/* 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
 *
 * pikacontainerview.h
 * Copyright (C) 2001-2010 Michael Natterer <mitch@gimp.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/>.
 */

#ifndef __PIKA_CONTAINER_VIEW_H__
#define __PIKA_CONTAINER_VIEW_H__


typedef enum
{
  PIKA_CONTAINER_VIEW_PROP_0,
  PIKA_CONTAINER_VIEW_PROP_CONTAINER,
  PIKA_CONTAINER_VIEW_PROP_CONTEXT,
  PIKA_CONTAINER_VIEW_PROP_SELECTION_MODE,
  PIKA_CONTAINER_VIEW_PROP_REORDERABLE,
  PIKA_CONTAINER_VIEW_PROP_VIEW_SIZE,
  PIKA_CONTAINER_VIEW_PROP_VIEW_BORDER_WIDTH,
  PIKA_CONTAINER_VIEW_PROP_LAST = PIKA_CONTAINER_VIEW_PROP_VIEW_BORDER_WIDTH
} PikaContainerViewProp;


#define PIKA_TYPE_CONTAINER_VIEW (pika_container_view_get_type ())
G_DECLARE_INTERFACE (PikaContainerView, pika_container_view, PIKA, CONTAINER_VIEW, GtkWidget)


struct _PikaContainerViewInterface
{
  GTypeInterface base_iface;

  /*  signals  */
  gboolean (* select_items)       (PikaContainerView *view,
                                   GList             *items,
                                   GList             *paths);

  void     (* activate_item)      (PikaContainerView *view,
                                   PikaViewable      *object,
                                   gpointer           insert_data);

  /*  virtual functions  */
  void     (* set_container)      (PikaContainerView *view,
                                   PikaContainer     *container);
  void     (* set_context)        (PikaContainerView *view,
                                   PikaContext       *context);
  void     (* set_selection_mode) (PikaContainerView *view,
                                   GtkSelectionMode   mode);

  gpointer (* insert_item)        (PikaContainerView *view,
                                   PikaViewable      *object,
                                   gpointer           parent_insert_data,
                                   gint               index);
  void     (* insert_items_after) (PikaContainerView *view);
  void     (* remove_item)        (PikaContainerView *view,
                                   PikaViewable      *object,
                                   gpointer           insert_data);
  void     (* reorder_item)       (PikaContainerView *view,
                                   PikaViewable      *object,
                                   gint               new_index,
                                   gpointer           insert_data);
  void     (* rename_item)        (PikaContainerView *view,
                                   PikaViewable      *object,
                                   gpointer           insert_data);
  void     (* expand_item)        (PikaContainerView *view,
                                   PikaViewable      *object,
                                   gpointer           insert_data);
  void     (* clear_items)        (PikaContainerView *view);
  void     (* set_view_size)      (PikaContainerView *view);
  gint     (* get_selected)       (PikaContainerView  *view,
                                   GList             **items,
                                   GList             **insert_data);


  /*  the destroy notifier for private->hash_table's values  */
  GDestroyNotify  insert_data_free;
  gboolean        model_is_tree;
};


PikaContainer    * pika_container_view_get_container      (PikaContainerView  *view);
void               pika_container_view_set_container      (PikaContainerView  *view,
                                                           PikaContainer      *container);

PikaContext      * pika_container_view_get_context        (PikaContainerView  *view);
void               pika_container_view_set_context        (PikaContainerView  *view,
                                                           PikaContext        *context);

GtkSelectionMode   pika_container_view_get_selection_mode (PikaContainerView  *view);
void               pika_container_view_set_selection_mode (PikaContainerView  *view,
                                                           GtkSelectionMode    mode);

gint               pika_container_view_get_view_size      (PikaContainerView  *view,
                                                           gint               *view_border_width);
void               pika_container_view_set_view_size      (PikaContainerView  *view,
                                                           gint                view_size,
                                                           gint                view_border_width);

gboolean           pika_container_view_get_reorderable    (PikaContainerView  *view);
void               pika_container_view_set_reorderable    (PikaContainerView  *view,
                                                           gboolean            reorderable);

GtkWidget        * pika_container_view_get_dnd_widget     (PikaContainerView  *view);
void               pika_container_view_set_dnd_widget     (PikaContainerView  *view,
                                                           GtkWidget          *dnd_widget);

void               pika_container_view_enable_dnd         (PikaContainerView  *editor,
                                                           GtkButton          *button,
                                                           GType               children_type);

gboolean           pika_container_view_select_items       (PikaContainerView  *view,
                                                           GList              *viewables);
gboolean           pika_container_view_select_item        (PikaContainerView  *view,
                                                           PikaViewable       *viewable);
void               pika_container_view_activate_item      (PikaContainerView  *view,
                                                           PikaViewable       *viewable);
gint               pika_container_view_get_selected       (PikaContainerView  *view,
                                                           GList             **items,
                                                           GList             **items_data);
gboolean           pika_container_view_is_item_selected   (PikaContainerView  *view,
                                                           PikaViewable       *viewable);

/*  protected  */

gpointer           pika_container_view_lookup             (PikaContainerView  *view,
                                                           PikaViewable       *viewable);
gboolean           pika_container_view_contains           (PikaContainerView *view,
                                                           GList             *viewables);


gboolean           pika_container_view_item_selected      (PikaContainerView  *view,
                                                           PikaViewable       *item);
gboolean           pika_container_view_multi_selected     (PikaContainerView  *view,
                                                           GList              *items,
                                                           GList              *paths);
void               pika_container_view_item_activated     (PikaContainerView  *view,
                                                           PikaViewable       *item);

/*  convenience functions  */

void               pika_container_view_install_properties (GObjectClass       *klass);
void               pika_container_view_set_property       (GObject            *object,
                                                           guint               property_id,
                                                           const GValue       *value,
                                                           GParamSpec         *pspec);
void               pika_container_view_get_property       (GObject            *object,
                                                           guint               property_id,
                                                           GValue             *value,
                                                           GParamSpec         *pspec);

#endif  /*  __PIKA_CONTAINER_VIEW_H__  */
