2 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #ifndef _GTKMM_ACTION_H
4 #define _GTKMM_ACTION_H
11 /* Copyright (C) 2003 The gtkmm Development Team
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Library General Public
15 * License as published by the Free Software Foundation; either
16 * version 2 of the License, or (at your option) any later version.
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Library General Public License for more details.
23 * You should have received a copy of the GNU Library General Public
24 * License along with this library; if not, write to the Free
25 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #include <gtkmm/widget.h>
29 #include <gtkmm/accelgroup.h>
30 #include <gtkmm/stockid.h>
33 #ifndef DOXYGEN_SHOULD_SKIP_THIS
34 typedef struct _GtkAction GtkAction;
35 typedef struct _GtkActionClass GtkActionClass;
36 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
40 { class Action_Class; } // namespace Gtk
49 /** An action which can be triggered by a menu or toolbar item.
51 * Actions represent operations that the user can perform, along with
52 * some information about how it should be presented in the user interface.
53 * Each action provides methods to create icons, menu items and toolbar
54 * items representing itself.
56 * As well as the callback that is called when the action is activated,
57 * the following is also associated with the action:
59 * - a name (not translated, for path lookup)
60 * - a label (translated, for display)
62 * - whether the label indicates a stock id
63 * - a tooltip (optional, translated)
64 * - a toolbar label (optional, shorter than label)
66 * The action will also have some state information:
68 * - visible (shown/hidden)
69 * - sensitive (enabled/disabled)
71 * Apart from regular actions, there are toggle actions,
72 * which can be toggled between two states and radio actions,
73 * of which only one in a group can be in the "active" state.
74 * Other actions can be implemented as Gtk::Action subclasses.
76 * Each action can have one or more proxy menu item, toolbar button or other proxy widgets.
77 * 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.
80 class Action : public Glib::Object
83 #ifndef DOXYGEN_SHOULD_SKIP_THIS
86 typedef Action CppObjectType;
87 typedef Action_Class CppClassType;
88 typedef GtkAction BaseObjectType;
89 typedef GtkActionClass BaseClassType;
91 private: friend class Action_Class;
92 static CppClassType action_class_;
96 Action(const Action&);
97 Action& operator=(const Action&);
100 explicit Action(const Glib::ConstructParams& construct_params);
101 explicit Action(GtkAction* castitem);
103 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
108 #ifndef DOXYGEN_SHOULD_SKIP_THIS
109 static GType get_type() G_GNUC_CONST;
110 static GType get_base_type() G_GNUC_CONST;
113 ///Provides access to the underlying C GObject.
114 GtkAction* gobj() { return reinterpret_cast<GtkAction*>(gobject_); }
116 ///Provides access to the underlying C GObject.
117 const GtkAction* gobj() const { return reinterpret_cast<GtkAction*>(gobject_); }
119 ///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
120 GtkAction* gobj_copy();
127 explicit Action(const Glib::ustring& name, const StockID& stock_id = StockID(), const Glib::ustring& label = Glib::ustring(), const Glib::ustring& tooltip = Glib::ustring());
130 //Note that gtk_action_new() does not allow name to be NULL, which suggests that we should not have a default constructor,
131 //but it's OK to set the name later:
133 static Glib::RefPtr<Action> create();
136 static Glib::RefPtr<Action> create(const Glib::ustring& name, const Glib::ustring& label = Glib::ustring(), const Glib::ustring& tooltip = Glib::ustring());
137 static Glib::RefPtr<Action> create(const Glib::ustring& name, const Gtk::StockID& stock_id, const Glib::ustring& label = Glib::ustring(), const Glib::ustring& tooltip = Glib::ustring());
140 /** Return value: the name of the action. The string belongs to GTK+ and should not
141 * @return The name of the action. The string belongs to GTK+ and should not
146 Glib::ustring get_name() const;
149 /** Return value: <tt>true</tt> if the action and its associated action group
150 * @return <tt>true</tt> if the action and its associated action group
151 * are both sensitive.
155 bool is_sensitive() const;
157 /** Return value: <tt>true</tt> if the action itself is sensitive.
158 * @return <tt>true</tt> if the action itself is sensitive.
162 bool get_sensitive() const;
164 void set_tooltip(const Glib::ustring& tooltip);
167 /** Sets the ::sensitive property of the action to @a sensitive . Note that
168 * this doesn't necessarily mean effective sensitivity. See
173 * @param sensitive <tt>true</tt> to make the action sensitive.
175 void set_sensitive(bool sensitive = true);
178 /** Return value: <tt>true</tt> if the action and its associated action group
179 * @return <tt>true</tt> if the action and its associated action group
184 bool is_visible() const;
186 /** Return value: <tt>true</tt> if the action itself is visible.
187 * @return <tt>true</tt> if the action itself is visible.
191 bool get_visible() const;
193 /** Sets the ::visible property of the action to @a visible . Note that
194 * this doesn't necessarily mean effective visibility. See
199 * @param visible <tt>true</tt> to make the action visible.
201 void set_visible(bool visible = true);
204 /** Emits the "activate" signal on the specified action, if it isn't
205 * insensitive. This gets called by the proxy widgets when they get
208 * It can also be used to manually activate an action.
214 /** This function is intended for use by action implementations to
215 * create icons displayed in the proxy widgets.
216 * @param icon_size The size of the icon that should be created.
217 * @return A widget that displays the icon for this action.
221 Image* create_icon(IconSize icon_size);
223 /** Creates a menu item widget that proxies for the given action.
224 * @return A menu item connected to the action.
228 MenuItem* create_menu_item();
230 /** Creates a toolbar item widget that proxies for the given action.
231 * @return A toolbar item connected to the action.
235 ToolItem* create_tool_item();
237 /** If @a action provides a Gtk::Menu widget as a submenu for the menu
238 * item or the toolbar item it creates, this function returns an
239 * instance of that menu.
240 * @return The menu item provided by the action, or <tt>0</tt>.
246 /** Connects a widget to an action object as a proxy. Synchronises
247 * various properties of the action with the widget (such as label
248 * text, icon, tooltip, etc), and attaches a callback so that the
249 * action gets activated when the proxy widget does.
251 * If the widget is already connected to an action, it is disconnected
255 * @param proxy The proxy widget.
257 void connect_proxy(Widget& proxy);
259 /** Disconnects a proxy widget from an action.
260 * Does <em>not</em> destroy the widget, however.
263 * @param proxy The proxy widget.
265 void disconnect_proxy(Widget& proxy);
268 /** Return value: a G::SList of proxy widgets. The list is owned by GTK+
269 * @return A G::SList of proxy widgets. The list is owned by GTK+
270 * and must not be modified.
274 Glib::SListHandle<Widget*> get_proxies();
276 /** Return value: a G::SList of proxy widgets. The list is owned by GTK+
277 * @return A G::SList of proxy widgets. The list is owned by GTK+
278 * and must not be modified.
282 Glib::SListHandle<const Widget*> get_proxies() const;
285 /** Installs the accelerator for @a action if @a action has an
286 * accel path and group. See set_accel_path() and
289 * Since multiple proxies may independently trigger the installation
290 * of the accelerator, the @a action counts the number of times this
291 * function has been called and doesn't remove the accelerator until
292 * disconnect_accelerator() has been called as many times.
296 void connect_accelerator();
298 /** Undoes the effect of one call to connect_accelerator().
302 void disconnect_accelerator();
305 /** Returns: the accel path for this action, or <tt>0</tt>
306 * @return The accel path for this action, or <tt>0</tt>
307 * if none is set. The returned string is owned by GTK+
308 * and must not be freed or modified.
310 Glib::ustring get_accel_path() const;
312 /// For instance, void on_activate();
313 typedef sigc::slot<void> SlotActivate;
315 /** The "activate" signal is emitted when the action is activated.
318 * <tt>void on_my_%activate()</tt>
321 Glib::SignalProxy0< void > signal_activate();
324 //Used by AccelGroup:
326 /** Sets the accel path for this action. All proxy widgets associated
327 * with the action will have this accel path, so that their
328 * accelerators are consistent.
331 * @param accel_path The accelerator path.
333 void set_accel_path(const Glib::ustring& accel_path);
335 /** Sets the Gtk::AccelGroup in which the accelerator for this action
339 * @param accel_group A Gtk::AccelGroup or <tt>0</tt>.
341 void set_accel_group(const Glib::RefPtr<AccelGroup>& accel_group);
343 #ifdef GLIBMM_PROPERTIES_ENABLED
344 /** A unique name for the action.
346 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
347 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
348 * the value of the property changes.
350 Glib::PropertyProxy_ReadOnly<Glib::ustring> property_name() const;
351 #endif //#GLIBMM_PROPERTIES_ENABLED
354 #ifdef GLIBMM_PROPERTIES_ENABLED
355 /** The label used for menu items and buttons that activate this action.
357 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
358 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
359 * the value of the property changes.
361 Glib::PropertyProxy<Glib::ustring> property_label() ;
362 #endif //#GLIBMM_PROPERTIES_ENABLED
364 #ifdef GLIBMM_PROPERTIES_ENABLED
365 /** The label used for menu items and buttons that activate this action.
367 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
368 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
369 * the value of the property changes.
371 Glib::PropertyProxy_ReadOnly<Glib::ustring> property_label() const;
372 #endif //#GLIBMM_PROPERTIES_ENABLED
374 #ifdef GLIBMM_PROPERTIES_ENABLED
375 /** A shorter label that may be used on toolbar buttons.
377 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
378 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
379 * the value of the property changes.
381 Glib::PropertyProxy<Glib::ustring> property_short_label() ;
382 #endif //#GLIBMM_PROPERTIES_ENABLED
384 #ifdef GLIBMM_PROPERTIES_ENABLED
385 /** A shorter label that may be used on toolbar buttons.
387 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
388 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
389 * the value of the property changes.
391 Glib::PropertyProxy_ReadOnly<Glib::ustring> property_short_label() const;
392 #endif //#GLIBMM_PROPERTIES_ENABLED
394 #ifdef GLIBMM_PROPERTIES_ENABLED
395 /** A tooltip for this action.
397 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
398 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
399 * the value of the property changes.
401 Glib::PropertyProxy<Glib::ustring> property_tooltip() ;
402 #endif //#GLIBMM_PROPERTIES_ENABLED
404 #ifdef GLIBMM_PROPERTIES_ENABLED
405 /** A tooltip for this action.
407 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
408 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
409 * the value of the property changes.
411 Glib::PropertyProxy_ReadOnly<Glib::ustring> property_tooltip() const;
412 #endif //#GLIBMM_PROPERTIES_ENABLED
414 #ifdef GLIBMM_PROPERTIES_ENABLED
415 /** The stock icon displayed in widgets representing this action.
417 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
418 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
419 * the value of the property changes.
421 Glib::PropertyProxy<StockID> property_stock_id() ;
422 #endif //#GLIBMM_PROPERTIES_ENABLED
424 #ifdef GLIBMM_PROPERTIES_ENABLED
425 /** The stock icon displayed in widgets representing this action.
427 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
428 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
429 * the value of the property changes.
431 Glib::PropertyProxy_ReadOnly<StockID> property_stock_id() const;
432 #endif //#GLIBMM_PROPERTIES_ENABLED
434 #ifdef GLIBMM_PROPERTIES_ENABLED
435 /** Whether the toolbar item is visible when the toolbar is in a horizontal orientation.
437 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
438 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
439 * the value of the property changes.
441 Glib::PropertyProxy<bool> property_visible_horizontal() ;
442 #endif //#GLIBMM_PROPERTIES_ENABLED
444 #ifdef GLIBMM_PROPERTIES_ENABLED
445 /** Whether the toolbar item is visible when the toolbar is in a horizontal orientation.
447 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
448 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
449 * the value of the property changes.
451 Glib::PropertyProxy_ReadOnly<bool> property_visible_horizontal() const;
452 #endif //#GLIBMM_PROPERTIES_ENABLED
454 #ifdef GLIBMM_PROPERTIES_ENABLED
455 /** Whether the toolbar item is visible when the toolbar is in a vertical orientation.
457 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
458 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
459 * the value of the property changes.
461 Glib::PropertyProxy<bool> property_visible_vertical() ;
462 #endif //#GLIBMM_PROPERTIES_ENABLED
464 #ifdef GLIBMM_PROPERTIES_ENABLED
465 /** Whether the toolbar item is visible when the toolbar is in a vertical orientation.
467 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
468 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
469 * the value of the property changes.
471 Glib::PropertyProxy_ReadOnly<bool> property_visible_vertical() const;
472 #endif //#GLIBMM_PROPERTIES_ENABLED
474 #ifdef GLIBMM_PROPERTIES_ENABLED
475 /** Whether the action is considered important. When TRUE
477 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
478 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
479 * the value of the property changes.
481 Glib::PropertyProxy<bool> property_is_important() ;
482 #endif //#GLIBMM_PROPERTIES_ENABLED
484 #ifdef GLIBMM_PROPERTIES_ENABLED
485 /** Whether the action is considered important. When TRUE
487 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
488 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
489 * the value of the property changes.
491 Glib::PropertyProxy_ReadOnly<bool> property_is_important() const;
492 #endif //#GLIBMM_PROPERTIES_ENABLED
494 #ifdef GLIBMM_PROPERTIES_ENABLED
497 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
498 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
499 * the value of the property changes.
501 Glib::PropertyProxy<bool> property_hide_if_empty() ;
502 #endif //#GLIBMM_PROPERTIES_ENABLED
504 #ifdef GLIBMM_PROPERTIES_ENABLED
507 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
508 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
509 * the value of the property changes.
511 Glib::PropertyProxy_ReadOnly<bool> property_hide_if_empty() const;
512 #endif //#GLIBMM_PROPERTIES_ENABLED
514 #ifdef GLIBMM_PROPERTIES_ENABLED
515 /** Whether the action is enabled.
517 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
518 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
519 * the value of the property changes.
521 Glib::PropertyProxy<bool> property_sensitive() ;
522 #endif //#GLIBMM_PROPERTIES_ENABLED
524 #ifdef GLIBMM_PROPERTIES_ENABLED
525 /** Whether the action is enabled.
527 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
528 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
529 * the value of the property changes.
531 Glib::PropertyProxy_ReadOnly<bool> property_sensitive() const;
532 #endif //#GLIBMM_PROPERTIES_ENABLED
534 #ifdef GLIBMM_PROPERTIES_ENABLED
535 /** Whether the action is visible.
537 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
538 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
539 * the value of the property changes.
541 Glib::PropertyProxy<bool> property_visible() ;
542 #endif //#GLIBMM_PROPERTIES_ENABLED
544 #ifdef GLIBMM_PROPERTIES_ENABLED
545 /** Whether the action is visible.
547 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
548 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
549 * the value of the property changes.
551 Glib::PropertyProxy_ReadOnly<bool> property_visible() const;
552 #endif //#GLIBMM_PROPERTIES_ENABLED
556 //For use by child actions:
558 /** Disables calls to the activate()
559 * function by signals on the given proxy widget. This is used to
560 * break notification loops for things like check or radio actions.
562 * This function is intended for use by action implementations.
565 * @param proxy A proxy widget.
567 void block_activate_from(Widget& proxy);
569 /** Re-enables calls to the activate()
570 * function by signals on the given proxy widget. This undoes the
571 * blocking done by block_activate_from().
573 * This function is intended for use by action implementations.
576 * @param proxy A proxy widget.
578 void unblock_activate_from(Widget& proxy);
582 //Widget-creation routines:
583 #ifdef GLIBMM_VFUNCS_ENABLED
584 virtual Widget* create_menu_item_vfunc();
585 #endif //GLIBMM_VFUNCS_ENABLED
587 #ifdef GLIBMM_VFUNCS_ENABLED
588 virtual Widget* create_tool_item_vfunc();
589 #endif //GLIBMM_VFUNCS_ENABLED
591 #ifdef GLIBMM_VFUNCS_ENABLED
592 virtual void connect_proxy_vfunc(Widget* proxy);
593 #endif //GLIBMM_VFUNCS_ENABLED
595 #ifdef GLIBMM_VFUNCS_ENABLED
596 virtual void disconnect_proxy_vfunc(Widget* proxy);
597 #endif //GLIBMM_VFUNCS_ENABLED
603 //C++ methods used to invoke GTK+ virtual functions:
604 #ifdef GLIBMM_VFUNCS_ENABLED
605 #endif //GLIBMM_VFUNCS_ENABLED
608 //GTK+ Virtual Functions (override these to change behaviour):
609 #ifdef GLIBMM_VFUNCS_ENABLED
610 #endif //GLIBMM_VFUNCS_ENABLED
612 //Default Signal Handlers::
613 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
614 virtual void on_activate();
615 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
625 /** A Glib::wrap() method for this object.
627 * @param object The C instance.
628 * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
629 * @result A C++ instance that wraps this C instance.
631 * @relates Gtk::Action
633 Glib::RefPtr<Gtk::Action> wrap(GtkAction* object, bool take_copy = false);
637 #endif /* _GTKMM_ACTION_H */