/* 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, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#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()

//TODO: Deprecate this when we are ready. It is already deprecated in GTK+.
//_IS_DEPRECATED // This whole file is deprecated.

namespace Gtk
{

class ActionGroup
  : public Glib::Object,
    public Buildable
{
  _CLASS_GOBJECT(ActionGroup, GtkActionGroup, GTK_ACTION_GROUP, Glib::Object, GObject)
  _IMPLEMENTS_INTERFACE(Buildable)

protected:
  _WRAP_CTOR(ActionGroup(const Glib::ustring& name = Glib::ustring()), gtk_action_group_new)

public:
  _WRAP_CREATE(const Glib::ustring& name = Glib::ustring())

  _WRAP_METHOD(Glib::ustring get_name() const, gtk_action_group_get_name)

  _WRAP_METHOD(bool get_sensitive() const, gtk_action_group_get_sensitive)
  _WRAP_METHOD(void set_sensitive(bool sensitive = true), gtk_action_group_set_sensitive)
  _WRAP_METHOD(bool get_visible() const, gtk_action_group_get_visible)
  _WRAP_METHOD(void set_visible(bool visible = true), gtk_action_group_set_visible)

  _WRAP_METHOD(Glib::RefPtr<AccelGroup> get_accel_group(), gtk_action_group_get_accel_group, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const AccelGroup> get_accel_group() const, gtk_action_group_get_accel_group, refreturn, constversion)

  _WRAP_METHOD(void set_accel_group (const Glib::RefPtr<AccelGroup>& accel_group), gtk_action_group_set_accel_group)

  _WRAP_METHOD(Glib::RefPtr<Action> get_action(const Glib::ustring& action_name), gtk_action_group_get_action, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const Action> get_action(const Glib::ustring& action_name) const, gtk_action_group_get_action, refreturn, constversion)

#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)
#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)

  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.

  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?
  void add(const Glib::RefPtr<Action>& action, const Action::SlotActivate& slot);
  void add(const Glib::RefPtr<Action>& action, const AccelKey& accel_key, const Action::SlotActivate& slot);
  _WRAP_METHOD(void remove(const Glib::RefPtr<Action>& action), gtk_action_group_remove_action)

   //TODO: We probably need to use this in our add_actions() implementation.
   //But this whole class will be deprecated soon anyway.
  _WRAP_METHOD(Glib::ustring translate_string(const Glib::ustring& string) const, gtk_action_group_translate_string)


  //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)
  _WRAP_SIGNAL(void disconnect_proxy(const Glib::RefPtr<Action>& action, Widget* proxy), "disconnect_proxy", no_default_handler)
  _WRAP_SIGNAL(void pre_activate(const Glib::RefPtr<Action>& action), "pre_activate", no_default_handler)
  _WRAP_SIGNAL(void post_activate(const Glib::RefPtr<Action>& action), "post_activate", no_default_handler)

  _WRAP_PROPERTY("name", Glib::ustring)
  _WRAP_PROPERTY("sensitive", bool)
  _WRAP_PROPERTY("visible", bool)
  _WRAP_PROPERTY("accel-group", Glib::RefPtr<AccelGroup>)
};

} // namespace Gtk

