/* PIKA - Photo and Image Kooker Application
 * a rebranding of The GNU Image Manipulation Program (created with heckimp)
 * A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
 *
 * Original copyright, applying to most contents (license remains unchanged): 
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
 * pikadockcontainer.c
 * Copyright (C) 2011 Martin Nordholts <martinn@src.gnome.org>
 *
 * 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/>.
 */

#include "config.h"

#include <gtk/gtk.h>

#include "widgets-types.h"

#include "pikadockcontainer.h"


G_DEFINE_INTERFACE (PikaDockContainer, pika_dock_container, GTK_TYPE_WIDGET)


/*  private functions  */


static void
pika_dock_container_default_init (PikaDockContainerInterface *iface)
{
}


/*  public functions  */


/**
 * pika_dock_container_get_docks:
 * @container: A #PikaDockContainer
 *
 * Returns: A list of #PikaDock:s in the dock container. Free with
 *          g_list_free() when done.
 **/
GList *
pika_dock_container_get_docks (PikaDockContainer *container)
{
  PikaDockContainerInterface *iface;

  g_return_val_if_fail (PIKA_IS_DOCK_CONTAINER (container), NULL);

  iface = PIKA_DOCK_CONTAINER_GET_IFACE (container);

  if (iface->get_docks)
    return iface->get_docks (container);

  return NULL;
}

/**
 * pika_dock_container_get_dialog_factory:
 * @container: A #PikaDockContainer
 *
 * Returns: The #PikaDialogFactory of the #PikaDockContainer
 **/
PikaDialogFactory *
pika_dock_container_get_dialog_factory (PikaDockContainer *container)
{
  PikaDockContainerInterface *iface;

  g_return_val_if_fail (PIKA_IS_DOCK_CONTAINER (container), NULL);

  iface = PIKA_DOCK_CONTAINER_GET_IFACE (container);

  if (iface->get_dialog_factory)
    return iface->get_dialog_factory (container);

  return NULL;
}

/**
 * pika_dock_container_get_ui_manager:
 * @container: A #PikaDockContainer
 *
 * Returns: The #PikaUIManager of the #PikaDockContainer
 **/
PikaUIManager *
pika_dock_container_get_ui_manager (PikaDockContainer *container)
{
  PikaDockContainerInterface *iface;

  g_return_val_if_fail (PIKA_IS_DOCK_CONTAINER (container), NULL);

  iface = PIKA_DOCK_CONTAINER_GET_IFACE (container);

  if (iface->get_ui_manager)
    return iface->get_ui_manager (container);

  return NULL;
}

/**
 * pika_dock_container_add_dock:
 * @container: A #PikaDockContainer
 * @dock:      The newly created #PikaDock to add to the container.
 * @dock_info: The #PikaSessionInfoDock the @dock was created from.
 *
 * Add @dock that was created from @dock_info to @container.
 **/
void
pika_dock_container_add_dock (PikaDockContainer   *container,
                              PikaDock            *dock,
                              PikaSessionInfoDock *dock_info)
{
  PikaDockContainerInterface *iface;

  g_return_if_fail (PIKA_IS_DOCK_CONTAINER (container));

  iface = PIKA_DOCK_CONTAINER_GET_IFACE (container);

  if (iface->add_dock)
    iface->add_dock (container,
                     dock,
                     dock_info);
}

/**
 * pika_dock_container_get_dock_side:
 * @container: A #PikaDockContainer
 * @dock:      A #PikaDock
 *
 * Returns: What side @dock is in in @container, either
 *          PIKA_ALIGN_LEFT or PIKA_ALIGN_RIGHT, or -1 if the side
 *          concept is not applicable.
 **/
PikaAlignmentType
pika_dock_container_get_dock_side (PikaDockContainer   *container,
                                   PikaDock            *dock)
{
  PikaDockContainerInterface *iface;

  g_return_val_if_fail (PIKA_IS_DOCK_CONTAINER (container), -1);

  iface = PIKA_DOCK_CONTAINER_GET_IFACE (container);

  if (iface->get_dock_side)
    return iface->get_dock_side (container, dock);

  return -1;
}
