/* Copyright (C) 2020 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 <http://www.gnu.org/licenses/>.
 */

_CONFIGINCLUDE(gtkmmconfig.h)

#include <glibmm/object.h>
#include <gtkmm/shortcutaction.h>
#include <gtkmm/shortcuttrigger.h>
#include <gtk/gtk.h>

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

namespace Gtk
{
/** An object describing a keyboard shortcut.
 *
 * %Gtk::Shortcut is the low level object used for managing keyboard shortcuts.
 * It contains a description of how to trigger the shortcut via a
 * Gtk::ShortcutTrigger and a way to activate the shortcut on a widget
 * via Gtk::ShortcutAction.
 *
 * The actual work is usually done via Gtk::ShortcutController, which
 * decides if and when to activate a shortcut. Using that controller
 * directly however is rarely necessary as various higher level
 * convenience APIs exist on Widgets that make it easier to use
 * shortcuts in GTK.
 *
 * %Gtk::Shortcut does provide functionality to make it easy for users
 * to work with shortcuts, either by providing informational strings
 * for display purposes or by allowing shortcuts to be configured.
 *
 * @see Gtk::ShortcutController, Gtk::ShortcutAction, Gtk::ShortcutTrigger

 * @ingroup Gestures
 * @newin{3,98}
 */
class GTKMM_API Shortcut : public Glib::Object
{
  _CLASS_GOBJECT(Shortcut, GtkShortcut, GTK_SHORTCUT, Glib::Object, GObject, , , GTKMM_API)
  _DO_NOT_DERIVE_GTYPE dnl// GtkShortcut is a final type
  _ABI_AS_WITH_DERIVED_GTYPE dnl// Remove when we can break ABI
  _STRUCT_NOT_HIDDEN
protected:
  _WRAP_CTOR(Shortcut(const Glib::RefPtr<const ShortcutTrigger>& trigger,
    const Glib::RefPtr<const ShortcutAction>& action), gtk_shortcut_new)
  _IGNORE(gtk_shortcut_new_with_arguments)

public:
  _WRAP_CREATE(const Glib::RefPtr<const ShortcutTrigger>& trigger,
    const Glib::RefPtr<const ShortcutAction>& action)

  // gtk_shortcut_set_trigger() and gtk_shortcut_set_action() don't take a ref (transfer full).
#m4 _CONVERSION(`const Glib::RefPtr<const ShortcutTrigger>&', `GtkShortcutTrigger*', `Glib::unwrap_copy(std::const_pointer_cast<ShortcutTrigger>($3))')
#m4 _CONVERSION(`const Glib::RefPtr<const ShortcutAction>&', `GtkShortcutAction*', `Glib::unwrap_copy(std::const_pointer_cast<ShortcutAction>($3))')
#m4 _CONVERSION(`GVariant*',`Glib::VariantBase',`Glib::wrap($3, true)')
  // ShortcutTrigger, ShortcutAction and Glib::VariantBase are immutable.
  // No need for non-const get-methods.
  _WRAP_METHOD(Glib::RefPtr<ShortcutTrigger> get_trigger() const, gtk_shortcut_get_trigger, refreturn)
  _WRAP_METHOD(void set_trigger(const Glib::RefPtr<const ShortcutTrigger>& trigger), gtk_shortcut_set_trigger)
  _WRAP_METHOD(Glib::RefPtr<ShortcutAction> get_action() const, gtk_shortcut_get_action, refreturn)
  _WRAP_METHOD(void set_trigger(const Glib::RefPtr<const ShortcutAction>& action), gtk_shortcut_set_action)
  _WRAP_METHOD(Glib::VariantBase get_arguments() const, gtk_shortcut_get_arguments)
  _WRAP_METHOD(void set_arguments(const Glib::VariantBase& args) const, gtk_shortcut_set_arguments)

  _WRAP_PROPERTY("trigger", Glib::RefPtr<ShortcutTrigger>)
  _WRAP_PROPERTY("action", Glib::RefPtr<ShortcutAction>)
  _WRAP_PROPERTY("arguments", Glib::VariantBase)
};

} //namespace Gtk
