Commit bb72b647 authored by Matthias Clasen's avatar Matthias Clasen

i Bug 560228 – Add "action-controller" property to GtkWidgetClass

        Rework the way actions and proxies interact, to make the
        interaction less ad hoc, more extensible, and better suited
        for support in GUI builders like glade.

        To be used as a proxy, a widget must now implement the
        GtkActivatable interface, and GtkActivatable implementations
        are responsible for syncing their appearance with the action
        and for activating the action.

        All the widgets that are commonly used as proxies implement
        GtkActivatable now.

        Patch by Tristan van Berkom.

        * gtk/gtkactivatable.[hc]: The GtkActivatable interface.

        * gtk/gtkbutton.c:
        * gtk/gtktogglebutton.c:
        * gtk/gtktoolitem.c:
        * gtk/gtktoolbutton.c:
        * gtk/gtktoggletoolbutton.c:
        * gtk/gtkmenuitem.c:
        * gtk/gtkcheckmenuitem.c:
        * gtk/gtkimagemenuitem.c:
        * gtk/gtkradiomenuitem.c:
        * gtk/gtkrecentchooserprivate.h:
        * gtk/gtkrecentchooser.c:
        * gtk/gtkrecentchooserdefault.c:
        * gtk/gtkrecentchoosermenu.c: Implement GtkActivatable.
        * gtk/gtkaction.[hc]: Move appearance synchronization to
        GtkActivatable implementations.

        * gtk/gtkradioaction.c:
        * gtk/gtkrecentaction.c:
        * gtk/gtktoggleaction.c:
        * gtk/gtkactiongroup.c: Adapt.

        * gtk/gtk.h: Include gtkactivatable.h
        * gtk/gtk.symbols: Add new functions


