Commit 36d81d40 authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen

Fix actiongroup-action interaction that relied on actions connecting to

2006-01-07  Matthias Clasen  <mclasen@redhat.com>

	Fix actiongroup-action interaction that relied on
	actions connecting to notify on themselves:

	* gtk/gtkaction.[hc]: Factor out the code updating the
	visibility/sensitivity of proxies into _gtk_action_sync_visible()
	and _gtk_action_sync_sensible().

	* gtk/gtkactiongroup.c: Call the new functions when the
	group visibility/sensitivity changes.
parent 91cde9ce
2006-01-07 Matthias Clasen <mclasen@redhat.com>
Fix actiongroup-action interaction that relied on
actions connecting to notify on themselves:
* gtk/gtkaction.[hc]: Factor out the code updating the
visibility/sensitivity of proxies into _gtk_action_sync_visible()
and _gtk_action_sync_sensible().
* gtk/gtkactiongroup.c: Call the new functions when the
group visibility/sensitivity changes.
2006-01-06 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkactiongroup.c (gtk_action_group_set_sensitive)
......
2006-01-07 Matthias Clasen <mclasen@redhat.com>
Fix actiongroup-action interaction that relied on
actions connecting to notify on themselves:
* gtk/gtkaction.[hc]: Factor out the code updating the
visibility/sensitivity of proxies into _gtk_action_sync_visible()
and _gtk_action_sync_sensible().
* gtk/gtkactiongroup.c: Call the new functions when the
group visibility/sensitivity changes.
2006-01-06 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkactiongroup.c (gtk_action_group_set_sensitive)
......
......@@ -603,7 +603,7 @@ _gtk_action_sync_menu_visible (GtkAction *action,
g_return_if_fail (GTK_IS_MENU_ITEM (proxy));
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);
......@@ -1057,6 +1057,22 @@ gtk_action_get_sensitive (GtkAction *action)
return action->private_data->sensitive;
}
void
_gtk_action_sync_sensitive (GtkAction *action)
{
GSList *p;
GtkWidget *proxy;
gboolean sensitive;
sensitive = gtk_action_is_sensitive (action);
for (p = action->private_data->proxies; p; p = p->next)
{
proxy = (GtkWidget *)p->data;
gtk_widget_set_sensitive (proxy, sensitive);
}
}
/**
* gtk_action_set_sensitive:
* @action: the action object
......@@ -1073,9 +1089,6 @@ void
gtk_action_set_sensitive (GtkAction *action,
gboolean sensitive)
{
GSList *p;
GtkWidget *proxy;
g_return_if_fail (GTK_IS_ACTION (action));
sensitive = sensitive != FALSE;
......@@ -1084,12 +1097,8 @@ gtk_action_set_sensitive (GtkAction *action,
{
action->private_data->sensitive = sensitive;
for (p = action->private_data->proxies; p; p = p->next)
{
proxy = (GtkWidget *)p->data;
gtk_widget_set_sensitive (proxy, sensitive);
}
_gtk_action_sync_sensitive (action);
g_object_notify (G_OBJECT (action), "sensitive");
}
}
......@@ -1137,6 +1146,36 @@ gtk_action_get_visible (GtkAction *action)
return action->private_data->visible;
}
void
_gtk_action_sync_visible (GtkAction *action)
{
GSList *p;
GtkWidget *proxy;
GtkWidget *menu;
gboolean visible;
visible = gtk_action_is_visible (action);
for (p = action->private_data->proxies; p; p = p->next)
{
proxy = (GtkWidget *)p->data;
if (GTK_IS_MENU_ITEM (proxy))
{
menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (proxy));
_gtk_action_sync_menu_visible (action, proxy, _gtk_menu_is_empty (menu));
}
else
{
if (visible)
gtk_widget_show (proxy);
else
gtk_widget_hide (proxy);
}
}
}
/**
* gtk_action_set_visible:
* @action: the action object
......@@ -1153,9 +1192,6 @@ void
gtk_action_set_visible (GtkAction *action,
gboolean visible)
{
GSList *p;
GtkWidget *proxy;
g_return_if_fail (GTK_IS_ACTION (action));
visible = visible != FALSE;
......@@ -1164,25 +1200,8 @@ gtk_action_set_visible (GtkAction *action,
{
action->private_data->visible = visible;
for (p = action->private_data->proxies; p; p = p->next)
{
proxy = (GtkWidget *)p->data;
_gtk_action_sync_visible (action);
if (GTK_IS_MENU_ITEM (proxy))
{
GtkWidget *menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (proxy));
_gtk_action_sync_menu_visible (action, proxy, _gtk_menu_is_empty (menu));
}
else
{
if (visible)
gtk_widget_show (proxy);
else
gtk_widget_hide (proxy);
}
}
g_object_notify (G_OBJECT (action), "visible");
}
}
......
......@@ -121,7 +121,11 @@ void gtk_action_set_accel_path (GtkAction *action,
const gchar *accel_path);
void gtk_action_set_accel_group (GtkAction *action,
GtkAccelGroup *accel_group);
void _gtk_action_sync_sensitive (GtkAction *action);
void _gtk_action_sync_visible (GtkAction *action);
void _gtk_action_sync_menu_visible (GtkAction *action,
GtkWidget *proxy,
gboolean empty);
G_END_DECLS
......
......@@ -420,10 +420,10 @@ static void
cb_set_action_sensitivity (const gchar *name,
GtkAction *action)
{
/* Minor optimization, the action_groups state only affects actions that are
* themselves sensitive */
/* Minor optimization, the action_groups state only affects actions
* that are themselves sensitive */
if (gtk_action_get_sensitive (action))
g_object_notify (G_OBJECT (action), "sensitive");
_gtk_action_sync_sensitive (action);
}
/**
......@@ -478,10 +478,10 @@ static void
cb_set_action_visiblity (const gchar *name,
GtkAction *action)
{
/* Minor optimization, the action_groups state only affects actions that are
* themselves sensitive */
/* Minor optimization, the action_groups state only affects actions
* that are themselves visible */
if (gtk_action_get_visible (action))
g_object_notify (G_OBJECT (action), "visible");
_gtk_action_sync_visible (action);
}
/**
......
......@@ -2008,10 +2008,6 @@ enum {
SEPARATOR_MODE_HIDDEN
};
void _gtk_action_sync_menu_visible (GtkAction *action,
GtkWidget *proxy,
gboolean empty);
static void
update_smart_separators (GtkWidget *proxy)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment