/* $Id: recentaction.hg,v 1.5 2004/07/01 08:55:45 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 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., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <gtkmm/action.h>
#include <gtkmm/recentchooser.h>
#include <gtkmm/recentmanager.h>
#include <gtkmm/stockid.h>

_DEFS(gtkmm,gtk)
_PINCLUDE(gtkmm/private/action_p.h)


namespace Gtk
{

/** An action of which represents a list of recently used files.
 *
 * A Gtk::RecentAction represents a list of recently used files, 
 * which can be shown by widgets such as Gtk::RecentChooserDialog or 
 * Gtk::RecentChooserMenu.
 * To construct a submenu showing recently used files, use a 
 * Gtk::RecentAction as the action for a <menuitem>. To construct a menu 
 * toolbutton showing the recently used files in the popup menu, use a 
 * Gtk::RecentAction as the action for a <toolitem> element.
 *
 * See also the methods in the RecentChooser base class.
 *
 * @newin{2,12}
 *
 * @ingroup RecentFiles
 */
class RecentAction
  : public Gtk::Action,
    public Gtk::RecentChooser
{
  _CLASS_GOBJECT(RecentAction, GtkRecentAction, GTK_RECENT_ACTION, Gtk::Action, GtkAction)
  _IMPLEMENTS_INTERFACE(RecentChooser)

protected:
  _CTOR_DEFAULT

//Make sure that we use NULL instead of empty strings for the constructors:
#m4 _CONVERSION(`const Glib::ustring&',`const char*',`$3.empty() ? 0 : $3.c_str()')

  //Note that the order of the parameters is not the same as gtk_recent_action_new(), because 
  //a) we want to be consistent with Action, ToggleAction, etc.
  //b) this allows us to use the StockID parameter to distinguish the create() overloads.
  _WRAP_CTOR(RecentAction(const Glib::ustring& name, const StockID& stock_id = StockID(), const Glib::ustring& label = Glib::ustring(), const Glib::ustring& tooltip = Glib::ustring()), gtk_recent_action_new)
  _WRAP_CTOR(RecentAction(const Glib::ustring& name, const StockID& stock_id, const Glib::ustring& label, const Glib::ustring& tooltip, const Glib::RefPtr<RecentManager>& recent_manager), gtk_recent_action_new_for_manager )

public:
  //Note that gtk_recent_action_new() does not allow name to be NULL, which suggests that we should not have a default constructor,
  //but it's OK to set the name later:
  _WRAP_CREATE()

  static Glib::RefPtr<RecentAction> create(const Glib::ustring& name, const Glib::ustring& label = Glib::ustring(), const Glib::ustring& tooltip = Glib::ustring());
  _WRAP_CREATE(const Glib::ustring& name, const Gtk::StockID& stock_id, const Glib::ustring& label = Glib::ustring(), const Glib::ustring& tooltip = Glib::ustring())
  _WRAP_CREATE(const Glib::ustring& name, const Gtk::StockID& stock_id, const Glib::ustring& label, const Glib::ustring& tooltip, const Glib::RefPtr<RecentManager>& recent_manager)


  _WRAP_METHOD(bool get_show_numbers(), gtk_recent_action_get_show_numbers)
  _WRAP_METHOD(void set_show_numbers(bool show_numbers = true), gtk_recent_action_set_show_numbers)

  _WRAP_PROPERTY("show-numbers", bool)          
};

} // namespace Gtk

