mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-17 06:10:15 +00:00
iconview: Simplify adjustment monitoring for accessible
This commit is contained in:
parent
4652d4c399
commit
1961be9ee9
@ -27,6 +27,7 @@
|
||||
#include "gtk/gtkcellrendererpixbuf.h"
|
||||
#include "gtk/gtkcellrenderertext.h"
|
||||
#include "gtk/gtkpango.h"
|
||||
#include "gtk/gtkwidgetprivate.h"
|
||||
|
||||
#define GTK_TYPE_ICON_VIEW_ITEM_ACCESSIBLE (_gtk_icon_view_item_accessible_get_type ())
|
||||
#define GTK_ICON_VIEW_ITEM_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ICON_VIEW_ITEM_ACCESSIBLE, GtkIconViewItemAccessible))
|
||||
@ -875,8 +876,6 @@ gtk_icon_view_item_accessible_info_new (AtkObject *accessible,
|
||||
items = items->next;
|
||||
}
|
||||
view->items = g_list_insert_before (view->items, items, info);
|
||||
view->old_hadj = NULL;
|
||||
view->old_vadj = NULL;
|
||||
}
|
||||
|
||||
static gint
|
||||
@ -996,52 +995,16 @@ gtk_icon_view_accessible_traverse_items (GtkIconViewAccessible *view,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_icon_view_accessible_adjustment_changed (GtkAdjustment *adjustment,
|
||||
GtkIconViewAccessible *view)
|
||||
{
|
||||
gtk_icon_view_accessible_traverse_items (view, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_icon_view_accessible_set_adjustment (AtkObject *accessible,
|
||||
GtkOrientation orientation,
|
||||
GtkAdjustment *adjustment)
|
||||
_gtk_icon_view_accessible_adjustment_changed (GtkIconView *icon_view)
|
||||
{
|
||||
GtkIconViewAccessible *view = (GtkIconViewAccessible*)accessible;
|
||||
GtkAdjustment **old_adj_ptr;
|
||||
GtkIconViewAccessible *view;
|
||||
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
{
|
||||
if (view->old_hadj == adjustment)
|
||||
return;
|
||||
view = GTK_ICON_VIEW_ACCESSIBLE (_gtk_widget_peek_accessible (GTK_WIDGET (icon_view)));
|
||||
if (view == NULL)
|
||||
return;
|
||||
|
||||
old_adj_ptr = &view->old_hadj;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (view->old_vadj == adjustment)
|
||||
return;
|
||||
|
||||
old_adj_ptr = &view->old_vadj;
|
||||
}
|
||||
|
||||
/* Disconnect signal handlers */
|
||||
if (*old_adj_ptr)
|
||||
{
|
||||
g_object_remove_weak_pointer (G_OBJECT (*old_adj_ptr),
|
||||
(gpointer *)old_adj_ptr);
|
||||
g_signal_handlers_disconnect_by_func (*old_adj_ptr,
|
||||
gtk_icon_view_accessible_adjustment_changed,
|
||||
accessible);
|
||||
}
|
||||
|
||||
/* Connect signal */
|
||||
*old_adj_ptr = adjustment;
|
||||
g_object_add_weak_pointer (G_OBJECT (adjustment), (gpointer *)old_adj_ptr);
|
||||
g_signal_connect (adjustment, "value-changed",
|
||||
G_CALLBACK (gtk_icon_view_accessible_adjustment_changed),
|
||||
accessible);
|
||||
gtk_icon_view_accessible_traverse_items (view, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1327,14 +1290,6 @@ gtk_icon_view_accessible_initialize (AtkObject *accessible,
|
||||
icon_view = (GtkIconView*)data;
|
||||
view = (GtkIconViewAccessible*)accessible;
|
||||
|
||||
if (icon_view->priv->hadjustment)
|
||||
_gtk_icon_view_accessible_set_adjustment (accessible,
|
||||
GTK_ORIENTATION_HORIZONTAL,
|
||||
icon_view->priv->hadjustment);
|
||||
if (icon_view->priv->vadjustment)
|
||||
_gtk_icon_view_accessible_set_adjustment (accessible,
|
||||
GTK_ORIENTATION_VERTICAL,
|
||||
icon_view->priv->vadjustment);
|
||||
g_signal_connect (data, "notify",
|
||||
G_CALLBACK (gtk_icon_view_accessible_notify_gtk), NULL);
|
||||
|
||||
@ -1358,60 +1313,13 @@ gtk_icon_view_accessible_finalize (GObject *object)
|
||||
G_OBJECT_CLASS (_gtk_icon_view_accessible_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_icon_view_accessible_destroyed (GtkWidget *widget,
|
||||
GtkAccessible *accessible)
|
||||
{
|
||||
AtkObject *atk_obj;
|
||||
GtkIconViewAccessible *view;
|
||||
|
||||
atk_obj = ATK_OBJECT (accessible);
|
||||
view = (GtkIconViewAccessible*)atk_obj;
|
||||
if (view->old_hadj)
|
||||
{
|
||||
g_object_remove_weak_pointer (G_OBJECT (view->old_hadj),
|
||||
(gpointer *)&view->old_hadj);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (view->old_hadj,
|
||||
(gpointer) gtk_icon_view_accessible_adjustment_changed,
|
||||
accessible);
|
||||
view->old_hadj = NULL;
|
||||
}
|
||||
if (view->old_vadj)
|
||||
{
|
||||
g_object_remove_weak_pointer (G_OBJECT (view->old_vadj),
|
||||
(gpointer *)&view->old_vadj);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (view->old_vadj,
|
||||
(gpointer) gtk_icon_view_accessible_adjustment_changed,
|
||||
accessible);
|
||||
view->old_vadj = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_icon_view_accessible_connect_widget_destroyed (GtkAccessible *accessible)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
|
||||
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
|
||||
if (widget)
|
||||
{
|
||||
g_signal_connect_after (widget, "destroy",
|
||||
G_CALLBACK (gtk_icon_view_accessible_destroyed), accessible);
|
||||
}
|
||||
GTK_ACCESSIBLE_CLASS (_gtk_icon_view_accessible_parent_class)->connect_widget_destroyed (accessible);
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_icon_view_accessible_class_init (GtkIconViewAccessibleClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GtkAccessibleClass *accessible_class;
|
||||
AtkObjectClass *atk_class;
|
||||
|
||||
gobject_class = (GObjectClass *)klass;
|
||||
accessible_class = (GtkAccessibleClass *)klass;
|
||||
atk_class = (AtkObjectClass *)klass;
|
||||
|
||||
gobject_class->finalize = gtk_icon_view_accessible_finalize;
|
||||
@ -1419,8 +1327,6 @@ _gtk_icon_view_accessible_class_init (GtkIconViewAccessibleClass *klass)
|
||||
atk_class->get_n_children = gtk_icon_view_accessible_get_n_children;
|
||||
atk_class->ref_child = gtk_icon_view_accessible_ref_child;
|
||||
atk_class->initialize = gtk_icon_view_accessible_initialize;
|
||||
|
||||
accessible_class->connect_widget_destroyed = gtk_icon_view_accessible_connect_widget_destroyed;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -40,8 +40,6 @@ struct _GtkIconViewAccessible
|
||||
GtkContainerAccessible parent;
|
||||
|
||||
GList *items;
|
||||
GtkAdjustment *old_hadj;
|
||||
GtkAdjustment *old_vadj;
|
||||
GtkTreeModel *model;
|
||||
};
|
||||
|
||||
@ -52,9 +50,7 @@ struct _GtkIconViewAccessibleClass
|
||||
|
||||
GType _gtk_icon_view_accessible_get_type (void);
|
||||
|
||||
void _gtk_icon_view_accessible_set_adjustment (AtkObject *accessible,
|
||||
GtkOrientation orientation,
|
||||
GtkAdjustment *adjustment);
|
||||
void _gtk_icon_view_accessible_adjustment_changed (GtkIconView *icon_view);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -2446,7 +2446,6 @@ gtk_icon_view_set_hadjustment (GtkIconView *icon_view,
|
||||
GtkAdjustment *adjustment)
|
||||
{
|
||||
GtkIconViewPrivate *priv = icon_view->priv;
|
||||
AtkObject *atk_obj;
|
||||
|
||||
if (adjustment && priv->hadjustment == adjustment)
|
||||
return;
|
||||
@ -2468,11 +2467,6 @@ gtk_icon_view_set_hadjustment (GtkIconView *icon_view,
|
||||
priv->hadjustment = g_object_ref_sink (adjustment);
|
||||
gtk_icon_view_set_hadjustment_values (icon_view);
|
||||
|
||||
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (icon_view));
|
||||
_gtk_icon_view_accessible_set_adjustment (atk_obj,
|
||||
GTK_ORIENTATION_HORIZONTAL,
|
||||
adjustment);
|
||||
|
||||
g_object_notify (G_OBJECT (icon_view), "hadjustment");
|
||||
}
|
||||
|
||||
@ -2481,7 +2475,6 @@ gtk_icon_view_set_vadjustment (GtkIconView *icon_view,
|
||||
GtkAdjustment *adjustment)
|
||||
{
|
||||
GtkIconViewPrivate *priv = icon_view->priv;
|
||||
AtkObject *atk_obj;
|
||||
|
||||
if (adjustment && priv->vadjustment == adjustment)
|
||||
return;
|
||||
@ -2503,11 +2496,6 @@ gtk_icon_view_set_vadjustment (GtkIconView *icon_view,
|
||||
priv->vadjustment = g_object_ref_sink (adjustment);
|
||||
gtk_icon_view_set_vadjustment_values (icon_view);
|
||||
|
||||
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (icon_view));
|
||||
_gtk_icon_view_accessible_set_adjustment (atk_obj,
|
||||
GTK_ORIENTATION_VERTICAL,
|
||||
adjustment);
|
||||
|
||||
g_object_notify (G_OBJECT (icon_view), "vadjustment");
|
||||
}
|
||||
|
||||
@ -2525,6 +2513,8 @@ gtk_icon_view_adjustment_changed (GtkAdjustment *adjustment,
|
||||
|
||||
if (icon_view->priv->doing_rubberband)
|
||||
gtk_icon_view_update_rubberband (GTK_WIDGET (icon_view));
|
||||
|
||||
_gtk_icon_view_accessible_adjustment_changed (icon_view);
|
||||
|
||||
gtk_icon_view_process_updates (icon_view);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user