/* $Id: actiongroup.hg,v 1.17 2006/04/12 11:11:25 murrayc Exp $ */

/* 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 Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <gtkmm/widget.h>
#include <gtkmm/action.h>
#include <gtkmm/accelkey.h>
 
_DEFS(gtkmm,gtk)
_PINCLUDE(glibmm/private/object_p.h)


namespace Gtk
{
  
class ActionGroup : public Glib::Object
{
  _CLASS_GOBJECT(ActionGroup, GtkActionGroup, GTK_ACTION_GROUP, Glib::Object, GObject)

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

  _WRAP_METHOD(Glib::ListHandle< Glib::RefPtr<Action> > get_actions(), gtk_action_group_list_actions)
  _WRAP_METHOD(Glib::ListHandle< 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:
  _WRAP_METHOD(Glib::ustring translate_string(const Glib::ustring& str) 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)

  /** The connect_proxy signal is emitted after connecting a proxy to 
   * an action in the group. Note that the proxy may have been connected 
   * to a different action before.
   *
   * This is intended for simple customizations for which a custom action
   * class would be too clumsy, e.g. showing tooltips for menuitems in the
   * statusbar.
   *
   * UIManager proxies the signal and provides global notification 
   * just before any action is connected to a proxy, which is probably more
   * convenient to use.
   *
   * @param action the action
   * @param proxy the proxy
   */
  _WRAP_SIGNAL(void connect_proxy(const Glib::RefPtr<Action>& action, Widget* proxy), "connect_proxy", no_default_handler)
  
  /** The disconnect_proxy signal is emitted after disconnecting a proxy 
   * from an action in the group. 
   *
   * UIManager proxies the signal and provides global notification 
   * just before any action is connected to a proxy, which is probably more
   * convenient to use.
   *
   * @param action the action
   * @param proxy the proxy
   */
  _WRAP_SIGNAL(void disconnect_proxy(const Glib::RefPtr<Action>& action, Widget* proxy), "disconnect_proxy", no_default_handler)
  
  /** The pre_activate signal is emitted just before the @action in the
   * action_group is activated
   *
   * This is intended for UIManager to proxy the signal and provide global
   * notification just before any action is activated.
   *
   * @action the action
   */          
  _WRAP_SIGNAL(void pre_activate(const Glib::RefPtr<Action>& action), "pre_activate", no_default_handler)
  
  /** The post_activate signal is emitted just after the @action in the
   * @action_group is activated
   *
   * This is intended for UIManager to proxy the signal and provide global
   * notification just after any action is activated.
   *
   * @param action the action
   */ 
  _WRAP_SIGNAL(void post_activate(const Glib::RefPtr<Action>& action), "post_activate", no_default_handler) 
};

} // namespace Gtk

