a11y: Remove idle handler from menuitem action
This commit is contained in:
parent
3e49e2387c
commit
fdc40111f8
@ -49,7 +49,6 @@ static const gchar * gail_menu_item_get_name (AtkObject *obje
|
|||||||
static void atk_action_interface_init (AtkActionIface *iface);
|
static void atk_action_interface_init (AtkActionIface *iface);
|
||||||
static gboolean gail_menu_item_do_action (AtkAction *action,
|
static gboolean gail_menu_item_do_action (AtkAction *action,
|
||||||
gint i);
|
gint i);
|
||||||
static gboolean idle_do_action (gpointer data);
|
|
||||||
static gint gail_menu_item_get_n_actions (AtkAction *action);
|
static gint gail_menu_item_get_n_actions (AtkAction *action);
|
||||||
static const gchar* gail_menu_item_action_get_name (AtkAction *action,
|
static const gchar* gail_menu_item_action_get_name (AtkAction *action,
|
||||||
gint i);
|
gint i);
|
||||||
@ -444,40 +443,6 @@ atk_action_interface_init (AtkActionIface *iface)
|
|||||||
iface->get_keybinding = gail_menu_item_get_keybinding;
|
iface->get_keybinding = gail_menu_item_get_keybinding;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gail_menu_item_do_action (AtkAction *action,
|
|
||||||
gint i)
|
|
||||||
{
|
|
||||||
if (i == 0)
|
|
||||||
{
|
|
||||||
GtkWidget *item;
|
|
||||||
GailMenuItem *gail_menu_item;
|
|
||||||
|
|
||||||
item = gtk_accessible_get_widget (GTK_ACCESSIBLE (action));
|
|
||||||
if (item == NULL)
|
|
||||||
/* State is defunct */
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (!gtk_widget_get_sensitive (item) || !gtk_widget_get_visible (item))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
gail_menu_item = GAIL_MENU_ITEM (action);
|
|
||||||
if (gail_menu_item->action_idle_handler)
|
|
||||||
return FALSE;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gail_menu_item->action_idle_handler =
|
|
||||||
gdk_threads_add_idle_full (G_PRIORITY_DEFAULT_IDLE,
|
|
||||||
idle_do_action,
|
|
||||||
g_object_ref (gail_menu_item),
|
|
||||||
(GDestroyNotify) g_object_unref);
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ensure_menus_unposted (GailMenuItem *menu_item)
|
ensure_menus_unposted (GailMenuItem *menu_item)
|
||||||
{
|
{
|
||||||
@ -500,32 +465,40 @@ ensure_menus_unposted (GailMenuItem *menu_item)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
idle_do_action (gpointer data)
|
gail_menu_item_do_action (AtkAction *action,
|
||||||
|
gint i)
|
||||||
{
|
{
|
||||||
GtkWidget *item;
|
if (i == 0)
|
||||||
GtkWidget *item_parent;
|
{
|
||||||
GailMenuItem *menu_item;
|
GtkWidget *item, *item_parent;
|
||||||
gboolean item_mapped;
|
gboolean item_mapped;
|
||||||
|
|
||||||
menu_item = GAIL_MENU_ITEM (data);
|
item = gtk_accessible_get_widget (GTK_ACCESSIBLE (action));
|
||||||
menu_item->action_idle_handler = 0;
|
if (item == NULL)
|
||||||
item = gtk_accessible_get_widget (GTK_ACCESSIBLE (menu_item));
|
/* State is defunct */
|
||||||
if (item == NULL /* State is defunct */ ||
|
return FALSE;
|
||||||
!gtk_widget_get_sensitive (item) || !gtk_widget_get_visible (item))
|
|
||||||
|
if (!gtk_widget_get_sensitive (item) || !gtk_widget_get_visible (item))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
item_parent = gtk_widget_get_parent (item);
|
||||||
|
if (!GTK_IS_MENU_SHELL (item_parent))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
gtk_menu_shell_select_item (GTK_MENU_SHELL (item_parent), item);
|
||||||
|
item_mapped = gtk_widget_get_mapped (item);
|
||||||
|
/*
|
||||||
|
* This is what is called when <Return> is pressed for a menu item
|
||||||
|
*/
|
||||||
|
g_signal_emit_by_name (item_parent, "activate_current",
|
||||||
|
/*force_hide*/ 1);
|
||||||
|
if (!item_mapped)
|
||||||
|
ensure_menus_unposted (GAIL_MENU_ITEM (action));
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
item_parent = gtk_widget_get_parent (item);
|
|
||||||
gtk_menu_shell_select_item (GTK_MENU_SHELL (item_parent), item);
|
|
||||||
item_mapped = gtk_widget_get_mapped (item);
|
|
||||||
/*
|
|
||||||
* This is what is called when <Return> is pressed for a menu item
|
|
||||||
*/
|
|
||||||
g_signal_emit_by_name (item_parent, "activate_current",
|
|
||||||
/*force_hide*/ 1);
|
|
||||||
if (!item_mapped)
|
|
||||||
ensure_menus_unposted (menu_item);
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
@ -743,12 +716,6 @@ gail_menu_item_finalize (GObject *object)
|
|||||||
GailMenuItem *menu_item = GAIL_MENU_ITEM (object);
|
GailMenuItem *menu_item = GAIL_MENU_ITEM (object);
|
||||||
|
|
||||||
g_free (menu_item->click_keybinding);
|
g_free (menu_item->click_keybinding);
|
||||||
if (menu_item->action_idle_handler)
|
|
||||||
{
|
|
||||||
g_source_remove (menu_item->action_idle_handler);
|
|
||||||
menu_item->action_idle_handler = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (menu_item->textutil)
|
if (menu_item->textutil)
|
||||||
{
|
{
|
||||||
g_object_unref (menu_item->textutil);
|
g_object_unref (menu_item->textutil);
|
||||||
|
@ -44,7 +44,6 @@ struct _GailMenuItem
|
|||||||
gchar *text;
|
gchar *text;
|
||||||
|
|
||||||
gchar *click_keybinding;
|
gchar *click_keybinding;
|
||||||
guint action_idle_handler;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GType gail_menu_item_get_type (void);
|
GType gail_menu_item_get_type (void);
|
||||||
|
Loading…
Reference in New Issue
Block a user