/* src/bazaar.p/bz-transact-icon-info.c
 *
 * Copyright 2026 AUTOGEN
 *
 * 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 3 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 <https://www.gnu.org/licenses/>.
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#include "src/bazaar.p/bz-transact-icon-info.h"



struct _BzTransactIconInfo
{
  GObject parent_instance;

  BzStateInfo *state;
  BzEntryGroup *group;
  GdkPaintable *paintable;
  BzTransactionEntryTracker *tracker;
};

G_DEFINE_FINAL_TYPE (BzTransactIconInfo, bz_transact_icon_info, G_TYPE_OBJECT);

enum
{
  PROP_0,

  PROP_STATE,
  PROP_GROUP,
  PROP_PAINTABLE,
  PROP_TRACKER,

  LAST_PROP
};
static GParamSpec *props[LAST_PROP] = { 0 };

static void
bz_transact_icon_info_dispose (GObject *object)
{
  BzTransactIconInfo *self = BZ_TRANSACT_ICON_INFO (object);

  g_clear_pointer (&self->state, g_object_unref);
  g_clear_pointer (&self->group, g_object_unref);
  g_clear_pointer (&self->paintable, g_object_unref);
  g_clear_pointer (&self->tracker, g_object_unref);

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

static void
bz_transact_icon_info_get_property (GObject    *object,
                       guint       prop_id,
                       GValue     *value,
                       GParamSpec *pspec)
{
  BzTransactIconInfo *self = BZ_TRANSACT_ICON_INFO (object);

  switch (prop_id)
    {
    case PROP_STATE:
      g_value_set_object (value, bz_transact_icon_info_get_state (self));
      break;
    case PROP_GROUP:
      g_value_set_object (value, bz_transact_icon_info_get_group (self));
      break;
    case PROP_PAINTABLE:
      g_value_set_object (value, bz_transact_icon_info_get_paintable (self));
      break;
    case PROP_TRACKER:
      g_value_set_object (value, bz_transact_icon_info_get_tracker (self));
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
    }
}

static void
bz_transact_icon_info_set_property (GObject      *object,
                       guint         prop_id,
                       const GValue *value,
                       GParamSpec   *pspec)
{
  BzTransactIconInfo *self = BZ_TRANSACT_ICON_INFO (object);

  switch (prop_id)
    {
    case PROP_STATE:
      bz_transact_icon_info_set_state (self, g_value_get_object (value));
      break;
    case PROP_GROUP:
      bz_transact_icon_info_set_group (self, g_value_get_object (value));
      break;
    case PROP_PAINTABLE:
      bz_transact_icon_info_set_paintable (self, g_value_get_object (value));
      break;
    case PROP_TRACKER:
      bz_transact_icon_info_set_tracker (self, g_value_get_object (value));
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
    }
}

static void
bz_transact_icon_info_class_init (BzTransactIconInfoClass *klass)
{
  GObjectClass *object_class = G_OBJECT_CLASS (klass);



  object_class->set_property = bz_transact_icon_info_set_property;
  object_class->get_property = bz_transact_icon_info_get_property;
  object_class->dispose      = bz_transact_icon_info_dispose;

  props[PROP_STATE] =
      g_param_spec_object (
          "state",
          NULL, NULL,
          BZ_TYPE_STATE_INFO,
          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);

  props[PROP_GROUP] =
      g_param_spec_object (
          "group",
          NULL, NULL,
          BZ_TYPE_ENTRY_GROUP,
          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);

  props[PROP_PAINTABLE] =
      g_param_spec_object (
          "paintable",
          NULL, NULL,
          GDK_TYPE_PAINTABLE,
          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);

  props[PROP_TRACKER] =
      g_param_spec_object (
          "tracker",
          NULL, NULL,
          BZ_TYPE_TRANSACTION_ENTRY_TRACKER,
          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);

  g_object_class_install_properties (object_class, LAST_PROP, props);
}

static void
bz_transact_icon_info_init (BzTransactIconInfo *self)
{
}

BzTransactIconInfo *
bz_transact_icon_info_new (void){
  return g_object_new (BZ_TYPE_TRANSACT_ICON_INFO, NULL);
}

BzStateInfo *
bz_transact_icon_info_get_state (BzTransactIconInfo *self){
  g_return_val_if_fail (BZ_IS_TRANSACT_ICON_INFO (self), NULL);
  return self->state;
}

BzEntryGroup *
bz_transact_icon_info_get_group (BzTransactIconInfo *self){
  g_return_val_if_fail (BZ_IS_TRANSACT_ICON_INFO (self), NULL);
  return self->group;
}

GdkPaintable *
bz_transact_icon_info_get_paintable (BzTransactIconInfo *self){
  g_return_val_if_fail (BZ_IS_TRANSACT_ICON_INFO (self), NULL);
  return self->paintable;
}

BzTransactionEntryTracker *
bz_transact_icon_info_get_tracker (BzTransactIconInfo *self){
  g_return_val_if_fail (BZ_IS_TRANSACT_ICON_INFO (self), NULL);
  return self->tracker;
}

void
bz_transact_icon_info_set_state (BzTransactIconInfo *self,
    BzStateInfo *state){
  g_return_if_fail (BZ_IS_TRANSACT_ICON_INFO (self));

  if (state == self->state)
    return;

  g_clear_pointer (&self->state, g_object_unref);
  if (state != NULL)
    self->state = g_object_ref (state);

  g_object_notify_by_pspec (G_OBJECT (self), props[PROP_STATE]);
}

void
bz_transact_icon_info_set_group (BzTransactIconInfo *self,
    BzEntryGroup *group){
  g_return_if_fail (BZ_IS_TRANSACT_ICON_INFO (self));

  if (group == self->group)
    return;

  g_clear_pointer (&self->group, g_object_unref);
  if (group != NULL)
    self->group = g_object_ref (group);

  g_object_notify_by_pspec (G_OBJECT (self), props[PROP_GROUP]);
}

void
bz_transact_icon_info_set_paintable (BzTransactIconInfo *self,
    GdkPaintable *paintable){
  g_return_if_fail (BZ_IS_TRANSACT_ICON_INFO (self));

  if (paintable == self->paintable)
    return;

  g_clear_pointer (&self->paintable, g_object_unref);
  if (paintable != NULL)
    self->paintable = g_object_ref (paintable);

  g_object_notify_by_pspec (G_OBJECT (self), props[PROP_PAINTABLE]);
}

void
bz_transact_icon_info_set_tracker (BzTransactIconInfo *self,
    BzTransactionEntryTracker *tracker){
  g_return_if_fail (BZ_IS_TRANSACT_ICON_INFO (self));

  if (tracker == self->tracker)
    return;

  g_clear_pointer (&self->tracker, g_object_unref);
  if (tracker != NULL)
    self->tracker = g_object_ref (tracker);

  g_object_notify_by_pspec (G_OBJECT (self), props[PROP_TRACKER]);
}



/* End of src/bazaar.p/bz-transact-icon-info.c */
