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> 2006-01-06 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkactiongroup.c (gtk_action_group_set_sensitive) * 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> 2006-01-06 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkactiongroup.c (gtk_action_group_set_sensitive) * gtk/gtkactiongroup.c (gtk_action_group_set_sensitive)
......
...@@ -1057,6 +1057,22 @@ gtk_action_get_sensitive (GtkAction *action) ...@@ -1057,6 +1057,22 @@ gtk_action_get_sensitive (GtkAction *action)
return action->private_data->sensitive; 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: * gtk_action_set_sensitive:
* @action: the action object * @action: the action object
...@@ -1073,9 +1089,6 @@ void ...@@ -1073,9 +1089,6 @@ void
gtk_action_set_sensitive (GtkAction *action, gtk_action_set_sensitive (GtkAction *action,
gboolean sensitive) gboolean sensitive)
{ {
GSList *p;
GtkWidget *proxy;
g_return_if_fail (GTK_IS_ACTION (action)); g_return_if_fail (GTK_IS_ACTION (action));
sensitive = sensitive != FALSE; sensitive = sensitive != FALSE;
...@@ -1084,11 +1097,7 @@ gtk_action_set_sensitive (GtkAction *action, ...@@ -1084,11 +1097,7 @@ gtk_action_set_sensitive (GtkAction *action,
{ {
action->private_data->sensitive = sensitive; action->private_data->sensitive = sensitive;
for (p = action->private_data->proxies; p; p = p->next) _gtk_action_sync_sensitive (action);
{
proxy = (GtkWidget *)p->data;
gtk_widget_set_sensitive (proxy, sensitive);
}
g_object_notify (G_OBJECT (action), "sensitive"); g_object_notify (G_OBJECT (action), "sensitive");
} }
...@@ -1137,6 +1146,36 @@ gtk_action_get_visible (GtkAction *action) ...@@ -1137,6 +1146,36 @@ gtk_action_get_visible (GtkAction *action)
return action->private_data->visible; 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: * gtk_action_set_visible:
* @action: the action object * @action: the action object
...@@ -1153,9 +1192,6 @@ void ...@@ -1153,9 +1192,6 @@ void
gtk_action_set_visible (GtkAction *action, gtk_action_set_visible (GtkAction *action,
gboolean visible) gboolean visible)
{ {
GSList *p;
GtkWidget *proxy;
g_return_if_fail (GTK_IS_ACTION (action)); g_return_if_fail (GTK_IS_ACTION (action));
visible = visible != FALSE; visible = visible != FALSE;
...@@ -1164,24 +1200,7 @@ gtk_action_set_visible (GtkAction *action, ...@@ -1164,24 +1200,7 @@ gtk_action_set_visible (GtkAction *action,
{ {
action->private_data->visible = visible; action->private_data->visible = visible;
for (p = action->private_data->proxies; p; p = p->next) _gtk_action_sync_visible (action);
{
proxy = (GtkWidget *)p->data;
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"); g_object_notify (G_OBJECT (action), "visible");
} }
......
...@@ -121,7 +121,11 @@ void gtk_action_set_accel_path (GtkAction *action, ...@@ -121,7 +121,11 @@ void gtk_action_set_accel_path (GtkAction *action,
const gchar *accel_path); const gchar *accel_path);
void gtk_action_set_accel_group (GtkAction *action, void gtk_action_set_accel_group (GtkAction *action,
GtkAccelGroup *accel_group); 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 G_END_DECLS
......
...@@ -420,10 +420,10 @@ static void ...@@ -420,10 +420,10 @@ static void
cb_set_action_sensitivity (const gchar *name, cb_set_action_sensitivity (const gchar *name,
GtkAction *action) GtkAction *action)
{ {
/* Minor optimization, the action_groups state only affects actions that are /* Minor optimization, the action_groups state only affects actions
* themselves sensitive */ * that are themselves sensitive */
if (gtk_action_get_sensitive (action)) if (gtk_action_get_sensitive (action))
g_object_notify (G_OBJECT (action), "sensitive"); _gtk_action_sync_sensitive (action);
} }
/** /**
...@@ -478,10 +478,10 @@ static void ...@@ -478,10 +478,10 @@ static void
cb_set_action_visiblity (const gchar *name, cb_set_action_visiblity (const gchar *name,
GtkAction *action) GtkAction *action)
{ {
/* Minor optimization, the action_groups state only affects actions that are /* Minor optimization, the action_groups state only affects actions
* themselves sensitive */ * that are themselves visible */
if (gtk_action_get_visible (action)) if (gtk_action_get_visible (action))
g_object_notify (G_OBJECT (action), "visible"); _gtk_action_sync_visible (action);
} }
/** /**
......
...@@ -2008,10 +2008,6 @@ enum { ...@@ -2008,10 +2008,6 @@ enum {
SEPARATOR_MODE_HIDDEN SEPARATOR_MODE_HIDDEN
}; };
void _gtk_action_sync_menu_visible (GtkAction *action,
GtkWidget *proxy,
gboolean empty);
static void static void
update_smart_separators (GtkWidget *proxy) 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