/* Copyright (C) 2003 The gtkmm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
 */

// To exclude this file from the documentation when build-deprecated-api=false.
_CONFIGINCLUDE(gtkmmconfig.h)

#include <vector>
#include <gtkmm/widget.h>
#include <gtkmm/action.h>
#include <gtkmm/accelkey.h>
#include <gtkmm/accelgroup.h>

_DEFS(gtkmm,gtk)
_PINCLUDE(glibmm/private/object_p.h)

#m4 _PUSH(SECTION_CC_PRE_INCLUDES)
#undef GTK_DISABLE_DEPRECATED
#define GDK_DISABLE_DEPRECATION_WARNINGS 1
#m4 _POP()

_IS_DEPRECATED // This whole file is deprecated.

namespace Gtk
{

/** A deprecated action group.
 * It is essentially a map from names to Gtk::Action objects.
 *
 * @deprecated Use Gio::ActionGroup and Gio::Action instead.
 */
class GTKMM_API ActionGroup
  : public Glib::Object,
    public Buildable
{
  _CLASS_GOBJECT(ActionGroup, GtkActionGroup, GTK_ACTION_GROUP, Glib::Object, GObject, , , GTKMM_API)
  _IMPLEMENTS_INTERFACE(Buildable)

protected:
  /** @deprecated Use Gio::ActionGroup and give it a name with Gtk::Widget::insert_action_group().
   */
  _WRAP_CTOR(ActionGroup(const Glib::ustring& name = Glib::ustring()), gtk_action_group_new)

public:
  /** @deprecated Use Gio::ActionGroup and give it a name with Gtk::Widget::insert_action_group().
   */
  _WRAP_CREATE(const Glib::ustring& name = Glib::ustring())

  _WRAP_METHOD(Glib::ustring get_name() const, gtk_action_group_get_name,
    deprecated "There is no corresponding replacement when using Gio::ActionGroup.")

  _WRAP_METHOD(bool get_sensitive() const, gtk_action_group_get_sensitive,
    deprecated "Use Gio::ActionGroup::get_action_enabled() or Gio::Action::get_enabled() instead.")
  _WRAP_METHOD(void set_sensitive(bool sensitive = true), gtk_action_group_set_sensitive,
    deprecated "Use Gio::SimpleAction::set_enabled() instead.")
  _WRAP_METHOD(bool get_visible() const, gtk_action_group_get_visible,
    deprecated "Use Gio::ActionGroup instead, and control and monitor the state of Gtk::Actionable widgets directly.")
  _WRAP_METHOD(void set_visible(bool visible = true), gtk_action_group_set_visible,
    deprecated "Use Gio::ActionGroup instead, and control and monitor the state of Gtk::Actionable widgets directly.")

  _WRAP_METHOD(Glib::RefPtr<AccelGroup> get_accel_group(), gtk_action_group_get_accel_group, refreturn,
    deprecated "Use Gio::ActionGroup and the accelerator group on an associated Gtk::Menu instead.")
  _WRAP_METHOD(Glib::RefPtr<const AccelGroup> get_accel_group() const, gtk_action_group_get_accel_group, refreturn, constversion,
    deprecated "Use Gio::ActionGroup and the accelerator group on an associated Gtk::Menu instead.")
  _WRAP_METHOD(void set_accel_group (const Glib::RefPtr<AccelGroup>& accel_group), gtk_action_group_set_accel_group,
    deprecated "Use Gio::ActionGroup and the accelerator group on an associated Gtk::Menu instead.")

  _WRAP_METHOD(Glib::RefPtr<Action> get_action(const Glib::ustring& action_name), gtk_action_group_get_action, refreturn,
    deprecated "Use Gio::ActionMap::lookup_action() on a Gio::SimpleActionGroup instead.")
  _WRAP_METHOD(Glib::RefPtr<const Action> get_action(const Glib::ustring& action_name) const, gtk_action_group_get_action, refreturn, constversion,
    deprecated "Use Gio::ActionMap::lookup_action() on a Gio::SimpleActionGroup instead.")

#m4 _CONVERSION(`GList*',`std::vector< Glib::RefPtr<Action> >',`Glib::ListHandler< Glib::RefPtr<Action> >::list_to_vector($3, Glib::OWNERSHIP_SHALLOW)')
  _WRAP_METHOD(std::vector< Glib::RefPtr<Action> > get_actions(), gtk_action_group_list_actions,
    deprecated "Use Gio::ActionGroup::list_actions() and Gio::ActionMap::lookup_action() on a Gio::SimpleActionGroup instead.")
#m4 _CONVERSION(`GList*',`std::vector< Glib::RefPtr<const Action> >',`Glib::ListHandler< Glib::RefPtr<const Action> >::list_to_vector($3, Glib::OWNERSHIP_SHALLOW)')
  _WRAP_METHOD(std::vector< Glib::RefPtr<const Action> > get_actions() const, gtk_action_group_list_actions,
    deprecated "Use Gio::ActionGroup::list_actions() and Gio::ActionMap::lookup_action() on a Gio::SimpleActionGroup instead.")

_DEPRECATE_IFDEF_START
  /** @deprecated Use Gio::ActionMap::add_action() on a Gio::SimpleActionGroup instead.
   */
  void add(const Glib::RefPtr<Action>& action);
  _IGNORE(gtk_action_group_add_action)
  //We want it to always try to use the stock accelerator,
  //so we use gtk_action_group_add_action_with_accel(), instead of gtk_action_group_add_action(),
  //passing null for the accelerator.

  /** @deprecated Use Gio::ActionMap::add_action() on a Gio::SimpleActionGroup instead,
   * and Gtk::Application::set_accel_for_action().
   */
  void add(const Glib::RefPtr<Action>& action, const AccelKey& accel_key);
  _IGNORE(gtk_action_group_add_action_with_accel)
  //We need to duplicate the gtk_action_group_add_action_with_accel() implementation, because we want to
  //use AccelKey, not just the accelerator string format that is _one_ of the ways to create an AccelKey.

  //TODO: Could this whole class have an STL-style interface?
  /** @deprecated Use Gio::ActionMap::add_action() on a Gio::SimpleActionGroup instead.
   */
  void add(const Glib::RefPtr<Action>& action, const Action::SlotActivate& slot);
  /** @deprecated Use Gio::ActionMap::add_action() on a Gio::SimpleActionGroup instead,
   * and Gtk::Application::set_accel_for_action().
   */
  void add(const Glib::RefPtr<Action>& action, const AccelKey& accel_key, const Action::SlotActivate& slot);
_DEPRECATE_IFDEF_END
  _WRAP_METHOD(void remove(const Glib::RefPtr<Action>& action), gtk_action_group_remove_action,
    deprecated "Use Gio::ActionMap::remove_action() on a Gio::SimpleActionGroup instead.")

   //TODO: We probably need to use this in our add_actions() implementation.
   //But this whole class is deprecated anyway.
  _WRAP_METHOD(Glib::ustring translate_string(const Glib::ustring& string) const, gtk_action_group_translate_string,
    deprecated "There is no corresponding replacement when using Gio::ActionGroup.")

  //These are just C convenience methods:
  _IGNORE(gtk_action_group_add_actions, gtk_action_group_add_toggle_actions, gtk_action_group_add_radio_actions,
          gtk_action_group_add_actions_full, gtk_action_group_add_toggle_actions_full,
          gtk_action_group_add_radio_actions_full)
  //These are also just C convenience methods that are useless unless you are using the other convenience methods:
  _IGNORE(gtk_action_group_set_translate_func, gtk_action_group_set_translation_domain)

#m4 _CONVERSION(`GtkAction*',`const Glib::RefPtr<Action>&',`Glib::wrap($3, true)')
  _WRAP_SIGNAL(void connect_proxy(const Glib::RefPtr<Action>& action, Widget* proxy), "connect_proxy", no_default_handler,
    deprecated "There is no corresponding replacement when using Gio::ActionGroup.")
  _WRAP_SIGNAL(void disconnect_proxy(const Glib::RefPtr<Action>& action, Widget* proxy), "disconnect_proxy", no_default_handler,
    deprecated "There is no corresponding replacement when using Gio::ActionGroup.")
  _WRAP_SIGNAL(void pre_activate(const Glib::RefPtr<Action>& action), "pre_activate", no_default_handler,
    deprecated "There is no corresponding replacement when using Gio::ActionGroup.")
  _WRAP_SIGNAL(void post_activate(const Glib::RefPtr<Action>& action), "post_activate", no_default_handler,
    deprecated "There is no corresponding replacement when using Gio::ActionGroup.")

  _WRAP_PROPERTY("name", Glib::ustring, deprecated "There is no corresponding replacement when using Gio::ActionGroup.")
  _WRAP_PROPERTY("sensitive", bool, deprecated "Use Gio::Action::property_enabled() and Gio::SimpleAction::property_enabled() instead.")
  _WRAP_PROPERTY("visible", bool, deprecated "There is no corresponding replacement when using Gio::ActionGroup.")
  _WRAP_PROPERTY("accel-group", Glib::RefPtr<AccelGroup>, deprecated "Use Gio::ActionGroup and the accelerator group on an associated Gtk::Menu instead.")
};

} // namespace Gtk