svn path=/trunk/; revision=22195
parent acd40c45
2009-01-23 Matthias Clasen <mclasen@redhat.com>
Bug 560228 – Add "action-controller" property to GtkWidgetClass
Rework the way actions and proxies interact, to make the
interaction less ad hoc, more extensible, and better suited
for support in GUI builders like glade.
To be used as a proxy, a widget must now implement the
GtkActivatable interface, and GtkActivatable implementations
are responsible for syncing their appearance with the action
and for activating the action.
All the widgets that are commonly used as proxies implement
GtkActivatable now.
Patch by Tristan van Berkom.
* gtk/gtkactivatable.[hc]: The GtkActivatable interface.
* gtk/gtkbutton.c:
* gtk/gtktogglebutton.c:
* gtk/gtktoolitem.c:
* gtk/gtktoolbutton.c:
* gtk/gtktoggletoolbutton.c:
* gtk/gtkmenuitem.c:
* gtk/gtkcheckmenuitem.c:
* gtk/gtkimagemenuitem.c:
* gtk/gtkradiomenuitem.c:
* gtk/gtkrecentchooserprivate.h:
* gtk/gtkrecentchooser.c:
* gtk/gtkrecentchooserdefault.c:
* gtk/gtkrecentchoosermenu.c: Implement GtkActivatable.
* gtk/gtkaction.[hc]: Move appearance synchronization to
GtkActivatable implementations.
* gtk/gtkradioaction.c:
* gtk/gtkrecentaction.c:
* gtk/gtktoggleaction.c:
* gtk/gtkactiongroup.c: Adapt.
* gtk/gtk.h: Include gtkactivatable.h
* gtk/gtk.symbols: Add new functions
2009-01-23 Matthias Clasen <mclasen@redhat.com>
Bug 567124 – proposal to delay doing something related to
......
2009-01-23 Matthias Clasen <mclasen@redhat.com>
* gtk/gtk-sections.txt: Add new GtkActivatable API
* gtk/gtk-docs.sgml: Include GtkActivatable section
* gtk.types: Add gtk_activatable_get_type
2009-01-23 Matthias Clasen <mclasen@redhat.com>
* gtk/gtk-sections.txt: Additions
......
......@@ -247,6 +247,7 @@ that is, GUI components such as #GtkButton or #GtkTextView.
<xi:include href="xml/gtktoggleaction.xml" />
<xi:include href="xml/gtkradioaction.xml" />
<xi:include href="xml/gtkrecentaction.xml" />
<xi:include href="xml/gtkactivatable.xml" />
</chapter>
<chapter id="SelectorWidgets">
......
......@@ -188,6 +188,8 @@ gtk_action_disconnect_proxy
gtk_action_get_proxies
gtk_action_connect_accelerator
gtk_action_disconnect_accelerator
gtk_action_block_activate
gtk_action_unblock_activate
gtk_action_block_activate_from
gtk_action_unblock_activate_from
gtk_action_get_accel_path
......@@ -226,6 +228,19 @@ gtk_action_get_type
GtkActionPrivate
</SECTION>
<SECTION>
<FILE>gtkactivatable</FILE>
<TITLE>GtkActivatable</TITLE>
gtk_activatable_do_set_related_action
gtk_activatable_get_related_action
gtk_activatable_get_use_action_appearance
gtk_activatable_reset
gtk_activatable_set_related_action
gtk_activatable_set_use_action_appearance
<SUBSECTION Private>
gtk_activatable_get_type
</SECTION>
<SECTION>
<FILE>gtkactiongroup</FILE>
<TITLE>GtkActionGroup</TITLE>
......
......@@ -8,6 +8,7 @@ gtk_accel_map_get_type
gtk_accessible_get_type
gtk_action_get_type
gtk_action_group_get_type
gtk_activatable_get_type
gtk_adjustment_get_type
gtk_alignment_get_type
gtk_arrow_get_type
......
......@@ -148,6 +148,7 @@ gtk_public_h_sources = \
gtkaccessible.h \
gtkaction.h \
gtkactiongroup.h \
gtkactivatable.h \
gtkadjustment.h \
gtkalignment.h \
gtkarrow.h \
......@@ -397,6 +398,7 @@ gtk_base_c_sources = \
gtkaccessible.c \
gtkaction.c \
gtkactiongroup.c \
gtkactivatable.c \
gtkadjustment.c \
gtkalignment.c \
gtkarrow.c \
......
......@@ -37,6 +37,7 @@
#include <gtk/gtkaccessible.h>
#include <gtk/gtkaction.h>
#include <gtk/gtkactiongroup.h>
#include <gtk/gtkactivatable.h>
#include <gtk/gtkadjustment.h>
#include <gtk/gtkalignment.h>
#include <gtk/gtkarrow.h>
......
......@@ -144,49 +144,61 @@ gtk_accessible_get_type G_GNUC_CONST
#if IN_HEADER(__GTK_ACTION_H__)
#if IN_FILE(__GTK_ACTION_C__)
gtk_action_activate
gtk_action_block_activate
#ifndef GTK_DISABLE_DEPRECATED
gtk_action_block_activate_from
#endif
gtk_action_connect_accelerator
#ifndef GTK_DISABLE_DEPRECATED
gtk_action_connect_proxy
#endif
gtk_action_create_icon
gtk_action_create_menu_item
gtk_action_create_tool_item
gtk_action_create_menu
gtk_action_disconnect_accelerator
#ifndef GTK_DISABLE_DEPRECATED
gtk_action_disconnect_proxy
#endif
gtk_action_get_accel_closure
gtk_action_get_accel_path
gtk_action_get_gicon
gtk_action_get_label
gtk_action_get_name
gtk_action_get_proxies
#ifndef GTK_DISABLE_DEPRECATED
gtk_widget_get_action
#endif
gtk_action_get_icon_name
gtk_action_get_is_important
gtk_action_get_sensitive
gtk_action_get_short_label
gtk_action_get_stock_id
gtk_action_get_tooltip
gtk_action_get_type G_GNUC_CONST
gtk_action_get_visible
gtk_action_get_visible_horizontal
gtk_action_get_visible_vertical
gtk_action_is_sensitive
gtk_action_is_visible
gtk_action_new
gtk_action_set_accel_group
gtk_action_set_accel_path
gtk_action_set_sensitive
gtk_action_set_visible
gtk_action_unblock_activate_from
gtk_action_set_gicon
gtk_action_set_icon_name
gtk_action_set_is_important
gtk_action_set_label
gtk_action_get_label
gtk_action_set_sensitive
gtk_action_set_short_label
gtk_action_get_short_label
gtk_action_set_tooltip
gtk_action_get_tooltip
gtk_action_set_stock_id
gtk_action_get_stock_id
gtk_action_set_gicon
gtk_action_get_gicon
gtk_action_set_icon_name
gtk_action_get_icon_name
gtk_action_set_tooltip
gtk_action_set_visible
gtk_action_set_visible_horizontal
gtk_action_get_visible_horizontal
gtk_action_set_visible_vertical
gtk_action_get_visible_vertical
gtk_action_set_is_important
gtk_action_get_is_important
gtk_action_unblock_activate
#ifndef GTK_DISABLE_DEPRECATED
gtk_action_unblock_activate_from
#endif
#endif
#endif
......@@ -216,6 +228,18 @@ gtk_action_group_translate_string
#endif
#endif
#if IN_HEADER(__GTK_ACTIVATABLE_H__)
#if IN_FILE(__GTK_ACTIVATABLE_C__)
gtk_activatable_do_set_related_action
gtk_activatable_get_related_action
gtk_activatable_get_type G_GNUC_CONST
gtk_activatable_get_use_action_appearance
gtk_activatable_reset
gtk_activatable_set_related_action
gtk_activatable_set_use_action_appearance
#endif
#endif
#if IN_HEADER(__GTK_ADJUSTMENT_H__)
#if IN_FILE(__GTK_ADJUSTMENT_C__)
gtk_adjustment_changed
......
......@@ -47,6 +47,7 @@
#include "gtktoolbar.h"
#include "gtkprivate.h"
#include "gtkbuildable.h"
#include "gtkactivatable.h"
#include "gtkalias.h"
......@@ -71,6 +72,8 @@ struct _GtkActionPrivate
guint is_important : 1;
guint hide_if_empty : 1;
guint visible_overflown : 1;
guint recursion_guard : 1;
guint activate_blocked : 1;
/* accelerator */
guint accel_count;
......@@ -120,10 +123,6 @@ G_DEFINE_TYPE_WITH_CODE (GtkAction, gtk_action, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
gtk_action_buildable_init))
static GQuark quark_gtk_action_proxy = 0;
static const gchar gtk_action_proxy_key[] = "gtk-action";
static void gtk_action_finalize (GObject *object);
static void gtk_action_set_property (GObject *object,
guint prop_id,
......@@ -135,8 +134,6 @@ static void gtk_action_get_property (GObject *object,
GParamSpec *pspec);
static void gtk_action_set_action_group (GtkAction *action,
GtkActionGroup *action_group);
static void gtk_action_sync_tooltip (GtkAction *action,
GtkWidget *proxy);
static GtkWidget *create_menu_item (GtkAction *action);
static GtkWidget *create_tool_item (GtkAction *action);
......@@ -144,7 +141,7 @@ static void connect_proxy (GtkAction *action,
GtkWidget *proxy);
static void disconnect_proxy (GtkAction *action,
GtkWidget *proxy);
static void closure_accel_activate (GClosure *closure,
GValue *return_value,
guint n_param_values,
......@@ -160,8 +157,6 @@ gtk_action_class_init (GtkActionClass *klass)
{
GObjectClass *gobject_class;
quark_gtk_action_proxy = g_quark_from_static_string (gtk_action_proxy_key);
gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = gtk_action_finalize;
......@@ -170,14 +165,13 @@ gtk_action_class_init (GtkActionClass *klass)
klass->activate = NULL;
klass->create_menu_item = create_menu_item;
klass->create_tool_item = create_tool_item;
klass->create_menu = NULL;
klass->connect_proxy = connect_proxy;
klass->disconnect_proxy = disconnect_proxy;
klass->menu_item_type = GTK_TYPE_IMAGE_MENU_ITEM;
klass->create_menu_item = create_menu_item;
klass->create_tool_item = create_tool_item;
klass->create_menu = NULL;
klass->menu_item_type = GTK_TYPE_IMAGE_MENU_ITEM;
klass->toolbar_item_type = GTK_TYPE_TOOL_BUTTON;
klass->connect_proxy = connect_proxy;
klass->disconnect_proxy = disconnect_proxy;
g_object_class_install_property (gobject_class,
PROP_NAME,
......@@ -194,6 +188,9 @@ gtk_action_class_init (GtkActionClass *klass)
* The label used for menu items and buttons that activate
* this action. If the label is %NULL, GTK+ uses the stock
* label specified via the stock-id property.
*
* This is an appearance property and thus only applies if
* #GtkActivatable:use-action-appearance is %TRUE.
*/
g_object_class_install_property (gobject_class,
PROP_LABEL,
......@@ -208,6 +205,9 @@ gtk_action_class_init (GtkActionClass *klass)
* GtkAction:short-label:
*
* A shorter label that may be used on toolbar buttons.
*
* This is an appearance property and thus only applies if
* #GtkActivatable:use-action-appearance is %TRUE.
*/
g_object_class_install_property (gobject_class,
PROP_SHORT_LABEL,
......@@ -230,6 +230,9 @@ gtk_action_class_init (GtkActionClass *klass)
* GtkAction:stock-id:
*
* The stock icon displayed in widgets representing this action.
*
* This is an appearance property and thus only applies if
* #GtkActivatable:use-action-appearance is %TRUE.
*/
g_object_class_install_property (gobject_class,
PROP_STOCK_ID,
......@@ -247,6 +250,9 @@ gtk_action_class_init (GtkActionClass *klass)
* Note that the stock icon is preferred, if the #GtkAction:stock-id
* property holds the id of an existing stock icon.
*
* This is an appearance property and thus only applies if
* #GtkActivatable:use-action-appearance is %TRUE.
*
* Since: 2.16
*/
g_object_class_install_property (gobject_class,
......@@ -265,6 +271,9 @@ gtk_action_class_init (GtkActionClass *klass)
* property holds the id of an existing stock icon, and the #GIcon is
* preferred if the #GtkAction:gicon property is set.
*
* This is an appearance property and thus only applies if
* #GtkActivatable:use-action-appearance is %TRUE.
*
* Since: 2.10
*/
g_object_class_install_property (gobject_class,
......@@ -381,6 +390,7 @@ gtk_action_init (GtkAction *action)
action->private_data->visible_overflown = TRUE;
action->private_data->is_important = FALSE;
action->private_data->hide_if_empty = TRUE;
action->private_data->activate_blocked = FALSE;
action->private_data->sensitive = TRUE;
action->private_data->visible = TRUE;
......@@ -634,12 +644,30 @@ static void
remove_proxy (GtkAction *action,
GtkWidget *proxy)
{
if (GTK_IS_MENU_ITEM (proxy))
gtk_action_disconnect_accelerator (action);
action->private_data->proxies = g_slist_remove (action->private_data->proxies, proxy);
}
static void
connect_proxy (GtkAction *action,
GtkWidget *proxy)
{
action->private_data->proxies = g_slist_prepend (action->private_data->proxies, proxy);
if (action->private_data->action_group)
_gtk_action_group_emit_connect_proxy (action->private_data->action_group, action, proxy);
}
static void
disconnect_proxy (GtkAction *action,
GtkWidget *proxy)
{
remove_proxy (action, proxy);
if (action->private_data->action_group)
_gtk_action_group_emit_disconnect_proxy (action->private_data->action_group, action, proxy);
}
/**
* _gtk_action_sync_menu_visible:
* @action: a #GtkAction, or %NULL to determine the action from @proxy
......@@ -670,7 +698,7 @@ _gtk_action_sync_menu_visible (GtkAction *action,
g_return_if_fail (action == NULL || GTK_IS_ACTION (action));
if (action == NULL)
action = g_object_get_qdata (G_OBJECT (proxy), quark_gtk_action_proxy);
action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (proxy));
if (action)
{
......@@ -685,257 +713,6 @@ _gtk_action_sync_menu_visible (GtkAction *action,
gtk_widget_hide (proxy);
}
gboolean _gtk_menu_is_empty (GtkWidget *menu);
static gboolean
gtk_action_create_menu_proxy (GtkToolItem *tool_item,
GtkAction *action)
{
GtkWidget *menu_item;
if (action->private_data->visible_overflown)
{
menu_item = gtk_action_create_menu_item (action);
g_object_ref_sink (menu_item);
gtk_tool_item_set_proxy_menu_item (tool_item,
"gtk-action-menu-item", menu_item);
g_object_unref (menu_item);
}
else
gtk_tool_item_set_proxy_menu_item (tool_item,
"gtk-action-menu-item", NULL);
return TRUE;
}
static void
connect_proxy (GtkAction *action,
GtkWidget *proxy)
{
g_object_ref (action);
g_object_set_qdata_full (G_OBJECT (proxy), quark_gtk_action_proxy, action,
g_object_unref);
/* add this widget to the list of proxies */
action->private_data->proxies = g_slist_prepend (action->private_data->proxies, proxy);
g_object_weak_ref (G_OBJECT (proxy), (GWeakNotify)remove_proxy, action);
gtk_widget_set_sensitive (proxy, gtk_action_is_sensitive (action));
if (gtk_action_is_visible (action))
gtk_widget_show (proxy);
else
gtk_widget_hide (proxy);
gtk_widget_set_no_show_all (proxy, TRUE);
if (GTK_IS_MENU_ITEM (proxy))
{
GtkWidget *label;
/* menu item specific synchronisers ... */
if (action->private_data->accel_quark)
{
gtk_action_connect_accelerator (action);
gtk_menu_item_set_accel_path (GTK_MENU_ITEM (proxy),
g_quark_to_string (action->private_data->accel_quark));
}
label = GTK_BIN (proxy)->child;
/* make sure label is a label */
if (label && !GTK_IS_LABEL (label))
{
gtk_container_remove (GTK_CONTAINER (proxy), label);
label = NULL;
}
if (!label)
label = g_object_new (GTK_TYPE_ACCEL_LABEL,
"use-underline", TRUE,
"xalign", 0.0,
"visible", TRUE,
"parent", proxy,
NULL);
if (GTK_IS_ACCEL_LABEL (label) && action->private_data->accel_quark)
g_object_set (label,
"accel-closure", action->private_data->accel_closure,
NULL);
gtk_label_set_label (GTK_LABEL (label), action->private_data->label);
if (GTK_IS_IMAGE_MENU_ITEM (proxy))
{
GtkWidget *image;
image = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (proxy));
if (image && !GTK_IS_IMAGE (image))
{
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy), NULL);
image = NULL;
}
if (!image)
{
image = gtk_image_new ();
gtk_widget_show (image);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy),
image);
}
if (action->private_data->stock_id &&
gtk_icon_factory_lookup_default (action->private_data->stock_id))
gtk_image_set_from_stock (GTK_IMAGE (image),
action->private_data->stock_id, GTK_ICON_SIZE_MENU);
else if (action->private_data->gicon)
gtk_image_set_from_gicon (GTK_IMAGE (image),
action->private_data->gicon, GTK_ICON_SIZE_MENU);
else if (action->private_data->icon_name)
gtk_image_set_from_icon_name (GTK_IMAGE (image),
action->private_data->icon_name, GTK_ICON_SIZE_MENU);
else
gtk_image_clear (GTK_IMAGE (image));
}
if (gtk_menu_item_get_submenu (GTK_MENU_ITEM (proxy)) == NULL)
g_signal_connect_object (proxy, "activate",
G_CALLBACK (gtk_action_activate), action,
G_CONNECT_SWAPPED);
}
else if (GTK_IS_TOOL_ITEM (proxy))
{
/* toolbar button specific synchronisers ... */
if (GTK_IS_TOOL_BUTTON (proxy))
{
GtkWidget *image;
GtkIconSize icon_size;
g_object_set (proxy,
"visible-horizontal", action->private_data->visible_horizontal,
"visible-vertical", action->private_data->visible_vertical,
"is-important", action->private_data->is_important,
"label", action->private_data->short_label,
"use-underline", TRUE,
"stock-id", action->private_data->stock_id,
"icon-name", action->private_data->icon_name,
NULL);
if (action->private_data->stock_id &&
gtk_icon_factory_lookup_default (action->private_data->stock_id))
{
/* use the stock icon */
gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (proxy), NULL);
}
else if (action->private_data->gicon)
{
icon_size = gtk_tool_item_get_icon_size (GTK_TOOL_ITEM (proxy));
image = gtk_tool_button_get_icon_widget (GTK_TOOL_BUTTON (proxy));
if (!image)
{
image = gtk_image_new ();
gtk_widget_show (image);
gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (proxy),
image);
}
gtk_image_set_from_gicon (GTK_IMAGE (image),
action->private_data->gicon,
icon_size);
}
g_signal_connect_object (proxy, "clicked",
G_CALLBACK (gtk_action_activate), action,
G_CONNECT_SWAPPED);
}
else
{
g_object_set (proxy,
"visible-horizontal", action->private_data->visible_horizontal,
"visible-vertical", action->private_data->visible_vertical,
"is-important", action->private_data->is_important,
NULL);
}
gtk_action_sync_tooltip (action, proxy);
g_signal_connect_object (proxy, "create-menu-proxy",
G_CALLBACK (gtk_action_create_menu_proxy),
action, 0);
gtk_tool_item_rebuild_menu (GTK_TOOL_ITEM (proxy));
}
else if (GTK_IS_BUTTON (proxy))
{
/* button specific synchronisers ... */
if (gtk_button_get_use_stock (GTK_BUTTON (proxy)))
{
/* synchronise stock-id */
g_object_set (proxy,
"label", action->private_data->stock_id,
NULL);
}
else
{
GtkWidget *image;
image = gtk_button_get_image (GTK_BUTTON (proxy));
if (GTK_IS_IMAGE (image) ||
GTK_BIN (proxy)->child == NULL ||
GTK_IS_LABEL (GTK_BIN (proxy)->child))
{
/* synchronise the label */
g_object_set (proxy,
"label", action->private_data->short_label,
"use-underline", TRUE,
NULL);
}
if (GTK_IS_IMAGE (image) &&
(gtk_image_get_storage_type (GTK_IMAGE (image)) == GTK_IMAGE_EMPTY ||
gtk_image_get_storage_type (GTK_IMAGE (image)) == GTK_IMAGE_GICON))
gtk_image_set_from_gicon (GTK_IMAGE (image),
action->private_data->gicon, GTK_ICON_SIZE_MENU);
else if (GTK_IS_IMAGE (image) &&
(gtk_image_get_storage_type (GTK_IMAGE (image)) == GTK_IMAGE_EMPTY ||
gtk_image_get_storage_type (GTK_IMAGE (image)) == GTK_IMAGE_ICON_NAME))
gtk_image_set_from_icon_name (GTK_IMAGE (image),
action->private_data->icon_name, GTK_ICON_SIZE_MENU);
}
/* we leave the button alone if there is a custom child */
g_signal_connect_object (proxy, "clicked",
G_CALLBACK (gtk_action_activate), action,
G_CONNECT_SWAPPED);
}
if (action->private_data->action_group)
_gtk_action_group_emit_connect_proxy (action->private_data->action_group, action, proxy);
}
static void
disconnect_proxy (GtkAction *action,
GtkWidget *proxy)
{
g_object_set_qdata (G_OBJECT (proxy), quark_gtk_action_proxy, NULL);
g_object_weak_unref (G_OBJECT (proxy), (GWeakNotify)remove_proxy, action);
remove_proxy (action, proxy);
/* disconnect the activate handler */
g_signal_handlers_disconnect_by_func (proxy,
G_CALLBACK (gtk_action_activate),
action);
/* toolbar button specific synchronisers ... */
g_signal_handlers_disconnect_by_func (proxy,
G_CALLBACK (gtk_action_create_menu_proxy),
action);
if (action->private_data->action_group)
_gtk_action_group_emit_disconnect_proxy (action->private_data->action_group, action, proxy);
}
void
_gtk_action_emit_activate (GtkAction *action)
{
......@@ -973,10 +750,42 @@ gtk_action_activate (GtkAction *action)
{
g_return_if_fail (GTK_IS_ACTION (action));
if (gtk_action_is_sensitive (action))
if (action->private_data->activate_blocked == FALSE &&
gtk_action_is_sensitive (action))
_gtk_action_emit_activate (action);
}
/**
* gtk_action_block_activate:
*
* Disable activation signals from the action
*
* This is needed when updating the state of your proxy
* #GtkActivatable widget could result in calling gtk_action_activate(),
* this is a convenience function to avoid recursing in those
* cases (updating toggle state for instance).
*/
void
gtk_action_block_activate (GtkAction *action)
{
g_return_if_fail (GTK_IS_ACTION (action));
action->private_data->activate_blocked = TRUE;
}
/**
* gtk_action_unblock_activate:
*
* Reenable activation signals from the action
*/
void
gtk_action_unblock_activate (GtkAction *action)
{
g_return_if_fail (GTK_IS_ACTION (action));
action->private_data->activate_blocked = FALSE;
}
/**
* gtk_action_create_icon:
* @action: the action object
......@@ -1024,7 +833,8 @@ gtk_action_create_menu_item (GtkAction *action)
menu_item = GTK_ACTION_GET_CLASS (action)->create_menu_item (action);
GTK_ACTION_GET_CLASS (action)->connect_proxy (action, menu_item);
gtk_activatable_set_use_action_appearance (GTK_ACTIVATABLE (menu_item), TRUE);
gtk_activatable_set_related_action (GTK_ACTIVATABLE (menu_item), action);
return menu_item;
}
......@@ -1048,11 +858,32 @@ gtk_action_create_tool_item (GtkAction *action)
button = GTK_ACTION_GET_CLASS (action)->create_tool_item (action);
GTK_ACTION_GET_CLASS (action)->connect_proxy (action, button);
gtk_activatable_set_use_action_appearance (GTK_ACTIVATABLE (button), TRUE);
gtk_activatable_set_related_action (GTK_ACTIVATABLE (button), action);
return button;
}
void
_gtk_action_add_to_proxy_list (GtkAction *action,
GtkWidget *proxy)
{
g_return_if_fail (GTK_IS_ACTION (action));
g_return_if_fail (GTK_IS_WIDGET (proxy));
GTK_ACTION_GET_CLASS (action)->connect_proxy (action, proxy);
}
void
_gtk_action_remove_from_proxy_list (GtkAction *action,
GtkWidget *proxy)
{
g_return_if_fail (GTK_IS_ACTION (action));
g_return_if_fail (GTK_IS_WIDGET (proxy));
GTK_ACTION_GET_CLASS (action)->disconnect_proxy (action, proxy);
}
/**
* gtk_action_connect_proxy:
* @action: the action object
......@@ -1067,22 +898,20 @@ gtk_action_create_tool_item (GtkAction *action)
* first.
*
* Since: 2.4
*
* Deprecated 2.16: Use gtk_activatable_set_related_action() instead.
*/
void
gtk_action_connect_proxy (GtkAction *action,
GtkWidget *proxy)
{
GtkAction *prev_action;
g_return_if_fail (GTK_IS_ACTION (action));
g_return_if_fail (GTK_IS_WIDGET (proxy));
g_return_if_fail (GTK_IS_ACTIVATABLE (proxy));