/* 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
 *
 * 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 .
 */
#include "config.h"
#include 
#include 
#include "display-types.h"
#include "core/pika.h"
#include "core/pikacontext.h"
#include "menus/menus.h"
#include "widgets/pikaactiongroup.h"
#include "widgets/pikauimanager.h"
#include "pikadisplay.h"
#include "pikadisplayshell.h"
#include "pikadisplayshell-actions.h"
#include "pikaimagewindow.h"
void
pika_display_shell_set_action_sensitive (PikaDisplayShell *shell,
                                         const gchar      *action,
                                         gboolean          sensitive)
{
  PikaImageWindow *window;
  PikaContext     *context;
  g_return_if_fail (PIKA_IS_DISPLAY_SHELL (shell));
  g_return_if_fail (action != NULL);
  window = pika_display_shell_get_window (shell);
  if (window && pika_image_window_get_active_shell (window) == shell)
    {
      PikaUIManager   *manager = menus_get_image_manager_singleton (shell->display->pika);
      PikaActionGroup *action_group;
      action_group = pika_ui_manager_get_action_group (manager, "view");
      if (action_group)
        pika_action_group_set_action_sensitive (action_group, action, sensitive, NULL);
    }
  context = pika_get_user_context (shell->display->pika);
  if (shell->display == pika_context_get_display (context))
    {
      PikaActionGroup *action_group;
      action_group = pika_ui_manager_get_action_group (shell->popup_manager,
                                                       "view");
      if (action_group)
        pika_action_group_set_action_sensitive (action_group, action, sensitive, NULL);
    }
}
void
pika_display_shell_set_action_active (PikaDisplayShell *shell,
                                      const gchar      *action,
                                      gboolean          active)
{
  PikaImageWindow *window;
  PikaContext     *context;
  g_return_if_fail (PIKA_IS_DISPLAY_SHELL (shell));
  g_return_if_fail (action != NULL);
  window = pika_display_shell_get_window (shell);
  if (window && pika_image_window_get_active_shell (window) == shell)
    {
      PikaUIManager   *manager = menus_get_image_manager_singleton (shell->display->pika);
      PikaActionGroup *action_group;
      action_group = pika_ui_manager_get_action_group (manager, "view");
      if (action_group)
        pika_action_group_set_action_active (action_group, action, active);
    }
  context = pika_get_user_context (shell->display->pika);
  if (shell->display == pika_context_get_display (context))
    {
      PikaActionGroup *action_group;
      action_group = pika_ui_manager_get_action_group (shell->popup_manager,
                                                       "view");
      if (action_group)
        pika_action_group_set_action_active (action_group, action, active);
    }
}
void
pika_display_shell_set_action_color (PikaDisplayShell *shell,
                                     const gchar      *action,
                                     const PikaRGB    *color)
{
  PikaImageWindow *window;
  PikaContext     *context;
  g_return_if_fail (PIKA_IS_DISPLAY_SHELL (shell));
  g_return_if_fail (action != NULL);
  window = pika_display_shell_get_window (shell);
  if (window && pika_image_window_get_active_shell (window) == shell)
    {
      PikaUIManager   *manager = menus_get_image_manager_singleton (shell->display->pika);
      PikaActionGroup *action_group;
      action_group = pika_ui_manager_get_action_group (manager, "view");
      if (action_group)
        pika_action_group_set_action_color (action_group, action, color, FALSE);
    }
  context = pika_get_user_context (shell->display->pika);
  if (shell->display == pika_context_get_display (context))
    {
      PikaActionGroup *action_group;
      action_group = pika_ui_manager_get_action_group (shell->popup_manager,
                                                       "view");
      if (action_group)
        pika_action_group_set_action_color (action_group, action, color, FALSE);
    }
}