/* 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-2001 Spencer Kimball, Peter Mattis and others
 *
 * 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 <gegl.h>
#include <gtk/gtk.h>

#include "libpikawidgets/pikawidgets.h"

#include "tools-types.h"

#include "core/pika.h"
#include "core/pikachannel.h"
#include "core/pikalayer.h"

#include "vectors/pikavectors.h"

#include "widgets/pikacontainerview.h"
#include "widgets/pikadialogfactory.h"
#include "widgets/pikaitemtreeview.h"
#include "widgets/pikawidgets-utils.h"
#include "widgets/pikawindowstrategy.h"

#include "pikatools-utils.h"



/*  public functions  */

void
pika_tools_blink_lock_box (Pika     *pika,
                           PikaItem *item)
{
  GtkWidget        *dockable;
  PikaItemTreeView *view;
  GdkMonitor       *monitor;
  const gchar      *identifier;

  g_return_if_fail (PIKA_IS_PIKA (pika));
  g_return_if_fail (PIKA_IS_ITEM (item));

  if (PIKA_IS_LAYER (item))
    identifier = "pika-layer-list";
  else if (PIKA_IS_CHANNEL (item))
    identifier = "pika-channel-list";
  else if (PIKA_IS_VECTORS (item))
    identifier = "pika-vectors-list";
  else
    return;

  monitor = pika_get_monitor_at_pointer ();

  dockable = pika_window_strategy_show_dockable_dialog (
    PIKA_WINDOW_STRATEGY (pika_get_window_strategy (pika)),
    pika,
    pika_dialog_factory_get_singleton (),
    monitor,
    identifier);

  if (! dockable)
    return;

  view = PIKA_ITEM_TREE_VIEW (gtk_bin_get_child (GTK_BIN (dockable)));
  pika_item_tree_view_blink_lock (view, item);
}

void
pika_tools_show_tool_options (Pika *pika)
{
  GdkMonitor *monitor;

  g_return_if_fail (PIKA_IS_PIKA (pika));

  monitor = pika_get_monitor_at_pointer ();

  pika_window_strategy_show_dockable_dialog (PIKA_WINDOW_STRATEGY (pika_get_window_strategy (pika)),
                                             pika,
                                             pika_dialog_factory_get_singleton (),
                                             monitor, "pika-tool-options");
}
