4
\description{An interface for activatable widgets}
5
\section{Methods and Functions}{
6
\code{\link{gtkActivatableDoSetRelatedAction}(object, action)}\cr
7
\code{\link{gtkActivatableGetRelatedAction}(object)}\cr
8
\code{\link{gtkActivatableGetUseActionAppearance}(object)}\cr
9
\code{\link{gtkActivatableSyncActionProperties}(object, action = NULL)}\cr
10
\code{\link{gtkActivatableSetRelatedAction}(object, action)}\cr
11
\code{\link{gtkActivatableSetUseActionAppearance}(object, use.appearance)}\cr
13
\section{Hierarchy}{\preformatted{GInterface
15
\section{Implementations}{GtkActivatable is implemented by
16
\code{\link{GtkButton}}, \code{\link{GtkCheckButton}}, \code{\link{GtkCheckMenuItem}}, \code{\link{GtkColorButton}}, \code{\link{GtkFontButton}}, \code{\link{GtkImageMenuItem}}, \code{\link{GtkLinkButton}}, \code{\link{GtkMenuItem}}, \code{\link{GtkMenuToolButton}}, \code{\link{GtkOptionMenu}}, \code{\link{GtkRadioButton}}, \code{\link{GtkRadioMenuItem}}, \code{\link{GtkRadioToolButton}}, \code{\link{GtkRecentChooserMenu}}, \code{\link{GtkScaleButton}}, \code{\link{GtkSeparatorMenuItem}}, \code{\link{GtkSeparatorToolItem}}, \code{\link{GtkTearoffMenuItem}}, \code{\link{GtkToggleButton}}, \code{\link{GtkToggleToolButton}}, \code{\link{GtkToolButton}}, \code{\link{GtkToolItem}} and \code{\link{GtkVolumeButton}}.}
17
\section{Detailed Description}{Activatable widgets can be connected to a \code{\link{GtkAction}} and reflects
18
the state of its action. A \code{\link{GtkActivatable}} can also provide feedback
19
through its action, as they are responsible for activating their
21
\section{Implementing GtkActivatable}{When extending a class that is already \code{\link{GtkActivatable}}; it is only
22
necessary to implement the \code{\link{GtkActivatable}}->\code{syncActionProperties()}
23
and \code{\link{GtkActivatable}}->\code{update()} methods and chain up to the parent
24
implementation, however when introducing
25
a new \code{\link{GtkActivatable}} class; the \verb{"related-action"} and
26
\verb{"use-action-appearance"} properties need to be handled by
27
the implementor. Handling these properties is mostly a matter of installing
28
the action pointer and boolean flag on your instance, and calling
29
\code{\link{gtkActivatableDoSetRelatedAction}} and
30
\code{\link{gtkActivatableSyncActionProperties}} at the appropriate times.
32
\emph{A class fragment implementing \code{\link{GtkActivatable}}}\preformatted{enum {
35
PROP_ACTIVATABLE_RELATED_ACTION,
36
PROP_ACTIVATABLE_USE_ACTION_APPEARANCE
45
gboolean use_action_appearance;
50
static void foo_bar_activatable_interface_init (GtkActivatableIface *iface);
51
static void foo_bar_activatable_update (GtkActivatable *activatable,
53
const gchar *property_name);
54
static void foo_bar_activatable_sync_action_properties (GtkActivatable *activatable,
60
foo_bar_class_init (FooBarClass *klass)
65
g_object_class_override_property (gobject_class, PROP_ACTIVATABLE_RELATED_ACTION, "related-action");
66
g_object_class_override_property (gobject_class, PROP_ACTIVATABLE_USE_ACTION_APPEARANCE, "use-action-appearance");
73
foo_bar_activatable_interface_init (GtkActivatableIface *iface)
75
iface->update = foo_bar_activatable_update;
76
iface->sync_action_properties = foo_bar_activatable_sync_action_properties;
79
... Break the reference using gtk_activatable_do_set_related_action()...
82
foo_bar_dispose (GObject *object)
84
FooBar *bar = FOO_BAR (object);
85
FooBarPrivate *priv = FOO_BAR_GET_PRIVATE (bar);
91
gtk_activatable_do_set_related_action (GTK_ACTIVATABLE (bar), NULL);
94
G_OBJECT_CLASS (foo_bar_parent_class)->dispose (object);
97
... Handle the "related-action" and "use-action-appearance" properties ...
100
foo_bar_set_property (GObject *object,
105
FooBar *bar = FOO_BAR (object);
106
FooBarPrivate *priv = FOO_BAR_GET_PRIVATE (bar);
113
case PROP_ACTIVATABLE_RELATED_ACTION:
114
foo_bar_set_related_action (bar, g_value_get_object (value));
116
case PROP_ACTIVATABLE_USE_ACTION_APPEARANCE:
117
foo_bar_set_use_action_appearance (bar, g_value_get_boolean (value));
120
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
126
foo_bar_get_property (GObject *object,
131
FooBar *bar = FOO_BAR (object);
132
FooBarPrivate *priv = FOO_BAR_GET_PRIVATE (bar);
139
case PROP_ACTIVATABLE_RELATED_ACTION:
140
g_value_set_object (value, priv->action);
142
case PROP_ACTIVATABLE_USE_ACTION_APPEARANCE:
143
g_value_set_boolean (value, priv->use_action_appearance);
146
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
153
foo_bar_set_use_action_appearance (FooBar *bar,
154
gboolean use_appearance)
156
FooBarPrivate *priv = FOO_BAR_GET_PRIVATE (bar);
158
if (priv->use_action_appearance != use_appearance)
160
priv->use_action_appearance = use_appearance;
162
gtk_activatable_sync_action_properties (GTK_ACTIVATABLE (bar), priv->action);
166
... call gtk_activatable_do_set_related_action() and then assign the action pointer,
167
no need to reference the action here since gtk_activatable_do_set_related_action() already
168
holds a reference here for you...
170
foo_bar_set_related_action (FooBar *bar,
173
FooBarPrivate *priv = FOO_BAR_GET_PRIVATE (bar);
175
if (priv->action == action)
178
gtk_activatable_do_set_related_action (GTK_ACTIVATABLE (bar), action);
180
priv->action = action;
183
... Selectively reset and update activatable depending on the use-action-appearance property ...
185
gtk_button_activatable_sync_action_properties (GtkActivatable *activatable,
188
GtkButtonPrivate *priv = GTK_BUTTON_GET_PRIVATE (activatable);
193
if (gtk_action_is_visible (action))
194
gtk_widget_show (GTK_WIDGET (activatable));
196
gtk_widget_hide (GTK_WIDGET (activatable));
198
gtk_widget_set_sensitive (GTK_WIDGET (activatable), gtk_action_is_sensitive (action));
202
if (priv->use_action_appearance)
204
if (gtk_action_get_stock_id (action))
205
foo_bar_set_stock (button, gtk_action_get_stock_id (action));
206
else if (gtk_action_get_label (action))
207
foo_bar_set_label (button, gtk_action_get_label (action));
215
foo_bar_activatable_update (GtkActivatable *activatable,
217
const gchar *property_name)
219
FooBarPrivate *priv = FOO_BAR_GET_PRIVATE (activatable);
221
if (strcmp (property_name, "visible") == 0)
223
if (gtk_action_is_visible (action))
224
gtk_widget_show (GTK_WIDGET (activatable));
226
gtk_widget_hide (GTK_WIDGET (activatable));
228
else if (strcmp (property_name, "sensitive") == 0)
229
gtk_widget_set_sensitive (GTK_WIDGET (activatable), gtk_action_is_sensitive (action));
233
if (!priv->use_action_appearance)
236
if (strcmp (property_name, "stock-id") == 0)
237
foo_bar_set_stock (button, gtk_action_get_stock_id (action));
238
else if (strcmp (property_name, "label") == 0)
239
foo_bar_set_label (button, gtk_action_get_label (action));
244
\section{Structures}{\describe{\item{\verb{GtkActivatable}}{
249
\section{Properties}{\describe{
250
\item{\verb{related-action} [\code{\link{GtkAction}} : * : Read / Write]}{
252
The action that this activatable will activate and receive
253
updates from for various states and possibly appearance.
254
\strong{PLEASE NOTE:} \code{\link{GtkActivatable}} implementors need to handle the this property and
255
call \code{\link{gtkActivatableDoSetRelatedAction}} when it changes. Since 2.16
258
\item{\verb{use-action-appearance} [logical : Read / Write]}{
260
Whether this activatable should reset its layout
261
and appearance when setting the related action or when
262
the action changes appearance.
264
See the \code{\link{GtkAction}} documentation directly to find which properties
265
should be ignored by the \code{\link{GtkActivatable}} when this property is \code{FALSE}.
266
\strong{PLEASE NOTE:} \code{\link{GtkActivatable}} implementors need to handle this property
267
and call \code{\link{gtkActivatableSyncActionProperties}} on the activatable
268
widget when it changes. Default value: TRUE Since 2.16
272
\references{\url{http://library.gnome.org/devel//gtk/GtkActivatable.html}}
273
\author{Derived by RGtkGen from GTK+ documentation}