/* 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 . */ _CONFIGINCLUDE(gtkmmconfig.h) #include #include #include #include _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: Do this when we can stop using Gtk::Action in virtual functions in Gtk::Activatable, when we break ABI: //_IS_DEPRECATED // This whole file is deprecated. namespace Gtk { class GTKMM_API ActionGroup; //deprecated class GTKMM_API Menu; class GTKMM_API MenuItem; class GTKMM_API ToolItem; class GTKMM_API Image; class GTKMM_API StockID; //deprecated /** A deprecated action which can be triggered by a menu or toolbar item. * * Actions represent operations that the user can perform, along with * some information about how it should be presented in the user interface. * Each action provides methods to create icons, menu items and toolbar * items representing itself. * * As well as the callback that is called when the action is activated, * the following is also associated with the action: * * - a name (not translated, for path lookup) * - a label (translated, for display) * - an accelerator * - whether the label indicates a stock id * - a tooltip (optional, translated) * - a toolbar label (optional, shorter than label) * * The action will also have some state information: * * - visible (shown/hidden) * - sensitive (enabled/disabled) * * Apart from regular actions, there are toggle actions, * which can be toggled between two states and radio actions, * of which only one in a group can be in the "active" state. * Other actions can be implemented as Gtk::Action subclasses. * * Each action can have one or more proxy menu item, toolbar button or other proxy widgets. * Proxies mirror the state of the action (text label, tooltip, icon, visible, sensitive, etc), * and should change when the action's state changes. When the proxy is activated, * it should activate its action. * * @deprecated Use Gio::Action and Gio::SimpleAction instead, and associate actions * with Gtk::Actionable widgets. Use Gio::MenuModel for creating menus with * Gtk::Menu(const Glib::RefPtr& model).
* Some gtkmm widgets don't derive from Gtk::Actionable, although the corresponding * gtk+ widgets implement the GtkActionable interface. This discrepancy can't be * fixed until we can break ABI. You can sometimes work around this problem * by using a widget's %gobj() method and calling a gtk_actionable_*() method * directly. Several examples in the * Programming with gtkmm * book use Gio::SimpleAction, such as the menus and toolbars examples. * The online version of this tutorial describes gtkmm-4.0. */ class GTKMM_API Action : public Glib::Object, public Buildable { _CLASS_GOBJECT(Action, GtkAction, GTK_ACTION, Glib::Object, GObject, , , GTKMM_API) _IMPLEMENTS_INTERFACE(Buildable) protected: /** Creates an empty action. */ _CTOR_DEFAULT _DEPRECATE_IFDEF_START /** Creates an action with a stock ID. * The stock ID is used to set a default icon, text and accelerator for the * action. * * @param name A unique name for the action. * @param stock_id The stock icon to display in widgets representing the * action. * @param label The label displayed in menu items and on buttons. * @param tooltip A tooltip for the action. * @deprecated There is no corresponding replacement when using Gio::Action. */ explicit Action(const Glib::ustring& name, const StockID& stock_id = StockID(), const Glib::ustring& label = Glib::ustring(), const Glib::ustring& tooltip = Glib::ustring()); /** Creates an action with an icon name. * The action's icon will reflect the specified icon name in the user's * icon theme. * * @param name A unique name for the action. * @param icon_name An IconTheme icon name used for widgets representing the * action. * @param label The label displayed in menu items and on buttons. * @param tooltip A tooltip for the action. * @deprecated See set_icon_name(), set_label() and set_tooltip() for * replacements when using Gio::Action. */ explicit Action(const Glib::ustring& name, const Glib::ustring& icon_name, const Glib::ustring& label = Glib::ustring(), const Glib::ustring& tooltip = Glib::ustring()); _DEPRECATE_IFDEF_END public: //Note that gtk_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() _DEPRECATE_IFDEF_START /** Creates an action. * * @param name A unique name for the action. * @param label The label displayed in menu items and on buttons. * @param tooltip A tooltip for the action. * * @return A new Action. * @deprecated See set_label() and set_tooltip() for replacements when using Gio::Action. */ static Glib::RefPtr create(const Glib::ustring& name, const Glib::ustring& label = Glib::ustring(), const Glib::ustring& tooltip = Glib::ustring()); /** Creates an action with a stock ID. * The stock ID is used to set a default icon, text and accelerator for the * action. * * @param name A unique name for the action. * @param stock_id The stock icon to display in widgets representing the * action. * @param label The label displayed in menu items and on buttons. * @param tooltip A tooltip for the action. * * @return A new Action. * @deprecated There is no corresponding replacement when using Gio::Action. */ static Glib::RefPtr create(const Glib::ustring& name, const Gtk::StockID& stock_id, const Glib::ustring& label = Glib::ustring(), const Glib::ustring& tooltip = Glib::ustring()); /** Create an action with an icon name. * The action's icon will reflect the specified icon name in the user's * icon theme. * * @param name A unique name for the action. * @param icon_name An IconTheme icon name used for widgets representing the * action. * @param label The label displayed in menu items and on buttons. * @param tooltip A tooltip for the action. * * @return A new Action. * @deprecated See set_icon_name(), set_label() and set_tooltip() for * replacements when using Gio::Action. */ static Glib::RefPtr create_with_icon_name(const Glib::ustring& name, const Glib::ustring& icon_name, const Glib::ustring& label, const Glib::ustring& tooltip); _DEPRECATE_IFDEF_END _WRAP_METHOD(Glib::ustring get_name() const, gtk_action_get_name, deprecated "Use Gio::Action::get_name() on a Gio::Action instead.") _WRAP_METHOD(bool is_sensitive() const, gtk_action_is_sensitive, deprecated "Use Gio::Action::get_enabled() on a Gio::Action instead.") _WRAP_METHOD(bool get_sensitive() const, gtk_action_get_sensitive, deprecated "Use Gio::Action::get_enabled() on a Gio::Action instead.") _WRAP_METHOD(void set_sensitive(bool sensitive = true), gtk_action_set_sensitive, deprecated "Use Gio::SimpleAction::set_enabled() on a Gio::SimpleAction instead.") _WRAP_METHOD(bool is_visible() const, gtk_action_is_visible, deprecated "Use Gio::Action instead, and control and monitor the state of Gtk::Actionable widgets directly.") _WRAP_METHOD(bool get_visible() const, gtk_action_get_visible, deprecated "Use Gio::Action instead, and control and monitor the state of Gtk::Actionable widgets directly.") _WRAP_METHOD(void set_visible(bool visible = true), gtk_action_set_visible, deprecated "Use Gio::Action instead, and control and monitor the state of Gtk::Actionable widgets directly.") _WRAP_METHOD(void activate(), gtk_action_activate, deprecated "Use Gio::ActionGroup::activate_action() on a Gio::Action instead.") _WRAP_METHOD(Image* create_icon(IconSize icon_size), gtk_action_create_icon, deprecated "Use Gio::MenuItem::set_icon() to set an icon on a Gio::MenuItem, or Gtk::Container::add() to add a Gtk::Image to a Gtk::Button.") _WRAP_METHOD(MenuItem* create_menu_item(), gtk_action_create_menu_item, deprecated "Use a Gio::MenuItem and associate it with a Gio::Action instead.") _WRAP_METHOD(ToolItem* create_tool_item(), gtk_action_create_tool_item, deprecated "Use a Gtk::ToolItem and associate it with a Gio::Action using Gtk::Actionable::set_action_name() instead. (Impossible until GtkToolItem implements the GActionable interface.)") _WRAP_METHOD(Menu* create_menu(), gtk_action_create_menu, deprecated "Use Gio::Action and Gio::MenuModel instead, and create a Gtk::Menu with Gtk::Menu(const Glib::RefPtr& model).") #m4 dnl // This isn't in convert_gtk.m4, and the default behaviour is wrong. #m4 _CONVERSION(`GSList*', `std::vector', `Glib::SListHandler::slist_to_vector($3, Glib::OWNERSHIP_NONE)') #m4 _CONVERSION(`GSList*', `std::vector', `Glib::SListHandler::slist_to_vector($3, Glib::OWNERSHIP_NONE)') _WRAP_METHOD(std::vector get_proxies(), gtk_action_get_proxies, deprecated "There is no corresponding replacement when using Gio::Action.") _WRAP_METHOD(std::vector get_proxies() const, gtk_action_get_proxies, deprecated "There is no corresponding replacement when using Gio::Action.") _WRAP_METHOD(void connect_accelerator(), gtk_action_connect_accelerator, deprecated "Use Gio::Action and the accelerator group on an associated Gtk::Menu instead.") _WRAP_METHOD(void disconnect_accelerator(), gtk_action_disconnect_accelerator, deprecated "Use Gio::Action and the accelerator group on an associated Gtk::Menu instead.") _WRAP_METHOD(Glib::ustring get_accel_path() const, gtk_action_get_accel_path, deprecated "Use Gio::Action and the accelerator path on an associated Gtk::Menu instead.") /// For instance, void on_activate(); typedef sigc::slot SlotActivate; _WRAP_SIGNAL(void activate(), "activate", deprecated "Use Gio::SimpleAction::signal_activate() instead.") //Used by AccelGroup: _WRAP_METHOD(void set_accel_path(const Glib::ustring& accel_path), gtk_action_set_accel_path, deprecated "Use Gio::Action and the accelerator path on an associated Gtk::Menu instead.") _WRAP_METHOD(void set_accel_group(const Glib::RefPtr& accel_group), gtk_action_set_accel_group, deprecated "Use Gio::Action and the accelerator group on an associated Gtk::Menu instead.") _WRAP_METHOD(void set_label(const Glib::ustring& label), gtk_action_set_label, deprecated "Use Gio::Action instead, and set a label on a menu item with Gio::MenuItem::set_label(). For Gtk::Actionable widgets, use the widget-specific API to set a label.") _WRAP_METHOD(Glib::ustring get_label() const, gtk_action_get_label, deprecated "Use Gio::Action instead, and get a label from a menu item with Gio::MenuItem::get_attribute_value(). For Gtk::Actionable widgets, use the widget-specific API to get a label.") _WRAP_METHOD(void set_short_label(const Glib::ustring& short_label), gtk_action_set_short_label, deprecated "There is no corresponding replacement when using Gio::Action.") _WRAP_METHOD(Glib::ustring get_short_label() const, gtk_action_get_short_label, deprecated "There is no corresponding replacement when using Gio::Action.") _WRAP_METHOD(void set_tooltip(const Glib::ustring& tooltip), gtk_action_set_tooltip, deprecated "Use Gio::Action instead, and set tooltips on associated Gtk::Actionable widgets with Gtk::Widget::set_tooltip_text().") _WRAP_METHOD(Glib::ustring get_tooltip() const, gtk_action_get_tooltip, deprecated "Use Gio::Action instead, and get tooltips from associated Gtk::Actionable widgets with Gtk::Widget::get_tooltip_text().") _WRAP_METHOD(void set_stock_id(const StockID& stock_id), gtk_action_set_stock_id, deprecated "There is no corresponding replacement when using Gio::Action.") _WRAP_METHOD(StockID get_stock_id() const, gtk_action_get_stock_id, deprecated "There is no corresponding replacement when using Gio::Action.") _WRAP_METHOD(void set_gicon(const Glib::RefPtr& icon), gtk_action_set_gicon, deprecated "Use Gio::Action instead, and Gio::MenuItem::set_icon() to set an icon on a Gio::MenuItem associated with a Gio::Action, or Gtk::Container::add() to add a Gtk::Image to a Gtk::Button.") _WRAP_METHOD(Glib::RefPtr get_gicon(), gtk_action_get_gicon, refreturn, deprecated "Use Gio::Action instead, and Gio::MenuItem::get_attribute_value() to get an icon from a Gio::MenuItem associated with a Gio::Action.") _WRAP_METHOD(Glib::RefPtr get_gicon() const, gtk_action_get_gicon, refreturn, constversion, deprecated "Use Gio::Action instead, and Gio::MenuItem::get_attribute_value() to get an icon from a Gio::MenuItem associated with a Gio::Action.") _WRAP_METHOD(void set_icon_name(const Glib::ustring& icon_name), gtk_action_set_icon_name, deprecated "Use Gio::Action instead, and Gio::MenuItem::set_icon() to set an icon on a Gio::MenuItem associated with a Gio::Action, or Gtk::Container::add() to add a Gtk::Image to a Gtk::Button.") _WRAP_METHOD(Glib::ustring get_icon_name() const, gtk_action_get_icon_name, deprecated "Use Gio::Action instead, and Gio::MenuItem::get_attribute_value() to get an icon from a Gio::MenuItem associated with a Gio::Action.") _WRAP_METHOD(void set_visible_horizontal(bool visible_horizontal = true), gtk_action_set_visible_horizontal, deprecated "Use Gio::Action instead, and control and monitor the visibility of associated widgets and menu items directly.") _WRAP_METHOD(bool get_visible_horizontal() const, gtk_action_get_visible_horizontal, deprecated "Use Gio::Action instead, and control and monitor the visibility of associated widgets and menu items directly.") _WRAP_METHOD(void set_visible_vertical(bool visible_vertical = true), gtk_action_set_visible_vertical, deprecated "Use Gio::Action instead, and control and monitor the visibility of associated widgets and menu items directly.") _WRAP_METHOD(bool get_visible_vertical() const, gtk_action_get_visible_vertical, deprecated "Use Gio::Action instead, and control and monitor the visibility of associated widgets and menu items directly.") _WRAP_METHOD(void set_is_important(bool is_important = true), gtk_action_set_is_important, deprecated "Use Gio::Action instead, and control and monitor whether labels are shown directly.") _WRAP_METHOD(bool get_is_important() const, gtk_action_get_is_important, deprecated "Use Gio::Action instead, and control and monitor whether labels are shown directly.") _WRAP_METHOD(void set_always_show_image(bool always_show = true), gtk_action_set_always_show_image, deprecated "Use Gio::MenuItem::set_icon() on a Gio::MenuItem instead, if the item should have an image.") _WRAP_METHOD(bool get_always_show_image() const, gtk_action_get_always_show_image, deprecated "Use Gio::MenuItem::get_attribute_value() on a Gio::MenuItem instead.") _WRAP_METHOD(void block_activate(), gtk_action_block_activate, deprecated "Use Gio::SimpleAction::set_enabled() to disable the Gio::SimpleAction instead.") _WRAP_METHOD(void unblock_activate(), gtk_action_unblock_activate, deprecated "Use Gio::SimpleAction::set_enabled() to enable the Gio::SimpleAction instead.") //gtk_action_get_accel_closure() is too C-specific: _IGNORE(gtk_action_get_accel_closure) _WRAP_PROPERTY("name", Glib::ustring, deprecated "Use Gio::Action::property_name() instead.") _WRAP_PROPERTY("label", Glib::ustring, deprecated "Use the 'label' attribute on Gio::MenuItem instead.") _WRAP_PROPERTY("short_label", Glib::ustring, deprecated "There is no corresponding replacement when using Gio::Action.") _WRAP_PROPERTY("tooltip", Glib::ustring, deprecated "Use Gtk::Widget::set_tooltip_text() and Gtk::Widget::get_tooltip_text() instead.") _WRAP_PROPERTY("stock_id", StockID, deprecated "There is no corresponding replacement when using Gio::Action.") _WRAP_PROPERTY("gicon", Glib::RefPtr, deprecated "Use the 'icon' attribute on Gio::MenuItem instead.") _WRAP_PROPERTY("icon_name", Glib::ustring, deprecated "Use the 'icon' attribute on Gio::MenuItem instead.") _WRAP_PROPERTY("visible_horizontal", bool, deprecated "There is no corresponding replacement when using Gio::Action.") _WRAP_PROPERTY("visible_vertical", bool, deprecated "There is no corresponding replacement when using Gio::Action.") _WRAP_PROPERTY("visible_overflown", bool, deprecated "There is no corresponding replacement when using Gio::Action.") _WRAP_PROPERTY("is_important", bool, deprecated "There is no corresponding replacement when using Gio::Action.") _WRAP_PROPERTY("hide_if_empty", bool, deprecated "There is no corresponding replacement when using Gio::Action.") _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::Action.") _WRAP_PROPERTY("action_group", Glib::RefPtr, deprecated "Lookup the Gio::Action using Gio::ActionMap::lookup_action() instead.") _WRAP_PROPERTY("always-show-image", bool, deprecated "There is no corresponding replacement when using Gio::Action.") protected: //Widget-creation routines: _WRAP_VFUNC(Widget* create_menu_item(), "create_menu_item") _WRAP_VFUNC(Widget* create_tool_item(), "create_tool_item") _WRAP_VFUNC(void connect_proxy(Widget* proxy), "connect_proxy") _WRAP_VFUNC(void disconnect_proxy(Widget* proxy), "disconnect_proxy") }; } // namespace Gtk