Compare commits
12 Commits
list-widge
...
wip/matthi
Author | SHA1 | Date | |
---|---|---|---|
|
bfb67c68b7 | ||
|
0057db7934 | ||
|
ec4dedf021 | ||
|
f5daab3dd2 | ||
|
86c91a7c2a | ||
|
9b2b70f697 | ||
|
840b2920fb | ||
|
29b23c38bf | ||
|
dadc7c35fe | ||
|
706ba68f3c | ||
|
5e1d605e85 | ||
|
b67f89a1cb |
@@ -138,7 +138,6 @@ private_headers = [
|
||||
'gtkmountoperationprivate.h',
|
||||
'gtknativedialogprivate.h',
|
||||
'gtknomediafileprivate.h',
|
||||
'gtkorientableprivate.h',
|
||||
'gtkplacessidebarprivate.h',
|
||||
'gtkplacesviewprivate.h',
|
||||
'gtkplacesviewrowprivate.h',
|
||||
|
@@ -171,6 +171,20 @@ gtk_button_accessible_ref_state_set (AtkObject *obj)
|
||||
return state_set;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_button_accessible_update_label (GtkButtonAccessible *self)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_BUTTON_ACCESSIBLE (self));
|
||||
|
||||
/* If we don't have an overridden name, we use the label as the
|
||||
* accessible name
|
||||
*/
|
||||
if (atk_object_get_name (ATK_OBJECT (self)) == NULL)
|
||||
g_object_notify (G_OBJECT (self), "accessible-name");
|
||||
|
||||
g_signal_emit_by_name (self, "visible-data-changed");
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_button_accessible_notify_gtk (GObject *obj,
|
||||
GParamSpec *pspec)
|
||||
|
@@ -52,6 +52,9 @@ struct _GtkButtonAccessibleClass
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_button_accessible_get_type (void);
|
||||
|
||||
/*< private >*/
|
||||
void gtk_button_accessible_update_label (GtkButtonAccessible *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_BUTTON_ACCESSIBLE_H__ */
|
||||
|
@@ -32,11 +32,11 @@
|
||||
#define GTK_ICON_VIEW_ITEM_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ICON_VIEW_ITEM_ACCESSIBLE, GtkIconViewItemAccessible))
|
||||
#define GTK_IS_ICON_VIEW_ITEM_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ICON_VIEW_ITEM_ACCESSIBLE))
|
||||
|
||||
struct _GtkIconViewAccessiblePrivate
|
||||
typedef struct
|
||||
{
|
||||
GList *items;
|
||||
GtkTreeModel *model;
|
||||
};
|
||||
} GtkIconViewAccessiblePrivate;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -265,7 +265,8 @@ get_text (GtkIconView *icon_view,
|
||||
|
||||
_gtk_icon_view_set_cell_data (icon_view, item);
|
||||
gtk_cell_area_foreach (icon_view->priv->cell_area,
|
||||
(GtkCellCallback)get_text_foreach, &text);
|
||||
(GtkCellCallback) get_text_foreach,
|
||||
&text);
|
||||
|
||||
return text;
|
||||
}
|
||||
@@ -742,8 +743,9 @@ gtk_icon_view_item_accessible_set_visibility (GtkIconViewItemAccessible *item,
|
||||
static void
|
||||
_gtk_icon_view_item_accessible_init (GtkIconViewItemAccessible *item)
|
||||
{
|
||||
item->state_set = atk_state_set_new ();
|
||||
atk_object_set_role (ATK_OBJECT (item), ATK_ROLE_ICON);
|
||||
|
||||
item->state_set = atk_state_set_new ();
|
||||
atk_state_set_add_state (item->state_set, ATK_STATE_ENABLED);
|
||||
atk_state_set_add_state (item->state_set, ATK_STATE_FOCUSABLE);
|
||||
atk_state_set_add_state (item->state_set, ATK_STATE_SENSITIVE);
|
||||
@@ -860,25 +862,25 @@ G_DEFINE_TYPE_WITH_CODE (GtkIconViewAccessible, gtk_icon_view_accessible, GTK_TY
|
||||
typedef struct
|
||||
{
|
||||
AtkObject *item;
|
||||
gint index;
|
||||
} GtkIconViewItemAccessibleInfo;
|
||||
int index;
|
||||
} ItemAccessibleInfo;
|
||||
|
||||
|
||||
static void
|
||||
gtk_icon_view_item_accessible_info_new (AtkObject *accessible,
|
||||
AtkObject *item,
|
||||
gint index)
|
||||
gtk_icon_view_item_accessible_info_new (GtkIconViewAccessible *self,
|
||||
GtkIconViewItemAccessible *item,
|
||||
int index)
|
||||
{
|
||||
GtkIconViewAccessible *view = (GtkIconViewAccessible *)accessible;
|
||||
GtkIconViewItemAccessibleInfo *info;
|
||||
GtkIconViewItemAccessibleInfo *tmp_info;
|
||||
GtkIconViewAccessiblePrivate *priv = gtk_icon_view_accessible_get_instance_private (self);
|
||||
ItemAccessibleInfo *info;
|
||||
ItemAccessibleInfo *tmp_info;
|
||||
GList *items;
|
||||
|
||||
info = g_new (GtkIconViewItemAccessibleInfo, 1);
|
||||
info->item = item;
|
||||
info = g_new (ItemAccessibleInfo, 1);
|
||||
info->item = ATK_OBJECT (item);
|
||||
info->index = index;
|
||||
|
||||
items = view->priv->items;
|
||||
items = priv->items;
|
||||
while (items)
|
||||
{
|
||||
tmp_info = items->data;
|
||||
@@ -886,7 +888,8 @@ gtk_icon_view_item_accessible_info_new (AtkObject *accessible,
|
||||
break;
|
||||
items = items->next;
|
||||
}
|
||||
view->priv->items = g_list_insert_before (view->priv->items, items, info);
|
||||
|
||||
priv->items = g_list_insert_before (priv->items, items, info);
|
||||
}
|
||||
|
||||
static gint
|
||||
@@ -904,22 +907,24 @@ gtk_icon_view_accessible_get_n_children (AtkObject *accessible)
|
||||
return g_list_length (icon_view->priv->items);
|
||||
}
|
||||
|
||||
static AtkObject *
|
||||
gtk_icon_view_accessible_find_child (AtkObject *accessible,
|
||||
gint index)
|
||||
static GtkIconViewItemAccessible *
|
||||
gtk_icon_view_accessible_find_child (GtkIconViewAccessible *self,
|
||||
gint index)
|
||||
{
|
||||
GtkIconViewAccessible *view = (GtkIconViewAccessible*)accessible;
|
||||
GtkIconViewItemAccessibleInfo *info;
|
||||
GtkIconViewAccessiblePrivate *priv = gtk_icon_view_accessible_get_instance_private (self);
|
||||
GList *items;
|
||||
|
||||
items = view->priv->items;
|
||||
items = priv->items;
|
||||
|
||||
while (items)
|
||||
{
|
||||
info = items->data;
|
||||
ItemAccessibleInfo *info = items->data;
|
||||
GList *next = items->next;
|
||||
|
||||
if (info->index == index)
|
||||
return info->item;
|
||||
items = items->next;
|
||||
return GTK_ICON_VIEW_ITEM_ACCESSIBLE (info->item);
|
||||
|
||||
items = next;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -929,31 +934,28 @@ static AtkObject *
|
||||
gtk_icon_view_accessible_ref_child (AtkObject *accessible,
|
||||
gint index)
|
||||
{
|
||||
GtkIconViewAccessible *self = GTK_ICON_VIEW_ACCESSIBLE (accessible);
|
||||
GtkIconViewItemAccessible *a11y_item;
|
||||
GtkIconView *icon_view;
|
||||
GtkWidget *widget;
|
||||
GList *icons;
|
||||
AtkObject *obj;
|
||||
GtkIconViewItemAccessible *a11y_item;
|
||||
|
||||
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
|
||||
if (!widget)
|
||||
if (widget == NULL)
|
||||
return NULL;
|
||||
|
||||
icon_view = GTK_ICON_VIEW (widget);
|
||||
icons = g_list_nth (icon_view->priv->items, index);
|
||||
obj = NULL;
|
||||
if (icons)
|
||||
{
|
||||
GtkIconViewItem *item = icons->data;
|
||||
|
||||
g_return_val_if_fail (item->index == index, NULL);
|
||||
obj = gtk_icon_view_accessible_find_child (accessible, index);
|
||||
if (!obj)
|
||||
|
||||
a11y_item = gtk_icon_view_accessible_find_child (self, index);
|
||||
if (a11y_item == NULL)
|
||||
{
|
||||
obj = g_object_new (GTK_TYPE_ICON_VIEW_ITEM_ACCESSIBLE, NULL);
|
||||
gtk_icon_view_item_accessible_info_new (accessible, obj, index);
|
||||
obj->role = ATK_ROLE_ICON;
|
||||
a11y_item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (obj);
|
||||
a11y_item = g_object_new (GTK_TYPE_ICON_VIEW_ITEM_ACCESSIBLE, NULL);
|
||||
a11y_item->item = item;
|
||||
a11y_item->widget = widget;
|
||||
|
||||
@@ -962,60 +964,62 @@ gtk_icon_view_accessible_ref_child (AtkObject *accessible,
|
||||
|
||||
gtk_icon_view_item_accessible_set_visibility (a11y_item, FALSE);
|
||||
g_object_add_weak_pointer (G_OBJECT (widget), (gpointer) &(a11y_item->widget));
|
||||
|
||||
gtk_icon_view_item_accessible_info_new (self, a11y_item, index);
|
||||
}
|
||||
g_object_ref (obj);
|
||||
|
||||
g_object_ref (a11y_item);
|
||||
|
||||
return ATK_OBJECT (a11y_item);
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_icon_view_accessible_traverse_items (GtkIconViewAccessible *view,
|
||||
gtk_icon_view_accessible_traverse_items (GtkIconViewAccessible *self,
|
||||
GList *list)
|
||||
{
|
||||
GtkIconViewItemAccessibleInfo *info;
|
||||
GtkIconViewItemAccessible *item;
|
||||
GtkIconViewAccessiblePrivate *priv = gtk_icon_view_accessible_get_instance_private (self);
|
||||
GtkWidget *widget;
|
||||
gboolean act_on_item;
|
||||
GList *items;
|
||||
|
||||
if (view->priv->items)
|
||||
if (priv->items == NULL)
|
||||
return;
|
||||
|
||||
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (self));
|
||||
if (widget == NULL)
|
||||
return;
|
||||
|
||||
items = priv->items;
|
||||
|
||||
act_on_item = (list == NULL);
|
||||
|
||||
while (items)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
gboolean act_on_item;
|
||||
ItemAccessibleInfo *info = items->data;
|
||||
GtkIconViewItemAccessible *item;
|
||||
GList *next = items->next;
|
||||
|
||||
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (view));
|
||||
if (widget == NULL)
|
||||
return;
|
||||
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (info->item);
|
||||
|
||||
items = view->priv->items;
|
||||
if (act_on_item == FALSE && list == items)
|
||||
act_on_item = TRUE;
|
||||
|
||||
act_on_item = (list == NULL);
|
||||
if (act_on_item)
|
||||
gtk_icon_view_item_accessible_set_visibility (item, TRUE);
|
||||
|
||||
while (items)
|
||||
{
|
||||
|
||||
info = (GtkIconViewItemAccessibleInfo *)items->data;
|
||||
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (info->item);
|
||||
|
||||
if (act_on_item == FALSE && list == items)
|
||||
act_on_item = TRUE;
|
||||
|
||||
if (act_on_item)
|
||||
gtk_icon_view_item_accessible_set_visibility (item, TRUE);
|
||||
|
||||
items = items->next;
|
||||
}
|
||||
items = next;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_icon_view_accessible_adjustment_changed (GtkIconView *icon_view)
|
||||
gtk_icon_view_accessible_adjustment_changed (GtkIconViewAccessible *self)
|
||||
{
|
||||
GtkIconViewAccessible *view;
|
||||
|
||||
view = GTK_ICON_VIEW_ACCESSIBLE (_gtk_widget_peek_accessible (GTK_WIDGET (icon_view)));
|
||||
if (view == NULL)
|
||||
return;
|
||||
|
||||
gtk_icon_view_accessible_traverse_items (view, NULL);
|
||||
gtk_icon_view_accessible_traverse_items (self, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1024,36 +1028,26 @@ gtk_icon_view_accessible_model_row_changed (GtkTreeModel *tree_model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer user_data)
|
||||
{
|
||||
AtkObject *atk_obj;
|
||||
gint index;
|
||||
GtkWidget *widget;
|
||||
GtkIconView *icon_view;
|
||||
GtkIconViewItem *item;
|
||||
GtkIconViewAccessible *self = user_data;
|
||||
GtkIconViewItemAccessible *a11y_item;
|
||||
const gchar *name;
|
||||
|
||||
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (user_data));
|
||||
index = gtk_tree_path_get_indices(path)[0];
|
||||
a11y_item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (
|
||||
gtk_icon_view_accessible_find_child (atk_obj, index));
|
||||
int index;
|
||||
|
||||
index = gtk_tree_path_get_indices (path)[0];
|
||||
a11y_item = gtk_icon_view_accessible_find_child (self, index);
|
||||
if (a11y_item)
|
||||
{
|
||||
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (atk_obj));
|
||||
icon_view = GTK_ICON_VIEW (widget);
|
||||
item = a11y_item->item;
|
||||
GtkIconViewItem *item = a11y_item->item;
|
||||
GtkIconView *icon_view = GTK_ICON_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (self)));
|
||||
|
||||
name = atk_object_get_name (ATK_OBJECT (a11y_item));
|
||||
if (!name || strcmp (name, "") == 0)
|
||||
const char *name = atk_object_get_name (ATK_OBJECT (a11y_item));
|
||||
if (name == NULL || *name == '\0')
|
||||
{
|
||||
g_free (a11y_item->text);
|
||||
a11y_item->text = get_text (icon_view, item);
|
||||
}
|
||||
}
|
||||
|
||||
g_signal_emit_by_name (atk_obj, "visible-data-changed");
|
||||
|
||||
return;
|
||||
g_signal_emit_by_name (self, "visible-data-changed");
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1062,24 +1056,22 @@ gtk_icon_view_accessible_model_row_inserted (GtkTreeModel *tree_model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkIconViewItemAccessibleInfo *info;
|
||||
GtkIconViewAccessible *view;
|
||||
GtkIconViewItemAccessible *item;
|
||||
GtkIconViewAccessible *self = user_data;
|
||||
GtkIconViewAccessiblePrivate *priv = gtk_icon_view_accessible_get_instance_private (self);
|
||||
GList *items;
|
||||
GList *tmp_list;
|
||||
AtkObject *atk_obj;
|
||||
gint index;
|
||||
int index;
|
||||
|
||||
index = gtk_tree_path_get_indices(path)[0];
|
||||
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (user_data));
|
||||
view = GTK_ICON_VIEW_ACCESSIBLE (atk_obj);
|
||||
index = gtk_tree_path_get_indices (path)[0];
|
||||
|
||||
items = view->priv->items;
|
||||
items = priv->items;
|
||||
tmp_list = NULL;
|
||||
while (items)
|
||||
{
|
||||
info = items->data;
|
||||
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (info->item);
|
||||
ItemAccessibleInfo *info = items->data;
|
||||
GtkIconViewItemAccessible *item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (info->item);
|
||||
GList *next = items->next;
|
||||
|
||||
if (info->index != item->item->index)
|
||||
{
|
||||
if (info->index < index)
|
||||
@@ -1091,40 +1083,36 @@ gtk_icon_view_accessible_model_row_inserted (GtkTreeModel *tree_model,
|
||||
info->index = item->item->index;
|
||||
}
|
||||
|
||||
items = items->next;
|
||||
items = next;
|
||||
}
|
||||
gtk_icon_view_accessible_traverse_items (view, tmp_list);
|
||||
g_signal_emit_by_name (atk_obj, "children-changed::add",
|
||||
|
||||
gtk_icon_view_accessible_traverse_items (self, tmp_list);
|
||||
g_signal_emit_by_name (self,
|
||||
"children-changed::add",
|
||||
index, NULL, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_icon_view_accessible_model_row_deleted (GtkTreeModel *tree_model,
|
||||
GtkTreePath *path,
|
||||
gpointer user_data)
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkIconViewItemAccessibleInfo *info;
|
||||
GtkIconViewAccessible *view;
|
||||
GtkIconViewItemAccessible *item;
|
||||
GtkIconViewAccessible *self = user_data;
|
||||
GtkIconViewAccessiblePrivate *priv = gtk_icon_view_accessible_get_instance_private (self);
|
||||
GList *items;
|
||||
GList *tmp_list;
|
||||
GList *deleted_item;
|
||||
AtkObject *atk_obj;
|
||||
gint index;
|
||||
GList *tmp_list = NULL;
|
||||
GList *deleted_item = NULL;
|
||||
int index;
|
||||
|
||||
index = gtk_tree_path_get_indices(path)[0];
|
||||
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (user_data));
|
||||
view = GTK_ICON_VIEW_ACCESSIBLE (atk_obj);
|
||||
index = gtk_tree_path_get_indices (path)[0];
|
||||
|
||||
items = view->priv->items;
|
||||
tmp_list = NULL;
|
||||
deleted_item = NULL;
|
||||
info = NULL;
|
||||
items = priv->items;
|
||||
while (items)
|
||||
{
|
||||
info = items->data;
|
||||
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (info->item);
|
||||
ItemAccessibleInfo *info = items->data;
|
||||
GtkIconViewItemAccessible *item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (info->item);
|
||||
GList *next = items->next;
|
||||
|
||||
if (info->index == index)
|
||||
{
|
||||
deleted_item = items;
|
||||
@@ -1137,26 +1125,32 @@ gtk_icon_view_accessible_model_row_deleted (GtkTreeModel *tree_model,
|
||||
info->index = item->item->index;
|
||||
}
|
||||
|
||||
items = items->next;
|
||||
items = next;
|
||||
}
|
||||
|
||||
if (deleted_item)
|
||||
{
|
||||
info = deleted_item->data;
|
||||
gtk_icon_view_item_accessible_add_state (GTK_ICON_VIEW_ITEM_ACCESSIBLE (info->item), ATK_STATE_DEFUNCT, TRUE);
|
||||
g_signal_emit_by_name (atk_obj, "children-changed::remove",
|
||||
ItemAccessibleInfo *info = deleted_item->data;
|
||||
|
||||
gtk_icon_view_item_accessible_add_state (GTK_ICON_VIEW_ITEM_ACCESSIBLE (info->item),
|
||||
ATK_STATE_DEFUNCT,
|
||||
TRUE);
|
||||
|
||||
g_signal_emit_by_name (self,
|
||||
"children-changed::remove",
|
||||
index, NULL, NULL);
|
||||
view->priv->items = g_list_delete_link (view->priv->items, deleted_item);
|
||||
|
||||
priv->items = g_list_delete_link (priv->items, deleted_item);
|
||||
g_object_unref (info->item);
|
||||
g_free (info);
|
||||
}
|
||||
gtk_icon_view_accessible_traverse_items (view, tmp_list);
|
||||
|
||||
return;
|
||||
gtk_icon_view_accessible_traverse_items (self, tmp_list);
|
||||
}
|
||||
|
||||
static gint
|
||||
gtk_icon_view_accessible_item_compare (GtkIconViewItemAccessibleInfo *i1,
|
||||
GtkIconViewItemAccessibleInfo *i2)
|
||||
gtk_icon_view_accessible_item_compare (ItemAccessibleInfo *i1,
|
||||
ItemAccessibleInfo *i2)
|
||||
{
|
||||
return i1->index - i2->index;
|
||||
}
|
||||
@@ -1166,151 +1160,138 @@ gtk_icon_view_accessible_model_rows_reordered (GtkTreeModel *tree_model,
|
||||
GtkTreePath *path,
|
||||
GtkTreeIter *iter,
|
||||
gint *new_order,
|
||||
gpointer user_data)
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkIconViewAccessible *view;
|
||||
GtkIconViewItemAccessibleInfo *info;
|
||||
GtkIconViewAccessible *self = user_data;
|
||||
GtkIconViewAccessiblePrivate *priv = gtk_icon_view_accessible_get_instance_private (self);
|
||||
GtkIconView *icon_view;
|
||||
GtkIconViewItemAccessible *item;
|
||||
GList *items;
|
||||
AtkObject *atk_obj;
|
||||
gint *order;
|
||||
gint length, i;
|
||||
|
||||
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (user_data));
|
||||
icon_view = GTK_ICON_VIEW (user_data);
|
||||
view = (GtkIconViewAccessible*)atk_obj;
|
||||
int *order;
|
||||
int length, i;
|
||||
|
||||
icon_view = GTK_ICON_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (self)));
|
||||
length = gtk_tree_model_iter_n_children (tree_model, NULL);
|
||||
|
||||
order = g_new (gint, length);
|
||||
order = g_new (int, length);
|
||||
for (i = 0; i < length; i++)
|
||||
order [new_order[i]] = i;
|
||||
|
||||
items = view->priv->items;
|
||||
items = priv->items;
|
||||
while (items)
|
||||
{
|
||||
info = items->data;
|
||||
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (info->item);
|
||||
ItemAccessibleInfo *info = items->data;
|
||||
GtkIconViewItemAccessible *item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (info->item);
|
||||
GList *next = items->next;
|
||||
|
||||
info->index = order[info->index];
|
||||
item->item = g_list_nth_data (icon_view->priv->items, info->index);
|
||||
items = items->next;
|
||||
|
||||
items = next;
|
||||
}
|
||||
|
||||
g_free (order);
|
||||
view->priv->items = g_list_sort (view->priv->items,
|
||||
(GCompareFunc)gtk_icon_view_accessible_item_compare);
|
||||
|
||||
return;
|
||||
priv->items = g_list_sort (priv->items, (GCompareFunc) gtk_icon_view_accessible_item_compare);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_icon_view_accessible_disconnect_model_signals (GtkTreeModel *model,
|
||||
GtkWidget *widget)
|
||||
gtk_icon_view_accessible_disconnect_model_signals (GtkIconViewAccessible *self)
|
||||
{
|
||||
GObject *obj;
|
||||
GtkIconViewAccessiblePrivate *priv = gtk_icon_view_accessible_get_instance_private (self);
|
||||
|
||||
obj = G_OBJECT (model);
|
||||
g_signal_handlers_disconnect_by_func (obj, (gpointer) gtk_icon_view_accessible_model_row_changed, widget);
|
||||
g_signal_handlers_disconnect_by_func (obj, (gpointer) gtk_icon_view_accessible_model_row_inserted, widget);
|
||||
g_signal_handlers_disconnect_by_func (obj, (gpointer) gtk_icon_view_accessible_model_row_deleted, widget);
|
||||
g_signal_handlers_disconnect_by_func (obj, (gpointer) gtk_icon_view_accessible_model_rows_reordered, widget);
|
||||
g_signal_handlers_disconnect_by_func (priv->model, gtk_icon_view_accessible_model_row_changed, self);
|
||||
g_signal_handlers_disconnect_by_func (priv->model, gtk_icon_view_accessible_model_row_inserted, self);
|
||||
g_signal_handlers_disconnect_by_func (priv->model, gtk_icon_view_accessible_model_row_deleted, self);
|
||||
g_signal_handlers_disconnect_by_func (priv->model, gtk_icon_view_accessible_model_rows_reordered, self);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_icon_view_accessible_connect_model_signals (GtkIconView *icon_view)
|
||||
gtk_icon_view_accessible_connect_model_signals (GtkIconViewAccessible *self)
|
||||
{
|
||||
GObject *obj;
|
||||
GtkIconViewAccessiblePrivate *priv = gtk_icon_view_accessible_get_instance_private (self);
|
||||
|
||||
obj = G_OBJECT (icon_view->priv->model);
|
||||
g_signal_connect_object (obj, "row-changed",
|
||||
g_signal_connect_object (priv->model, "row-changed",
|
||||
G_CALLBACK (gtk_icon_view_accessible_model_row_changed),
|
||||
icon_view, 0);
|
||||
g_signal_connect_object (obj, "row-inserted",
|
||||
self, 0);
|
||||
g_signal_connect_object (priv->model, "row-inserted",
|
||||
G_CALLBACK (gtk_icon_view_accessible_model_row_inserted),
|
||||
icon_view, G_CONNECT_AFTER);
|
||||
g_signal_connect_object (obj, "row-deleted",
|
||||
self, G_CONNECT_AFTER);
|
||||
g_signal_connect_object (priv->model, "row-deleted",
|
||||
G_CALLBACK (gtk_icon_view_accessible_model_row_deleted),
|
||||
icon_view, G_CONNECT_AFTER);
|
||||
g_signal_connect_object (obj, "rows-reordered",
|
||||
self, G_CONNECT_AFTER);
|
||||
g_signal_connect_object (priv->model, "rows-reordered",
|
||||
G_CALLBACK (gtk_icon_view_accessible_model_rows_reordered),
|
||||
icon_view, G_CONNECT_AFTER);
|
||||
self, G_CONNECT_AFTER);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_icon_view_accessible_clear_cache (GtkIconViewAccessible *view)
|
||||
gtk_icon_view_accessible_clear_cache (GtkIconViewAccessible *self)
|
||||
{
|
||||
GtkIconViewItemAccessibleInfo *info;
|
||||
GtkIconViewAccessiblePrivate *priv = gtk_icon_view_accessible_get_instance_private (self);
|
||||
GList *items;
|
||||
|
||||
items = view->priv->items;
|
||||
while (items)
|
||||
if (priv->items == NULL)
|
||||
return;
|
||||
|
||||
items = priv->items;
|
||||
while (items != NULL)
|
||||
{
|
||||
info = (GtkIconViewItemAccessibleInfo *) items->data;
|
||||
gtk_icon_view_item_accessible_add_state (GTK_ICON_VIEW_ITEM_ACCESSIBLE (info->item), ATK_STATE_DEFUNCT, TRUE);
|
||||
ItemAccessibleInfo *info = items->data;
|
||||
GList *next = items->next;
|
||||
|
||||
gtk_icon_view_item_accessible_add_state (GTK_ICON_VIEW_ITEM_ACCESSIBLE (info->item),
|
||||
ATK_STATE_DEFUNCT,
|
||||
TRUE);
|
||||
g_object_unref (info->item);
|
||||
g_free (items->data);
|
||||
items = items->next;
|
||||
g_free (info);
|
||||
|
||||
items = next;
|
||||
}
|
||||
g_list_free (view->priv->items);
|
||||
view->priv->items = NULL;
|
||||
|
||||
g_clear_pointer (&priv->items, g_list_free);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_icon_view_accessible_notify_gtk (GObject *obj,
|
||||
GParamSpec *pspec)
|
||||
void
|
||||
gtk_icon_view_accessible_update_model (GtkIconViewAccessible *self,
|
||||
GtkTreeModel *model)
|
||||
{
|
||||
GtkIconView *icon_view;
|
||||
GtkWidget *widget;
|
||||
AtkObject *atk_obj;
|
||||
GtkIconViewAccessible *view;
|
||||
GtkIconViewAccessiblePrivate *priv = gtk_icon_view_accessible_get_instance_private (self);
|
||||
|
||||
if (strcmp (pspec->name, "model") == 0)
|
||||
if (priv->model != NULL)
|
||||
{
|
||||
widget = GTK_WIDGET (obj);
|
||||
atk_obj = gtk_widget_get_accessible (widget);
|
||||
view = (GtkIconViewAccessible*)atk_obj;
|
||||
if (view->priv->model)
|
||||
{
|
||||
g_object_remove_weak_pointer (G_OBJECT (view->priv->model),
|
||||
(gpointer *)&view->priv->model);
|
||||
gtk_icon_view_accessible_disconnect_model_signals (view->priv->model, widget);
|
||||
}
|
||||
gtk_icon_view_accessible_clear_cache (view);
|
||||
|
||||
icon_view = GTK_ICON_VIEW (obj);
|
||||
view->priv->model = icon_view->priv->model;
|
||||
/* If there is no model the GtkIconView is probably being destroyed */
|
||||
if (view->priv->model)
|
||||
{
|
||||
g_object_add_weak_pointer (G_OBJECT (view->priv->model), (gpointer *)&view->priv->model);
|
||||
gtk_icon_view_accessible_connect_model_signals (icon_view);
|
||||
}
|
||||
g_object_remove_weak_pointer (G_OBJECT (priv->model),
|
||||
(gpointer *) &priv->model);
|
||||
gtk_icon_view_accessible_disconnect_model_signals (self);
|
||||
}
|
||||
|
||||
return;
|
||||
gtk_icon_view_accessible_clear_cache (self);
|
||||
|
||||
priv->model = model;
|
||||
|
||||
/* If there is no model the GtkIconView is probably being destroyed */
|
||||
if (priv->model != NULL)
|
||||
{
|
||||
g_object_add_weak_pointer (G_OBJECT (priv->model), (gpointer *) &priv->model);
|
||||
gtk_icon_view_accessible_connect_model_signals (self);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_icon_view_accessible_initialize (AtkObject *accessible,
|
||||
gpointer data)
|
||||
{
|
||||
GtkIconViewAccessible *view;
|
||||
GtkIconView *icon_view;
|
||||
GtkIconViewAccessible *self = GTK_ICON_VIEW_ACCESSIBLE (accessible);
|
||||
GtkIconViewAccessiblePrivate *priv = gtk_icon_view_accessible_get_instance_private (self);
|
||||
GtkIconView *icon_view = data;
|
||||
|
||||
if (ATK_OBJECT_CLASS (gtk_icon_view_accessible_parent_class)->initialize)
|
||||
ATK_OBJECT_CLASS (gtk_icon_view_accessible_parent_class)->initialize (accessible, data);
|
||||
|
||||
icon_view = (GtkIconView*)data;
|
||||
view = (GtkIconViewAccessible*)accessible;
|
||||
|
||||
g_signal_connect (data, "notify",
|
||||
G_CALLBACK (gtk_icon_view_accessible_notify_gtk), NULL);
|
||||
|
||||
view->priv->model = icon_view->priv->model;
|
||||
if (view->priv->model)
|
||||
priv->model = icon_view->priv->model;
|
||||
if (priv->model)
|
||||
{
|
||||
g_object_add_weak_pointer (G_OBJECT (view->priv->model), (gpointer *)&view->priv->model);
|
||||
gtk_icon_view_accessible_connect_model_signals (icon_view);
|
||||
g_object_add_weak_pointer (G_OBJECT (priv->model), (gpointer *) &priv->model);
|
||||
gtk_icon_view_accessible_connect_model_signals (self);
|
||||
}
|
||||
|
||||
accessible->role = ATK_ROLE_LAYERED_PANE;
|
||||
@@ -1319,7 +1300,7 @@ gtk_icon_view_accessible_initialize (AtkObject *accessible,
|
||||
static void
|
||||
gtk_icon_view_accessible_finalize (GObject *object)
|
||||
{
|
||||
GtkIconViewAccessible *view = (GtkIconViewAccessible*)object;
|
||||
GtkIconViewAccessible *view = GTK_ICON_VIEW_ACCESSIBLE (object);
|
||||
|
||||
gtk_icon_view_accessible_clear_cache (view);
|
||||
|
||||
@@ -1329,11 +1310,8 @@ gtk_icon_view_accessible_finalize (GObject *object)
|
||||
static void
|
||||
gtk_icon_view_accessible_class_init (GtkIconViewAccessibleClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
AtkObjectClass *atk_class;
|
||||
|
||||
gobject_class = (GObjectClass *)klass;
|
||||
atk_class = (AtkObjectClass *)klass;
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
AtkObjectClass *atk_class = ATK_OBJECT_CLASS (klass);
|
||||
|
||||
gobject_class->finalize = gtk_icon_view_accessible_finalize;
|
||||
|
||||
@@ -1345,7 +1323,6 @@ gtk_icon_view_accessible_class_init (GtkIconViewAccessibleClass *klass)
|
||||
static void
|
||||
gtk_icon_view_accessible_init (GtkIconViewAccessible *accessible)
|
||||
{
|
||||
accessible->priv = gtk_icon_view_accessible_get_instance_private (accessible);
|
||||
}
|
||||
|
||||
static AtkObject*
|
||||
|
@@ -35,13 +35,10 @@ G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GtkIconViewAccessible GtkIconViewAccessible;
|
||||
typedef struct _GtkIconViewAccessibleClass GtkIconViewAccessibleClass;
|
||||
typedef struct _GtkIconViewAccessiblePrivate GtkIconViewAccessiblePrivate;
|
||||
|
||||
struct _GtkIconViewAccessible
|
||||
{
|
||||
GtkWidgetAccessible parent;
|
||||
|
||||
GtkIconViewAccessiblePrivate *priv;
|
||||
};
|
||||
|
||||
struct _GtkIconViewAccessibleClass
|
||||
|
@@ -19,12 +19,14 @@
|
||||
#define __GTK_ICON_VIEW_ACCESSIBLE_PRIVATE_H__
|
||||
|
||||
#include <gtk/a11y/gtkiconviewaccessible.h>
|
||||
|
||||
#include <gtk/gtkiconview.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
void _gtk_icon_view_accessible_adjustment_changed (GtkIconView *icon_view);
|
||||
void gtk_icon_view_accessible_adjustment_changed (GtkIconViewAccessible *self);
|
||||
|
||||
void gtk_icon_view_accessible_update_model (GtkIconViewAccessible *self,
|
||||
GtkTreeModel *model);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@@ -21,10 +21,12 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include "gtkrangeaccessible.h"
|
||||
|
||||
struct _GtkRangeAccessiblePrivate
|
||||
typedef struct
|
||||
{
|
||||
GtkAdjustment *adjustment;
|
||||
};
|
||||
|
||||
gulong value_changed_id;
|
||||
} GtkRangeAccessiblePrivate;
|
||||
|
||||
static void atk_value_interface_init (AtkValueIface *iface);
|
||||
|
||||
@@ -42,35 +44,44 @@ gtk_range_accessible_value_changed (GtkAdjustment *adjustment,
|
||||
static void
|
||||
gtk_range_accessible_widget_set (GtkAccessible *accessible)
|
||||
{
|
||||
GtkRangeAccessiblePrivate *priv = GTK_RANGE_ACCESSIBLE (accessible)->priv;
|
||||
GtkRangeAccessible *self = GTK_RANGE_ACCESSIBLE (accessible);
|
||||
GtkRangeAccessiblePrivate *priv = gtk_range_accessible_get_instance_private (self);
|
||||
GtkWidget *range;
|
||||
GtkAdjustment *adj;
|
||||
|
||||
range = gtk_accessible_get_widget (accessible);
|
||||
adj = gtk_range_get_adjustment (GTK_RANGE (range));
|
||||
if (adj)
|
||||
if (adj != NULL)
|
||||
{
|
||||
priv->adjustment = adj;
|
||||
g_object_ref (priv->adjustment);
|
||||
g_signal_connect (priv->adjustment, "value-changed",
|
||||
G_CALLBACK (gtk_range_accessible_value_changed),
|
||||
accessible);
|
||||
priv->adjustment = g_object_ref (adj);
|
||||
priv->value_changed_id =
|
||||
g_signal_connect (priv->adjustment, "value-changed",
|
||||
G_CALLBACK (gtk_range_accessible_value_changed),
|
||||
self);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_range_accessible_widget_unset (GtkAccessible *accessible)
|
||||
{
|
||||
GtkRangeAccessiblePrivate *priv = GTK_RANGE_ACCESSIBLE (accessible)->priv;
|
||||
GtkRangeAccessible *self = GTK_RANGE_ACCESSIBLE (accessible);
|
||||
GtkRangeAccessiblePrivate *priv = gtk_range_accessible_get_instance_private (self);
|
||||
|
||||
if (priv->adjustment)
|
||||
if (priv->adjustment != NULL &&
|
||||
priv->value_changed_id != 0)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (priv->adjustment,
|
||||
G_CALLBACK (gtk_range_accessible_value_changed),
|
||||
accessible);
|
||||
g_object_unref (priv->adjustment);
|
||||
priv->adjustment = NULL;
|
||||
g_signal_handler_disconnect (priv->adjustment, priv->value_changed_id);
|
||||
priv->value_changed_id = 0;
|
||||
}
|
||||
|
||||
g_clear_object (&priv->adjustment);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_range_accessible_update_adjustment (GtkRangeAccessible *self)
|
||||
{
|
||||
gtk_range_accessible_widget_unset (GTK_ACCESSIBLE (self));
|
||||
gtk_range_accessible_widget_set (GTK_ACCESSIBLE (self));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -82,42 +93,40 @@ gtk_range_accessible_initialize (AtkObject *obj,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_range_accessible_notify_gtk (GObject *obj,
|
||||
GParamSpec *pspec)
|
||||
gtk_range_accessible_dispose (GObject *gobject)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (obj);
|
||||
AtkObject *range;
|
||||
GtkRangeAccessible *self = GTK_RANGE_ACCESSIBLE (gobject);
|
||||
GtkRangeAccessiblePrivate *priv = gtk_range_accessible_get_instance_private (self);
|
||||
|
||||
if (strcmp (pspec->name, "adjustment") == 0)
|
||||
if (priv->adjustment != NULL && priv->value_changed_id != 0)
|
||||
{
|
||||
range = gtk_widget_get_accessible (widget);
|
||||
gtk_range_accessible_widget_unset (GTK_ACCESSIBLE (range));
|
||||
gtk_range_accessible_widget_set (GTK_ACCESSIBLE (range));
|
||||
g_signal_handler_disconnect (priv->adjustment, priv->value_changed_id);
|
||||
priv->value_changed_id = 0;
|
||||
}
|
||||
else
|
||||
GTK_WIDGET_ACCESSIBLE_CLASS (gtk_range_accessible_parent_class)->notify_gtk (obj, pspec);
|
||||
}
|
||||
|
||||
g_clear_object (&priv->adjustment);
|
||||
|
||||
G_OBJECT_CLASS (gtk_range_accessible_parent_class)->dispose (gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_range_accessible_class_init (GtkRangeAccessibleClass *klass)
|
||||
{
|
||||
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
AtkObjectClass *atkobject_class = ATK_OBJECT_CLASS (klass);
|
||||
GtkAccessibleClass *accessible_class = (GtkAccessibleClass*)klass;
|
||||
GtkWidgetAccessibleClass *widget_class = (GtkWidgetAccessibleClass*)klass;
|
||||
|
||||
class->initialize = gtk_range_accessible_initialize;
|
||||
gobject_class->dispose = gtk_range_accessible_dispose;
|
||||
|
||||
atkobject_class->initialize = gtk_range_accessible_initialize;
|
||||
|
||||
accessible_class->widget_set = gtk_range_accessible_widget_set;
|
||||
accessible_class->widget_unset = gtk_range_accessible_widget_unset;
|
||||
|
||||
widget_class->notify_gtk = gtk_range_accessible_notify_gtk;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_range_accessible_init (GtkRangeAccessible *range)
|
||||
{
|
||||
range->priv = gtk_range_accessible_get_instance_private (range);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -35,13 +35,10 @@ G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GtkRangeAccessible GtkRangeAccessible;
|
||||
typedef struct _GtkRangeAccessibleClass GtkRangeAccessibleClass;
|
||||
typedef struct _GtkRangeAccessiblePrivate GtkRangeAccessiblePrivate;
|
||||
|
||||
struct _GtkRangeAccessible
|
||||
{
|
||||
GtkWidgetAccessible parent;
|
||||
|
||||
GtkRangeAccessiblePrivate *priv;
|
||||
};
|
||||
|
||||
struct _GtkRangeAccessibleClass
|
||||
@@ -52,6 +49,9 @@ struct _GtkRangeAccessibleClass
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_range_accessible_get_type (void);
|
||||
|
||||
/*< private >*/
|
||||
void gtk_range_accessible_update_adjustment (GtkRangeAccessible *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_RANGE_ACCESSIBLE_H__ */
|
||||
|
@@ -49,27 +49,6 @@ gtk_toggle_button_accessible_initialize (AtkObject *obj,
|
||||
obj->role = ATK_ROLE_TOGGLE_BUTTON;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_toggle_button_accessible_notify_gtk (GObject *obj,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (obj);
|
||||
AtkObject *atk_obj;
|
||||
gboolean sensitive;
|
||||
|
||||
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (toggle_button));
|
||||
sensitive = gtk_widget_get_sensitive (GTK_WIDGET (toggle_button));
|
||||
|
||||
if (strcmp (pspec->name, "sensitive") == 0)
|
||||
{
|
||||
/* Need to override gailwidget behavior of notifying for ENABLED */
|
||||
atk_object_notify_state_change (atk_obj, ATK_STATE_SENSITIVE, sensitive);
|
||||
atk_object_notify_state_change (atk_obj, ATK_STATE_ENABLED, sensitive);
|
||||
}
|
||||
else
|
||||
GTK_WIDGET_ACCESSIBLE_CLASS (gtk_toggle_button_accessible_parent_class)->notify_gtk (obj, pspec);
|
||||
}
|
||||
|
||||
static AtkStateSet*
|
||||
gtk_toggle_button_accessible_ref_state_set (AtkObject *accessible)
|
||||
{
|
||||
@@ -94,9 +73,6 @@ static void
|
||||
gtk_toggle_button_accessible_class_init (GtkToggleButtonAccessibleClass *klass)
|
||||
{
|
||||
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
|
||||
GtkWidgetAccessibleClass *widget_class = (GtkWidgetAccessibleClass*)klass;
|
||||
|
||||
widget_class->notify_gtk = gtk_toggle_button_accessible_notify_gtk;
|
||||
|
||||
class->ref_state_set = gtk_toggle_button_accessible_ref_state_set;
|
||||
class->initialize = gtk_toggle_button_accessible_initialize;
|
||||
|
@@ -32,10 +32,10 @@
|
||||
#include "gtkcellaccessibleparent.h"
|
||||
#include "gtkcellaccessibleprivate.h"
|
||||
|
||||
struct _GtkTreeViewAccessiblePrivate
|
||||
typedef struct
|
||||
{
|
||||
GHashTable *cell_infos;
|
||||
};
|
||||
} GtkTreeViewAccessiblePrivate;
|
||||
|
||||
typedef struct _GtkTreeViewAccessibleCellInfo GtkTreeViewAccessibleCellInfo;
|
||||
struct _GtkTreeViewAccessibleCellInfo
|
||||
@@ -138,89 +138,80 @@ static void
|
||||
gtk_tree_view_accessible_initialize (AtkObject *obj,
|
||||
gpointer data)
|
||||
{
|
||||
GtkTreeViewAccessible *accessible;
|
||||
GtkTreeView *tree_view;
|
||||
GtkTreeViewAccessible *self = GTK_TREE_VIEW_ACCESSIBLE (obj);
|
||||
GtkTreeViewAccessiblePrivate *priv = gtk_tree_view_accessible_get_instance_private (self);
|
||||
GtkTreeView *tree_view = data;
|
||||
GtkTreeModel *tree_model;
|
||||
GtkWidget *widget;
|
||||
|
||||
ATK_OBJECT_CLASS (gtk_tree_view_accessible_parent_class)->initialize (obj, data);
|
||||
|
||||
accessible = GTK_TREE_VIEW_ACCESSIBLE (obj);
|
||||
priv->cell_infos = g_hash_table_new_full (cell_info_hash, cell_info_equal,
|
||||
NULL,
|
||||
(GDestroyNotify) cell_info_free);
|
||||
|
||||
accessible->priv->cell_infos = g_hash_table_new_full (cell_info_hash,
|
||||
cell_info_equal, NULL, (GDestroyNotify) cell_info_free);
|
||||
|
||||
widget = GTK_WIDGET (data);
|
||||
tree_view = GTK_TREE_VIEW (widget);
|
||||
tree_model = gtk_tree_view_get_model (tree_view);
|
||||
|
||||
if (tree_model)
|
||||
if (tree_model != NULL)
|
||||
{
|
||||
if (gtk_tree_model_get_flags (tree_model) & GTK_TREE_MODEL_LIST_ONLY)
|
||||
obj->role = ATK_ROLE_TABLE;
|
||||
AtkRole role;
|
||||
|
||||
if ((gtk_tree_model_get_flags (tree_model) & GTK_TREE_MODEL_LIST_ONLY) != 0)
|
||||
role = ATK_ROLE_TABLE;
|
||||
else
|
||||
obj->role = ATK_ROLE_TREE_TABLE;
|
||||
role = ATK_ROLE_TREE_TABLE;
|
||||
|
||||
atk_object_set_role (obj, role);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_tree_view_accessible_finalize (GObject *object)
|
||||
{
|
||||
GtkTreeViewAccessible *accessible = GTK_TREE_VIEW_ACCESSIBLE (object);
|
||||
GtkTreeViewAccessible *self = GTK_TREE_VIEW_ACCESSIBLE (object);
|
||||
GtkTreeViewAccessiblePrivate *priv = gtk_tree_view_accessible_get_instance_private (self);
|
||||
|
||||
if (accessible->priv->cell_infos)
|
||||
g_hash_table_destroy (accessible->priv->cell_infos);
|
||||
g_clear_pointer (&priv->cell_infos, g_hash_table_unref);
|
||||
|
||||
G_OBJECT_CLASS (gtk_tree_view_accessible_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_tree_view_accessible_notify_gtk (GObject *obj,
|
||||
GParamSpec *pspec)
|
||||
void
|
||||
gtk_tree_view_accessible_update_model (GtkTreeViewAccessible *self,
|
||||
GtkTreeModel *model)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GtkTreeView *tree_view;
|
||||
GtkTreeViewAccessible *accessible;
|
||||
GtkTreeViewAccessiblePrivate *priv = gtk_tree_view_accessible_get_instance_private (self);
|
||||
|
||||
widget = GTK_WIDGET (obj);
|
||||
accessible = GTK_TREE_VIEW_ACCESSIBLE (gtk_widget_get_accessible (widget));
|
||||
tree_view = GTK_TREE_VIEW (widget);
|
||||
g_return_if_fail (GTK_IS_TREE_VIEW_ACCESSIBLE (self));
|
||||
g_return_if_fail (model == NULL || GTK_IS_TREE_MODEL (model));
|
||||
|
||||
if (g_strcmp0 (pspec->name, "model") == 0)
|
||||
g_hash_table_remove_all (priv->cell_infos);
|
||||
|
||||
if (model != NULL)
|
||||
{
|
||||
GtkTreeModel *tree_model;
|
||||
AtkObject *object = ATK_OBJECT (self);
|
||||
AtkRole role;
|
||||
|
||||
tree_model = gtk_tree_view_get_model (tree_view);
|
||||
g_hash_table_remove_all (accessible->priv->cell_infos);
|
||||
|
||||
if (tree_model)
|
||||
{
|
||||
if (gtk_tree_model_get_flags (tree_model) & GTK_TREE_MODEL_LIST_ONLY)
|
||||
role = ATK_ROLE_TABLE;
|
||||
else
|
||||
role = ATK_ROLE_TREE_TABLE;
|
||||
}
|
||||
if ((gtk_tree_model_get_flags (model) & GTK_TREE_MODEL_LIST_ONLY) != 0)
|
||||
role = ATK_ROLE_TABLE;
|
||||
else
|
||||
{
|
||||
role = ATK_ROLE_UNKNOWN;
|
||||
}
|
||||
atk_object_set_role (ATK_OBJECT (accessible), role);
|
||||
g_object_freeze_notify (G_OBJECT (accessible));
|
||||
g_signal_emit_by_name (accessible, "model-changed");
|
||||
g_signal_emit_by_name (accessible, "visible-data-changed");
|
||||
g_object_thaw_notify (G_OBJECT (accessible));
|
||||
role = ATK_ROLE_TREE_TABLE;
|
||||
|
||||
atk_object_set_role (object, role);
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (self));
|
||||
g_signal_emit_by_name (self, "model-changed");
|
||||
g_signal_emit_by_name (self, "visible-data-changed");
|
||||
g_object_thaw_notify (G_OBJECT (self));
|
||||
}
|
||||
else
|
||||
GTK_WIDGET_ACCESSIBLE_CLASS (gtk_tree_view_accessible_parent_class)->notify_gtk (obj, pspec);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_tree_view_accessible_widget_unset (GtkAccessible *gtkaccessible)
|
||||
{
|
||||
GtkTreeViewAccessible *accessible = GTK_TREE_VIEW_ACCESSIBLE (gtkaccessible);
|
||||
GtkTreeViewAccessible *self = GTK_TREE_VIEW_ACCESSIBLE (gtkaccessible);
|
||||
GtkTreeViewAccessiblePrivate *priv = gtk_tree_view_accessible_get_instance_private (self);
|
||||
|
||||
g_hash_table_remove_all (accessible->priv->cell_infos);
|
||||
g_hash_table_remove_all (priv->cell_infos);
|
||||
|
||||
GTK_ACCESSIBLE_CLASS (gtk_tree_view_accessible_parent_class)->widget_unset (gtkaccessible);
|
||||
}
|
||||
@@ -338,18 +329,19 @@ set_cell_data (GtkTreeView *treeview,
|
||||
}
|
||||
|
||||
static GtkCellAccessible *
|
||||
peek_cell (GtkTreeViewAccessible *accessible,
|
||||
peek_cell (GtkTreeViewAccessible *self,
|
||||
GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node,
|
||||
GtkTreeViewColumn *column)
|
||||
{
|
||||
GtkTreeViewAccessiblePrivate *priv = gtk_tree_view_accessible_get_instance_private (self);
|
||||
GtkTreeViewAccessibleCellInfo lookup, *cell_info;
|
||||
|
||||
lookup.tree = tree;
|
||||
lookup.node = node;
|
||||
lookup.cell_col_ref = column;
|
||||
|
||||
cell_info = g_hash_table_lookup (accessible->priv->cell_infos, &lookup);
|
||||
cell_info = g_hash_table_lookup (priv->cell_infos, &lookup);
|
||||
if (cell_info == NULL)
|
||||
return NULL;
|
||||
|
||||
@@ -490,15 +482,12 @@ gtk_tree_view_accessible_class_init (GtkTreeViewAccessibleClass *klass)
|
||||
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
GtkAccessibleClass *accessible_class = (GtkAccessibleClass*)klass;
|
||||
GtkWidgetAccessibleClass *widget_class = (GtkWidgetAccessibleClass*)klass;
|
||||
|
||||
class->get_n_children = gtk_tree_view_accessible_get_n_children;
|
||||
class->ref_child = gtk_tree_view_accessible_ref_child;
|
||||
class->ref_state_set = gtk_tree_view_accessible_ref_state_set;
|
||||
class->initialize = gtk_tree_view_accessible_initialize;
|
||||
|
||||
widget_class->notify_gtk = gtk_tree_view_accessible_notify_gtk;
|
||||
|
||||
accessible_class->widget_unset = gtk_tree_view_accessible_widget_unset;
|
||||
|
||||
gobject_class->finalize = gtk_tree_view_accessible_finalize;
|
||||
@@ -507,7 +496,6 @@ gtk_tree_view_accessible_class_init (GtkTreeViewAccessibleClass *klass)
|
||||
static void
|
||||
gtk_tree_view_accessible_init (GtkTreeViewAccessible *view)
|
||||
{
|
||||
view->priv = gtk_tree_view_accessible_get_instance_private (view);
|
||||
}
|
||||
|
||||
/* atkcomponent.h */
|
||||
@@ -1499,27 +1487,28 @@ cell_info_get_index (GtkTreeView *tree_view,
|
||||
}
|
||||
|
||||
static void
|
||||
cell_info_new (GtkTreeViewAccessible *accessible,
|
||||
cell_info_new (GtkTreeViewAccessible *self,
|
||||
GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node,
|
||||
GtkTreeViewColumn *tv_col,
|
||||
GtkCellAccessible *cell)
|
||||
{
|
||||
GtkTreeViewAccessiblePrivate *priv = gtk_tree_view_accessible_get_instance_private (self);
|
||||
GtkTreeViewAccessibleCellInfo *cell_info;
|
||||
|
||||
cell_info = g_new (GtkTreeViewAccessibleCellInfo, 1);
|
||||
|
||||
cell_info->view = self;
|
||||
cell_info->tree = tree;
|
||||
cell_info->node = node;
|
||||
cell_info->cell_col_ref = tv_col;
|
||||
cell_info->cell = cell;
|
||||
cell_info->view = accessible;
|
||||
|
||||
g_object_set_qdata (G_OBJECT (cell),
|
||||
gtk_tree_view_accessible_get_data_quark (),
|
||||
cell_info);
|
||||
|
||||
g_hash_table_replace (accessible->priv->cell_infos, cell_info, cell_info);
|
||||
g_hash_table_replace (priv->cell_infos, cell_info, cell_info);
|
||||
}
|
||||
|
||||
/* Returns the column number of the specified GtkTreeViewColumn
|
||||
@@ -1668,12 +1657,15 @@ _gtk_tree_view_accessible_remove (GtkTreeView *treeview,
|
||||
GtkTreeViewAccessibleCellInfo *cell_info;
|
||||
GHashTableIter iter;
|
||||
GtkTreeViewAccessible *accessible;
|
||||
GtkTreeViewAccessiblePrivate *priv;
|
||||
guint row, n_rows, n_cols, i;
|
||||
|
||||
accessible = GTK_TREE_VIEW_ACCESSIBLE (_gtk_widget_peek_accessible (GTK_WIDGET (treeview)));
|
||||
if (accessible == NULL)
|
||||
return;
|
||||
|
||||
priv = gtk_tree_view_accessible_get_instance_private (accessible);
|
||||
|
||||
/* if this shows up in profiles, special-case node->children == NULL */
|
||||
|
||||
if (node == NULL)
|
||||
@@ -1700,7 +1692,7 @@ _gtk_tree_view_accessible_remove (GtkTreeView *treeview,
|
||||
g_signal_emit_by_name (accessible, "children-changed::remove", i, NULL, NULL);
|
||||
}
|
||||
|
||||
g_hash_table_iter_init (&iter, accessible->priv->cell_infos);
|
||||
g_hash_table_iter_init (&iter, priv->cell_infos);
|
||||
while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&cell_info))
|
||||
{
|
||||
if (node == cell_info->node ||
|
||||
@@ -1805,18 +1797,19 @@ _gtk_tree_view_accessible_add_column (GtkTreeView *treeview,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_tree_view_accessible_do_remove_column (GtkTreeViewAccessible *accessible,
|
||||
gtk_tree_view_accessible_do_remove_column (GtkTreeViewAccessible *self,
|
||||
GtkTreeView *treeview,
|
||||
GtkTreeViewColumn *column,
|
||||
guint id)
|
||||
{
|
||||
GtkTreeViewAccessiblePrivate *priv = gtk_tree_view_accessible_get_instance_private (self);
|
||||
GtkTreeViewAccessibleCellInfo *cell_info;
|
||||
GHashTableIter iter;
|
||||
gpointer value;
|
||||
guint row, n_rows, n_cols;
|
||||
|
||||
/* Clean column from cache */
|
||||
g_hash_table_iter_init (&iter, accessible->priv->cell_infos);
|
||||
g_hash_table_iter_init (&iter, priv->cell_infos);
|
||||
while (g_hash_table_iter_next (&iter, NULL, &value))
|
||||
{
|
||||
cell_info = value;
|
||||
@@ -1825,7 +1818,7 @@ gtk_tree_view_accessible_do_remove_column (GtkTreeViewAccessible *accessible,
|
||||
}
|
||||
|
||||
/* Generate column-deleted signal */
|
||||
g_signal_emit_by_name (accessible, "column-deleted", id, 1);
|
||||
g_signal_emit_by_name (self, "column-deleted", id, 1);
|
||||
|
||||
n_rows = get_n_rows (treeview);
|
||||
n_cols = get_n_columns (treeview);
|
||||
@@ -1834,7 +1827,7 @@ gtk_tree_view_accessible_do_remove_column (GtkTreeViewAccessible *accessible,
|
||||
for (row = 0; row <= n_rows; row++)
|
||||
{
|
||||
/* Pass NULL as the child object, 4th argument */
|
||||
g_signal_emit_by_name (accessible, "children-changed::remove",
|
||||
g_signal_emit_by_name (self, "children-changed::remove",
|
||||
(row * n_cols) + id, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
@@ -35,13 +35,10 @@ G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GtkTreeViewAccessible GtkTreeViewAccessible;
|
||||
typedef struct _GtkTreeViewAccessibleClass GtkTreeViewAccessibleClass;
|
||||
typedef struct _GtkTreeViewAccessiblePrivate GtkTreeViewAccessiblePrivate;
|
||||
|
||||
struct _GtkTreeViewAccessible
|
||||
{
|
||||
GtkWidgetAccessible parent;
|
||||
|
||||
GtkTreeViewAccessiblePrivate *priv;
|
||||
};
|
||||
|
||||
struct _GtkTreeViewAccessibleClass
|
||||
|
@@ -60,6 +60,9 @@ void _gtk_tree_view_accessible_remove_state (GtkTreeView *tree
|
||||
GtkTreeRBNode *node,
|
||||
GtkCellRendererState state);
|
||||
|
||||
void gtk_tree_view_accessible_update_model (GtkTreeViewAccessible *self,
|
||||
GtkTreeModel *model);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_TREE_VIEW_ACCESSIBLE_PRIVATE_H__ */
|
||||
|
@@ -17,20 +17,43 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "gtkwidgetaccessibleprivate.h"
|
||||
#include "gtknotebookpageaccessible.h"
|
||||
|
||||
struct _GtkWidgetAccessiblePrivate
|
||||
#include "gtkaccellabel.h"
|
||||
#include "gtkadjustment.h"
|
||||
#include "gtkbox.h"
|
||||
#include "gtkbutton.h"
|
||||
#include "gtkcombobox.h"
|
||||
#include "gtkdragicon.h"
|
||||
#include "gtkdrawingarea.h"
|
||||
#include "gtkglarea.h"
|
||||
#include "gtkimage.h"
|
||||
#include "gtklevelbar.h"
|
||||
#include "gtkmediacontrols.h"
|
||||
#include "gtknotebookpageaccessible.h"
|
||||
#include "gtknotebook.h"
|
||||
#include "gtkorientable.h"
|
||||
#include "gtkpicture.h"
|
||||
#include "gtkprogressbar.h"
|
||||
#include "gtkscrollable.h"
|
||||
#include "gtkscrollbar.h"
|
||||
#include "gtkseparator.h"
|
||||
#include "gtkshortcutlabel.h"
|
||||
#include "gtkshortcutsshortcut.h"
|
||||
#include "gtkspinner.h"
|
||||
#include "gtkstacksidebar.h"
|
||||
#include "gtkstatusbar.h"
|
||||
#include "gtkvideo.h"
|
||||
#include "gtkviewport.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
AtkLayer layer;
|
||||
};
|
||||
|
||||
#define TOOLTIP_KEY "tooltip"
|
||||
} GtkWidgetAccessiblePrivate;
|
||||
|
||||
extern GtkWidget *_focus_widget;
|
||||
|
||||
|
||||
static gboolean gtk_widget_accessible_on_screen (GtkWidget *widget);
|
||||
static gboolean gtk_widget_accessible_all_parents_visible (GtkWidget *widget);
|
||||
|
||||
@@ -40,20 +63,6 @@ G_DEFINE_TYPE_WITH_CODE (GtkWidgetAccessible, gtk_widget_accessible, GTK_TYPE_AC
|
||||
G_ADD_PRIVATE (GtkWidgetAccessible)
|
||||
G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, atk_component_interface_init))
|
||||
|
||||
/* Translate GtkWidget property change notification to the notify_gtk vfunc */
|
||||
static void
|
||||
notify_cb (GObject *obj,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkWidgetAccessible *widget;
|
||||
GtkWidgetAccessibleClass *klass;
|
||||
|
||||
widget = GTK_WIDGET_ACCESSIBLE (gtk_widget_get_accessible (GTK_WIDGET (obj)));
|
||||
klass = GTK_WIDGET_ACCESSIBLE_GET_CLASS (widget);
|
||||
if (klass->notify_gtk)
|
||||
klass->notify_gtk (obj, pspec);
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gtk_widget_accessible_update_bounds:
|
||||
* @self: a #GtkWidgetAccessible
|
||||
@@ -78,47 +87,128 @@ gtk_widget_accessible_update_bounds (GtkWidgetAccessible *self)
|
||||
g_signal_emit_by_name (self, "bounds-changed", &rect);
|
||||
}
|
||||
|
||||
/* Translate GtkWidget mapped state into AtkObject showing */
|
||||
static gint
|
||||
map_cb (GtkWidget *widget)
|
||||
/*< private >
|
||||
* gtk_widget_accessible_notify_showing:
|
||||
* @self: a #GtkWidgetAccessible
|
||||
*
|
||||
* Translates the #GtkWidget mapped state into the #AtkObject
|
||||
* showing state.
|
||||
*/
|
||||
void
|
||||
gtk_widget_accessible_notify_showing (GtkWidgetAccessible *self)
|
||||
{
|
||||
AtkObject *accessible;
|
||||
g_return_if_fail (GTK_IS_WIDGET_ACCESSIBLE (self));
|
||||
|
||||
accessible = gtk_widget_get_accessible (widget);
|
||||
atk_object_notify_state_change (accessible, ATK_STATE_SHOWING,
|
||||
GtkWidget *widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (self));
|
||||
|
||||
atk_object_notify_state_change (ATK_OBJECT (self),
|
||||
ATK_STATE_SHOWING,
|
||||
gtk_widget_get_mapped (widget));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_widget_accessible_update_tooltip (GtkWidgetAccessible *accessible,
|
||||
GtkWidget *widget)
|
||||
void
|
||||
gtk_widget_accessible_notify_tooltip (GtkWidgetAccessible *self)
|
||||
{
|
||||
g_object_set_data_full (G_OBJECT (accessible),
|
||||
TOOLTIP_KEY,
|
||||
gtk_widget_get_tooltip_text (widget),
|
||||
g_free);
|
||||
g_return_if_fail (GTK_IS_WIDGET_ACCESSIBLE (self));
|
||||
|
||||
GtkWidget *widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (self));
|
||||
|
||||
atk_object_notify_state_change (ATK_OBJECT (self),
|
||||
ATK_STATE_HAS_TOOLTIP,
|
||||
gtk_widget_get_has_tooltip (widget));
|
||||
}
|
||||
|
||||
void
|
||||
gtk_widget_accessible_notify_visible (GtkWidgetAccessible *self)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_WIDGET_ACCESSIBLE (self));
|
||||
|
||||
GtkWidget *widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (self));
|
||||
|
||||
atk_object_notify_state_change (ATK_OBJECT (self),
|
||||
ATK_STATE_VISIBLE,
|
||||
gtk_widget_get_visible (widget));
|
||||
}
|
||||
|
||||
void
|
||||
gtk_widget_accessible_notify_sensitive (GtkWidgetAccessible *self)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_WIDGET_ACCESSIBLE (self));
|
||||
|
||||
GtkWidget *widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (self));
|
||||
gboolean is_sensitive = gtk_widget_get_sensitive (widget);
|
||||
|
||||
atk_object_notify_state_change (ATK_OBJECT (self),
|
||||
ATK_STATE_SENSITIVE,
|
||||
is_sensitive);
|
||||
atk_object_notify_state_change (ATK_OBJECT (self),
|
||||
ATK_STATE_ENABLED,
|
||||
is_sensitive);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_widget_accessible_notify_focus (GtkWidgetAccessible *self)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_WIDGET_ACCESSIBLE (self));
|
||||
|
||||
GtkWidget *widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (self));
|
||||
|
||||
atk_object_notify_state_change (ATK_OBJECT (self),
|
||||
ATK_STATE_FOCUSED,
|
||||
gtk_widget_has_focus (widget));
|
||||
}
|
||||
|
||||
void
|
||||
gtk_widget_accessible_notify_orientation (GtkWidgetAccessible *self)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_WIDGET_ACCESSIBLE (self));
|
||||
|
||||
GtkWidget *widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (self));
|
||||
|
||||
if (GTK_IS_ORIENTABLE (widget))
|
||||
{
|
||||
GtkOrientable *orientable = GTK_ORIENTABLE (widget);
|
||||
GtkOrientation orientation = gtk_orientable_get_orientation (orientable);
|
||||
|
||||
atk_object_notify_state_change (ATK_OBJECT (self),
|
||||
ATK_STATE_HORIZONTAL,
|
||||
orientation == GTK_ORIENTATION_HORIZONTAL);
|
||||
atk_object_notify_state_change (ATK_OBJECT (self),
|
||||
ATK_STATE_VERTICAL,
|
||||
orientation == GTK_ORIENTATION_VERTICAL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_widget_accessible_initialize (AtkObject *obj,
|
||||
notify_cb (GObject *gobject,
|
||||
GParamSpec *pspec,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (gobject);
|
||||
GtkWidgetAccessible *self = user_data;
|
||||
|
||||
GTK_WIDGET_ACCESSIBLE_GET_CLASS (self)->notify_gtk (G_OBJECT (widget), pspec);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_widget_accessible_initialize (AtkObject *object,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GtkWidgetAccessible *self = GTK_WIDGET_ACCESSIBLE (object);
|
||||
GtkWidgetAccessiblePrivate *priv = gtk_widget_accessible_get_instance_private (self);
|
||||
GtkWidget *widget = data;
|
||||
|
||||
widget = GTK_WIDGET (data);
|
||||
priv->layer = ATK_LAYER_WIDGET;
|
||||
|
||||
g_signal_connect (widget, "notify", G_CALLBACK (notify_cb), NULL);
|
||||
g_signal_connect (widget, "map", G_CALLBACK (map_cb), NULL);
|
||||
g_signal_connect (widget, "unmap", G_CALLBACK (map_cb), NULL);
|
||||
atk_object_set_role (object, ATK_ROLE_UNKNOWN);
|
||||
|
||||
GTK_WIDGET_ACCESSIBLE (obj)->priv->layer = ATK_LAYER_WIDGET;
|
||||
obj->role = ATK_ROLE_UNKNOWN;
|
||||
|
||||
gtk_widget_accessible_update_tooltip (GTK_WIDGET_ACCESSIBLE (obj), widget);
|
||||
/* XXX: This will go away once we move all GtkWidgetAccessibleClass.notify_gtk()
|
||||
* implementations to explicit API on their respective classes
|
||||
*/
|
||||
g_signal_connect (widget, "notify", G_CALLBACK (notify_cb), self);
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
static const char *
|
||||
gtk_widget_accessible_get_description (AtkObject *accessible)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
@@ -127,10 +217,10 @@ gtk_widget_accessible_get_description (AtkObject *accessible)
|
||||
if (widget == NULL)
|
||||
return NULL;
|
||||
|
||||
if (accessible->description)
|
||||
if (accessible->description != NULL)
|
||||
return accessible->description;
|
||||
|
||||
return g_object_get_data (G_OBJECT (accessible), TOOLTIP_KEY);
|
||||
return gtk_widget_get_tooltip_text (widget);
|
||||
}
|
||||
|
||||
static AtkObject *
|
||||
@@ -446,72 +536,6 @@ gtk_widget_accessible_get_index_in_parent (AtkObject *accessible)
|
||||
return index;
|
||||
}
|
||||
|
||||
/* This function is the default implementation for the notify_gtk
|
||||
* vfunc which gets called when a property changes value on the
|
||||
* GtkWidget associated with a GtkWidgetAccessible. It constructs
|
||||
* an AtkPropertyValues structure and emits a “property_changed”
|
||||
* signal which causes the user specified AtkPropertyChangeHandler
|
||||
* to be called.
|
||||
*/
|
||||
static void
|
||||
gtk_widget_accessible_notify_gtk (GObject *obj,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkWidget* widget = GTK_WIDGET (obj);
|
||||
AtkObject* atk_obj = gtk_widget_get_accessible (widget);
|
||||
AtkState state;
|
||||
gboolean value;
|
||||
|
||||
if (g_strcmp0 (pspec->name, "has-focus") == 0)
|
||||
{
|
||||
state = ATK_STATE_FOCUSED;
|
||||
value = gtk_widget_has_focus (widget);
|
||||
}
|
||||
else if (g_strcmp0 (pspec->name, "tooltip-text") == 0)
|
||||
{
|
||||
gtk_widget_accessible_update_tooltip (GTK_WIDGET_ACCESSIBLE (atk_obj),
|
||||
widget);
|
||||
|
||||
if (atk_obj->description == NULL)
|
||||
g_object_notify (G_OBJECT (atk_obj), "accessible-description");
|
||||
return;
|
||||
}
|
||||
else if (g_strcmp0 (pspec->name, "visible") == 0)
|
||||
{
|
||||
state = ATK_STATE_VISIBLE;
|
||||
value = gtk_widget_get_visible (widget);
|
||||
}
|
||||
else if (g_strcmp0 (pspec->name, "sensitive") == 0)
|
||||
{
|
||||
state = ATK_STATE_SENSITIVE;
|
||||
value = gtk_widget_get_sensitive (widget);
|
||||
}
|
||||
else if (g_strcmp0 (pspec->name, "orientation") == 0 &&
|
||||
GTK_IS_ORIENTABLE (widget))
|
||||
{
|
||||
GtkOrientable *orientable;
|
||||
|
||||
orientable = GTK_ORIENTABLE (widget);
|
||||
|
||||
state = ATK_STATE_HORIZONTAL;
|
||||
value = (gtk_orientable_get_orientation (orientable) == GTK_ORIENTATION_HORIZONTAL);
|
||||
}
|
||||
else if (g_strcmp0 (pspec->name, "has-tooltip") == 0)
|
||||
{
|
||||
state = ATK_STATE_HAS_TOOLTIP;
|
||||
value = gtk_widget_get_has_tooltip (widget);
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
atk_object_notify_state_change (atk_obj, state, value);
|
||||
if (state == ATK_STATE_SENSITIVE)
|
||||
atk_object_notify_state_change (atk_obj, ATK_STATE_ENABLED, value);
|
||||
|
||||
if (state == ATK_STATE_HORIZONTAL)
|
||||
atk_object_notify_state_change (atk_obj, ATK_STATE_VERTICAL, !value);
|
||||
}
|
||||
|
||||
static AtkAttributeSet *
|
||||
gtk_widget_accessible_get_attributes (AtkObject *obj)
|
||||
{
|
||||
@@ -527,6 +551,13 @@ gtk_widget_accessible_get_attributes (AtkObject *obj)
|
||||
return attributes;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_widget_accessible_notify_gtk (GObject *gobject,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
/* Empty, used to chain up safely */
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_widget_accessible_class_init (GtkWidgetAccessibleClass *klass)
|
||||
{
|
||||
@@ -546,7 +577,6 @@ gtk_widget_accessible_class_init (GtkWidgetAccessibleClass *klass)
|
||||
static void
|
||||
gtk_widget_accessible_init (GtkWidgetAccessible *accessible)
|
||||
{
|
||||
accessible->priv = gtk_widget_accessible_get_instance_private (accessible);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -589,9 +619,10 @@ gtk_widget_accessible_get_extents (AtkComponent *component,
|
||||
static AtkLayer
|
||||
gtk_widget_accessible_get_layer (AtkComponent *component)
|
||||
{
|
||||
GtkWidgetAccessible *accessible = GTK_WIDGET_ACCESSIBLE (component);
|
||||
GtkWidgetAccessible *self = GTK_WIDGET_ACCESSIBLE (component);
|
||||
GtkWidgetAccessiblePrivate *priv = gtk_widget_accessible_get_instance_private (self);
|
||||
|
||||
return accessible->priv->layer;
|
||||
return priv->layer;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -723,10 +754,11 @@ gtk_widget_accessible_all_parents_visible (GtkWidget *widget)
|
||||
GtkWidget *iter_parent = NULL;
|
||||
gboolean result = TRUE;
|
||||
|
||||
for (iter_parent = gtk_widget_get_parent (widget); iter_parent;
|
||||
iter_parent = gtk_widget_get_parent (iter_parent))
|
||||
for (iter_parent = _gtk_widget_get_parent (widget);
|
||||
iter_parent != NULL;
|
||||
iter_parent = _gtk_widget_get_parent (iter_parent))
|
||||
{
|
||||
if (!gtk_widget_get_visible (iter_parent))
|
||||
if (!_gtk_widget_get_visible (iter_parent))
|
||||
{
|
||||
result = FALSE;
|
||||
break;
|
||||
@@ -737,8 +769,10 @@ gtk_widget_accessible_all_parents_visible (GtkWidget *widget)
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_widget_accessible_set_layer (GtkWidgetAccessible *accessible,
|
||||
_gtk_widget_accessible_set_layer (GtkWidgetAccessible *self,
|
||||
AtkLayer layer)
|
||||
{
|
||||
accessible->priv->layer = layer;
|
||||
GtkWidgetAccessiblePrivate *priv = gtk_widget_accessible_get_instance_private (self);
|
||||
|
||||
priv->layer = layer;
|
||||
}
|
||||
|
@@ -26,25 +26,10 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_WIDGET_ACCESSIBLE (gtk_widget_accessible_get_type ())
|
||||
#define GTK_WIDGET_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_WIDGET_ACCESSIBLE, GtkWidgetAccessible))
|
||||
#define GTK_WIDGET_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_WIDGET_ACCESSIBLE, GtkWidgetAccessibleClass))
|
||||
#define GTK_IS_WIDGET_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_WIDGET_ACCESSIBLE))
|
||||
#define GTK_IS_WIDGET_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_WIDGET_ACCESSIBLE))
|
||||
#define GTK_WIDGET_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_WIDGET_ACCESSIBLE, GtkWidgetAccessibleClass))
|
||||
#define GTK_TYPE_WIDGET_ACCESSIBLE (gtk_widget_accessible_get_type())
|
||||
|
||||
typedef struct _GtkWidgetAccessible GtkWidgetAccessible;
|
||||
typedef struct _GtkWidgetAccessibleClass GtkWidgetAccessibleClass;
|
||||
typedef struct _GtkWidgetAccessiblePrivate GtkWidgetAccessiblePrivate;
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkWidgetAccessible, g_object_unref)
|
||||
|
||||
struct _GtkWidgetAccessible
|
||||
{
|
||||
GtkAccessible parent;
|
||||
|
||||
GtkWidgetAccessiblePrivate *priv;
|
||||
};
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
G_DECLARE_DERIVABLE_TYPE (GtkWidgetAccessible, gtk_widget_accessible, GTK, WIDGET_ACCESSIBLE, GtkAccessible)
|
||||
|
||||
struct _GtkWidgetAccessibleClass
|
||||
{
|
||||
@@ -58,9 +43,6 @@ struct _GtkWidgetAccessibleClass
|
||||
|
||||
};
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_widget_accessible_get_type (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_WIDGET_ACCESSIBLE_H__ */
|
||||
|
@@ -25,7 +25,19 @@ G_BEGIN_DECLS
|
||||
void _gtk_widget_accessible_set_layer (GtkWidgetAccessible *accessible,
|
||||
AtkLayer layer);
|
||||
|
||||
void gtk_widget_accessible_update_bounds (GtkWidgetAccessible *self);
|
||||
void gtk_widget_accessible_update_bounds (GtkWidgetAccessible *self);
|
||||
|
||||
void gtk_widget_accessible_notify_showing (GtkWidgetAccessible *self);
|
||||
|
||||
void gtk_widget_accessible_notify_tooltip (GtkWidgetAccessible *self);
|
||||
|
||||
void gtk_widget_accessible_notify_visible (GtkWidgetAccessible *self);
|
||||
|
||||
void gtk_widget_accessible_notify_sensitive (GtkWidgetAccessible *self);
|
||||
|
||||
void gtk_widget_accessible_notify_focus (GtkWidgetAccessible *self);
|
||||
|
||||
void gtk_widget_accessible_notify_orientation (GtkWidgetAccessible *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@@ -21,7 +21,6 @@
|
||||
|
||||
#ifndef __GI_SCANNER__
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkAccessible, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkActionBar, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkActionable, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkAdjustment, g_object_unref)
|
||||
|
@@ -1,5 +1,6 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright 2001 Sun Microsystems Inc.
|
||||
* Copyright 2020 GNOME Foundation
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -40,12 +41,13 @@
|
||||
* in #GtkWidgetClass.
|
||||
*/
|
||||
|
||||
struct _GtkAccessiblePrivate
|
||||
typedef struct
|
||||
{
|
||||
GtkWidget *widget;
|
||||
};
|
||||
} GtkAccessiblePrivate;
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_WIDGET
|
||||
};
|
||||
@@ -78,7 +80,7 @@ gtk_accessible_get_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkAccessible *accessible = GTK_ACCESSIBLE (object);
|
||||
GtkAccessiblePrivate *priv = accessible->priv;
|
||||
GtkAccessiblePrivate *priv = gtk_accessible_get_instance_private (accessible);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
@@ -94,18 +96,18 @@ gtk_accessible_get_property (GObject *object,
|
||||
static void
|
||||
gtk_accessible_init (GtkAccessible *accessible)
|
||||
{
|
||||
accessible->priv = gtk_accessible_get_instance_private (accessible);
|
||||
}
|
||||
|
||||
static AtkStateSet *
|
||||
gtk_accessible_ref_state_set (AtkObject *object)
|
||||
{
|
||||
GtkAccessible *accessible = GTK_ACCESSIBLE (object);
|
||||
GtkAccessiblePrivate *priv = gtk_accessible_get_instance_private (accessible);
|
||||
AtkStateSet *state_set;
|
||||
|
||||
state_set = ATK_OBJECT_CLASS (gtk_accessible_parent_class)->ref_state_set (object);
|
||||
|
||||
if (accessible->priv->widget == NULL)
|
||||
if (priv->widget == NULL)
|
||||
atk_state_set_add_state (state_set, ATK_STATE_DEFUNCT);
|
||||
|
||||
return state_set;
|
||||
@@ -172,23 +174,20 @@ void
|
||||
gtk_accessible_set_widget (GtkAccessible *accessible,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GtkAccessiblePrivate *priv;
|
||||
GtkAccessiblePrivate *priv = gtk_accessible_get_instance_private (accessible);
|
||||
GtkAccessibleClass *klass;
|
||||
|
||||
g_return_if_fail (GTK_IS_ACCESSIBLE (accessible));
|
||||
|
||||
priv = accessible->priv;
|
||||
klass = GTK_ACCESSIBLE_GET_CLASS (accessible);
|
||||
|
||||
if (priv->widget == widget)
|
||||
return;
|
||||
|
||||
klass = GTK_ACCESSIBLE_GET_CLASS (accessible);
|
||||
if (priv->widget)
|
||||
klass->widget_unset (accessible);
|
||||
|
||||
priv->widget = widget;
|
||||
|
||||
if (widget)
|
||||
if (priv->widget)
|
||||
klass->widget_set (accessible);
|
||||
|
||||
g_object_notify (G_OBJECT (accessible), "widget");
|
||||
@@ -208,8 +207,9 @@ gtk_accessible_set_widget (GtkAccessible *accessible,
|
||||
GtkWidget*
|
||||
gtk_accessible_get_widget (GtkAccessible *accessible)
|
||||
{
|
||||
GtkAccessiblePrivate *priv = gtk_accessible_get_instance_private (accessible);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_ACCESSIBLE (accessible), NULL);
|
||||
|
||||
return accessible->priv->widget;
|
||||
return priv->widget;
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,6 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright 2001 Sun Microsystems Inc.
|
||||
* Copyright 2020 GNOME Foundation
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
@@ -28,37 +29,23 @@
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_ACCESSIBLE (gtk_accessible_get_type ())
|
||||
#define GTK_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ACCESSIBLE, GtkAccessible))
|
||||
#define GTK_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ACCESSIBLE, GtkAccessibleClass))
|
||||
#define GTK_IS_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ACCESSIBLE))
|
||||
#define GTK_IS_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ACCESSIBLE))
|
||||
#define GTK_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ACCESSIBLE, GtkAccessibleClass))
|
||||
|
||||
typedef struct _GtkAccessible GtkAccessible;
|
||||
typedef struct _GtkAccessiblePrivate GtkAccessiblePrivate;
|
||||
typedef struct _GtkAccessibleClass GtkAccessibleClass;
|
||||
#if !ATK_CHECK_VERSION(2, 37, 0)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(AtkObject, g_object_unref)
|
||||
#endif
|
||||
|
||||
struct _GtkAccessible
|
||||
{
|
||||
AtkObject parent;
|
||||
|
||||
/*< private >*/
|
||||
GtkAccessiblePrivate *priv;
|
||||
};
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
G_DECLARE_DERIVABLE_TYPE (GtkAccessible, gtk_accessible, GTK, ACCESSIBLE, AtkObject)
|
||||
|
||||
struct _GtkAccessibleClass
|
||||
{
|
||||
AtkObjectClass parent_class;
|
||||
|
||||
void (*widget_set) (GtkAccessible *accessible);
|
||||
void (*widget_unset) (GtkAccessible *accessible);
|
||||
/* Padding for future expansion */
|
||||
void (*_gtk_reserved3) (void);
|
||||
void (*_gtk_reserved4) (void);
|
||||
};
|
||||
void (* widget_set) (GtkAccessible *accessible);
|
||||
void (* widget_unset) (GtkAccessible *accessible);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_accessible_get_type (void) G_GNUC_CONST;
|
||||
gpointer _padding[8];
|
||||
};
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_accessible_set_widget (GtkAccessible *accessible,
|
||||
@@ -69,5 +56,3 @@ GtkWidget *gtk_accessible_get_widget (GtkAccessible *accessible);
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_ACCESSIBLE_H__ */
|
||||
|
||||
|
||||
|
@@ -61,7 +61,6 @@
|
||||
#include "gtkcsspositionvalueprivate.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkorientable.h"
|
||||
#include "gtkorientableprivate.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtksizerequest.h"
|
||||
@@ -120,7 +119,7 @@ gtk_box_set_property (GObject *object,
|
||||
priv->orientation = orientation;
|
||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (box_layout),
|
||||
priv->orientation);
|
||||
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (box));
|
||||
gtk_widget_update_orientation (GTK_WIDGET (box), priv->orientation);
|
||||
g_object_notify (object, "orientation");
|
||||
}
|
||||
}
|
||||
@@ -288,7 +287,7 @@ gtk_box_init (GtkBox *box)
|
||||
GtkBoxPrivate *priv = gtk_box_get_instance_private (box);
|
||||
|
||||
priv->orientation = GTK_ORIENTATION_HORIZONTAL;
|
||||
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (box));
|
||||
gtk_widget_update_orientation (GTK_WIDGET (box), priv->orientation);
|
||||
}
|
||||
|
||||
static GtkBuildableIface *parent_buildable_iface;
|
||||
|
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "gtkcsspositionvalueprivate.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkorientableprivate.h"
|
||||
#include "gtkorientable.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtksizerequest.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
@@ -89,7 +89,7 @@ gtk_box_layout_set_orientation (GtkBoxLayout *self,
|
||||
|
||||
widget = gtk_layout_manager_get_widget (layout_manager);
|
||||
if (widget != NULL && GTK_IS_ORIENTABLE (widget))
|
||||
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (widget));
|
||||
gtk_widget_update_orientation (widget, self->orientation);
|
||||
|
||||
gtk_layout_manager_layout_changed (layout_manager);
|
||||
|
||||
|
@@ -836,6 +836,15 @@ gtk_button_set_label (GtkButton *button,
|
||||
|
||||
gtk_label_set_label (GTK_LABEL (priv->child), label);
|
||||
gtk_button_set_child_type (button, LABEL_CHILD);
|
||||
|
||||
{
|
||||
GtkButtonAccessible *accessible =
|
||||
GTK_BUTTON_ACCESSIBLE (_gtk_widget_peek_accessible (GTK_WIDGET (button)));
|
||||
|
||||
if (accessible != NULL)
|
||||
gtk_button_accessible_update_label (accessible);
|
||||
}
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (button), props[PROP_LABEL]);
|
||||
}
|
||||
|
||||
|
@@ -16,19 +16,22 @@
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <string.h>
|
||||
|
||||
#include "gtkcellview.h"
|
||||
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkcelllayout.h"
|
||||
#include "gtkcellareabox.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkcellrenderertext.h"
|
||||
#include "gtkcellrendererpixbuf.h"
|
||||
#include "gtkcellrenderertext.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkorientable.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkorientableprivate.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include <gobject/gmarshal.h>
|
||||
#include "gtkbuildable.h"
|
||||
|
||||
#include <gobject/gmarshal.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
* SECTION:gtkcellview
|
||||
@@ -385,7 +388,7 @@ gtk_cell_view_set_property (GObject *object,
|
||||
priv->orientation = g_value_get_enum (value);
|
||||
if (priv->context)
|
||||
gtk_cell_area_context_reset (priv->context);
|
||||
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (object));
|
||||
gtk_widget_update_orientation (GTK_WIDGET (object), priv->orientation);
|
||||
g_object_notify_by_pspec (object, pspec);
|
||||
}
|
||||
break;
|
||||
|
@@ -58,7 +58,6 @@
|
||||
#include "gtkcssnodeprivate.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkorientable.h"
|
||||
#include "gtkorientableprivate.h"
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtksizerequest.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
@@ -140,7 +139,7 @@ gtk_center_box_set_property (GObject *object,
|
||||
if (current != orientation)
|
||||
{
|
||||
gtk_center_layout_set_orientation (GTK_CENTER_LAYOUT (layout), orientation);
|
||||
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (self));
|
||||
gtk_widget_update_orientation (GTK_WIDGET (self), orientation);
|
||||
gtk_widget_queue_resize (GTK_WIDGET (self));
|
||||
g_object_notify (object, "orientation");
|
||||
}
|
||||
|
@@ -2939,7 +2939,7 @@ static void
|
||||
ensure_has_tooltip (GtkEntry *entry)
|
||||
{
|
||||
GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
|
||||
gchar *text = gtk_widget_get_tooltip_text (GTK_WIDGET (entry));
|
||||
const char *text = gtk_widget_get_tooltip_text (GTK_WIDGET (entry));
|
||||
gboolean has_tooltip = text != NULL;
|
||||
|
||||
if (!has_tooltip)
|
||||
@@ -2957,10 +2957,6 @@ ensure_has_tooltip (GtkEntry *entry)
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
gtk_widget_set_has_tooltip (GTK_WIDGET (entry), has_tooltip);
|
||||
}
|
||||
|
@@ -75,7 +75,6 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "gtkflowbox.h"
|
||||
#include "gtkflowboxprivate.h"
|
||||
|
||||
#include "gtkadjustment.h"
|
||||
@@ -83,13 +82,14 @@
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkcsscolorvalueprivate.h"
|
||||
#include "gtkcssnodeprivate.h"
|
||||
#include "gtkgesturedrag.h"
|
||||
#include "gtkeventcontrollerkey.h"
|
||||
#include "gtkgestureclick.h"
|
||||
#include "gtkgesturedrag.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkmain.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkorientable.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkorientableprivate.h"
|
||||
#include "gtkrender.h"
|
||||
#include "gtksizerequest.h"
|
||||
#include "gtksnapshot.h"
|
||||
@@ -97,7 +97,6 @@
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkviewport.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkeventcontrollerkey.h"
|
||||
|
||||
#include "a11y/gtkflowboxaccessibleprivate.h"
|
||||
#include "a11y/gtkflowboxchildaccessible.h"
|
||||
@@ -3417,14 +3416,20 @@ gtk_flow_box_set_property (GObject *object,
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_ORIENTATION:
|
||||
if (priv->orientation != g_value_get_enum (value))
|
||||
{
|
||||
priv->orientation = g_value_get_enum (value);
|
||||
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (box));
|
||||
/* Re-box the children in the new orientation */
|
||||
gtk_widget_queue_resize (GTK_WIDGET (box));
|
||||
g_object_notify_by_pspec (object, pspec);
|
||||
}
|
||||
{
|
||||
GtkOrientation orientation = g_value_get_enum (value);
|
||||
|
||||
if (priv->orientation != orientation)
|
||||
{
|
||||
priv->orientation = orientation;
|
||||
|
||||
gtk_widget_update_orientation (GTK_WIDGET (box), priv->orientation);
|
||||
|
||||
/* Re-box the children in the new orientation */
|
||||
gtk_widget_queue_resize (GTK_WIDGET (box));
|
||||
g_object_notify_by_pspec (object, pspec);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PROP_HOMOGENEOUS:
|
||||
gtk_flow_box_set_homogeneous (box, g_value_get_boolean (value));
|
||||
@@ -3866,7 +3871,7 @@ gtk_flow_box_init (GtkFlowBox *box)
|
||||
priv->row_spacing = 0;
|
||||
priv->activate_on_single_click = TRUE;
|
||||
|
||||
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (box));
|
||||
gtk_widget_update_orientation (GTK_WIDGET (box), priv->orientation);
|
||||
|
||||
priv->children = g_sequence_new (NULL);
|
||||
|
||||
|
@@ -25,8 +25,8 @@
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkcsspositionvalueprivate.h"
|
||||
#include "gtkgridlayout.h"
|
||||
#include "gtkorientableprivate.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkorientable.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtksizerequest.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
@@ -135,7 +135,8 @@ gtk_grid_set_orientation (GtkGrid *grid,
|
||||
if (priv->orientation != orientation)
|
||||
{
|
||||
priv->orientation = orientation;
|
||||
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (grid));
|
||||
|
||||
gtk_widget_update_orientation (GTK_WIDGET (grid), priv->orientation);
|
||||
|
||||
g_object_notify (G_OBJECT (grid), "orientation");
|
||||
}
|
||||
@@ -435,7 +436,7 @@ gtk_grid_init (GtkGrid *grid)
|
||||
priv->layout_manager = gtk_widget_get_layout_manager (GTK_WIDGET (grid));
|
||||
|
||||
priv->orientation = GTK_ORIENTATION_HORIZONTAL;
|
||||
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (grid));
|
||||
gtk_widget_update_orientation (GTK_WIDGET (grid), priv->orientation);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -48,7 +48,7 @@
|
||||
#include "gtkdebug.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtklayoutchild.h"
|
||||
#include "gtkorientableprivate.h"
|
||||
#include "gtkorientable.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtksizerequest.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
|
@@ -2685,12 +2685,18 @@ static void
|
||||
gtk_icon_view_adjustment_changed (GtkAdjustment *adjustment,
|
||||
GtkIconView *icon_view)
|
||||
{
|
||||
if (gtk_widget_get_realized (GTK_WIDGET (icon_view)))
|
||||
GtkWidget *widget = GTK_WIDGET (icon_view);
|
||||
|
||||
if (gtk_widget_get_realized (widget))
|
||||
{
|
||||
GtkIconViewAccessible *accessible =
|
||||
GTK_ICON_VIEW_ACCESSIBLE (_gtk_widget_peek_accessible (GTK_WIDGET (icon_view)));
|
||||
|
||||
if (icon_view->priv->doing_rubberband)
|
||||
gtk_icon_view_update_rubberband (icon_view);
|
||||
|
||||
_gtk_icon_view_accessible_adjustment_changed (icon_view);
|
||||
if (accessible != NULL)
|
||||
gtk_icon_view_accessible_adjustment_changed (accessible);
|
||||
}
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (icon_view));
|
||||
@@ -4710,6 +4716,14 @@ gtk_icon_view_set_model (GtkIconView *icon_view,
|
||||
gtk_icon_view_build_items (icon_view);
|
||||
}
|
||||
|
||||
{
|
||||
GtkIconViewAccessible *accessible =
|
||||
GTK_ICON_VIEW_ACCESSIBLE (_gtk_widget_peek_accessible (GTK_WIDGET (icon_view)));
|
||||
|
||||
if (accessible != NULL)
|
||||
gtk_icon_view_accessible_update_model (accessible, icon_view->priv->model);
|
||||
}
|
||||
|
||||
g_object_notify (G_OBJECT (icon_view), "model");
|
||||
|
||||
if (dirty)
|
||||
|
@@ -122,18 +122,16 @@
|
||||
#include "gtkbinlayout.h"
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkbuilderprivate.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkorientableprivate.h"
|
||||
#include "gtklevelbar.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkstylecontext.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkwidget.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkcssstylepropertyprivate.h"
|
||||
#include "gtkcssnodeprivate.h"
|
||||
#include "gtkgizmoprivate.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtklevelbar.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkorientable.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
@@ -798,7 +796,7 @@ gtk_level_bar_set_orientation (GtkLevelBar *self,
|
||||
if (self->orientation != orientation)
|
||||
{
|
||||
self->orientation = orientation;
|
||||
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (self));
|
||||
gtk_widget_update_orientation (GTK_WIDGET (self), self->orientation);
|
||||
gtk_widget_queue_resize (GTK_WIDGET (self));
|
||||
g_object_notify (G_OBJECT (self), "orientation");
|
||||
}
|
||||
@@ -1014,7 +1012,7 @@ gtk_level_bar_init (GtkLevelBar *self)
|
||||
|
||||
/* set initial orientation and style classes */
|
||||
self->orientation = GTK_ORIENTATION_HORIZONTAL;
|
||||
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (self));
|
||||
gtk_widget_update_orientation (GTK_WIDGET (self), self->orientation);
|
||||
|
||||
self->inverted = FALSE;
|
||||
|
||||
|
@@ -591,7 +591,7 @@ gtk_link_button_query_tooltip_cb (GtkWidget *widget,
|
||||
{
|
||||
GtkLinkButton *link_button = GTK_LINK_BUTTON (widget);
|
||||
const gchar *label, *uri;
|
||||
gchar *text, *markup;
|
||||
const char *text, *markup;
|
||||
|
||||
label = gtk_button_get_label (GTK_BUTTON (link_button));
|
||||
uri = link_button->uri;
|
||||
@@ -606,9 +606,6 @@ gtk_link_button_query_tooltip_cb (GtkWidget *widget,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
g_free (text);
|
||||
g_free (markup);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@@ -21,9 +21,10 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkorientableprivate.h"
|
||||
#include "gtkorientable.h"
|
||||
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkstylecontext.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkintl.h"
|
||||
@@ -81,7 +82,7 @@ gtk_orientable_set_orientation (GtkOrientable *orientable,
|
||||
NULL);
|
||||
|
||||
if (GTK_IS_WIDGET (orientable))
|
||||
_gtk_orientable_set_style_classes (orientable);
|
||||
gtk_widget_update_orientation (GTK_WIDGET (orientable), orientation);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,25 +107,3 @@ gtk_orientable_get_orientation (GtkOrientable *orientable)
|
||||
|
||||
return orientation;
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_orientable_set_style_classes (GtkOrientable *orientable)
|
||||
{
|
||||
GtkOrientation orientation;
|
||||
|
||||
g_return_if_fail (GTK_IS_ORIENTABLE (orientable));
|
||||
g_return_if_fail (GTK_IS_WIDGET (orientable));
|
||||
|
||||
orientation = gtk_orientable_get_orientation (orientable);
|
||||
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
{
|
||||
gtk_widget_add_css_class (GTK_WIDGET (orientable), GTK_STYLE_CLASS_HORIZONTAL);
|
||||
gtk_widget_remove_css_class (GTK_WIDGET (orientable), GTK_STYLE_CLASS_VERTICAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_add_css_class (GTK_WIDGET (orientable), GTK_STYLE_CLASS_VERTICAL);
|
||||
gtk_widget_remove_css_class (GTK_WIDGET (orientable), GTK_STYLE_CLASS_HORIZONTAL);
|
||||
}
|
||||
}
|
||||
|
@@ -1,29 +0,0 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2011 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_ORIENTABLE_PRIVATE_H__
|
||||
#define __GTK_ORIENTABLE_PRIVATE_H__
|
||||
|
||||
#include "gtkorientable.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
void _gtk_orientable_set_style_classes (GtkOrientable *orientable);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_ORIENTABLE_H__ */
|
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "gtkpaned.h"
|
||||
|
||||
#include "gtkcssboxesprivate.h"
|
||||
#include "gtkcssnodeprivate.h"
|
||||
#include "gtkcssstylepropertyprivate.h"
|
||||
#include "gtkeventcontrollermotion.h"
|
||||
@@ -34,7 +35,7 @@
|
||||
#include "gtkgizmoprivate.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkorientableprivate.h"
|
||||
#include "gtkorientable.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkrendericonprivate.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
@@ -922,7 +923,7 @@ gtk_paned_set_property (GObject *object,
|
||||
if (paned->orientation != g_value_get_enum (value))
|
||||
{
|
||||
paned->orientation = g_value_get_enum (value);
|
||||
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (paned));
|
||||
gtk_widget_update_orientation (GTK_WIDGET (paned), paned->orientation);
|
||||
|
||||
if (paned->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
{
|
||||
@@ -1450,7 +1451,7 @@ gtk_paned_init (GtkPaned *paned)
|
||||
paned->shrink_start_child = TRUE;
|
||||
paned->shrink_end_child = TRUE;
|
||||
|
||||
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (paned));
|
||||
gtk_widget_update_orientation (GTK_WIDGET (paned), paned->orientation);
|
||||
|
||||
/* Touch gesture */
|
||||
gesture = gtk_gesture_pan_new (GTK_ORIENTATION_HORIZONTAL);
|
||||
|
@@ -26,18 +26,18 @@
|
||||
|
||||
#include "gtkprogressbar.h"
|
||||
|
||||
#include "gtkboxlayout.h"
|
||||
#include "gtkcssnodeprivate.h"
|
||||
#include "gtkcssnumbervalueprivate.h"
|
||||
#include "gtkcssstylepropertyprivate.h"
|
||||
#include "gtkgizmoprivate.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtklabel.h"
|
||||
#include "gtkorientableprivate.h"
|
||||
#include "gtkorientable.h"
|
||||
#include "gtkprogresstrackerprivate.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkboxlayout.h"
|
||||
|
||||
#include "a11y/gtkprogressbaraccessible.h"
|
||||
|
||||
@@ -459,7 +459,7 @@ gtk_progress_bar_init (GtkProgressBar *pbar)
|
||||
/* horizontal is default */
|
||||
pbar->orientation = GTK_ORIENTATION_VERTICAL; /* Just to force an update... */
|
||||
gtk_progress_bar_set_orientation (pbar, GTK_ORIENTATION_HORIZONTAL);
|
||||
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (pbar));
|
||||
gtk_widget_update_orientation (GTK_WIDGET (pbar), pbar->orientation);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -924,7 +924,7 @@ gtk_progress_bar_set_orientation (GtkProgressBar *pbar,
|
||||
gtk_widget_set_valign (pbar->trough_widget, GTK_ALIGN_FILL);
|
||||
}
|
||||
|
||||
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (pbar));
|
||||
gtk_widget_update_orientation (GTK_WIDGET (pbar), pbar->orientation);
|
||||
update_node_classes (pbar);
|
||||
|
||||
layout = GTK_BOX_LAYOUT (gtk_widget_get_layout_manager (GTK_WIDGET (pbar)));
|
||||
|
@@ -29,6 +29,7 @@
|
||||
|
||||
#include "gtkadjustmentprivate.h"
|
||||
#include "gtkcolorscaleprivate.h"
|
||||
#include "gtkeventcontrollerkey.h"
|
||||
#include "gtkeventcontrollerscroll.h"
|
||||
#include "gtkgesturedrag.h"
|
||||
#include "gtkgesturelongpressprivate.h"
|
||||
@@ -36,11 +37,11 @@
|
||||
#include "gtkgizmoprivate.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkorientableprivate.h"
|
||||
#include "gtkorientable.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkscale.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkeventcontrollerkey.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
|
||||
#include "a11y/gtkrangeaccessible.h"
|
||||
|
||||
@@ -458,7 +459,7 @@ gtk_range_set_property (GObject *object,
|
||||
if (priv->orientation != g_value_get_enum (value))
|
||||
{
|
||||
priv->orientation = g_value_get_enum (value);
|
||||
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (range));
|
||||
gtk_widget_update_orientation (GTK_WIDGET (range), priv->orientation);
|
||||
gtk_widget_queue_resize (GTK_WIDGET (range));
|
||||
g_object_notify_by_pspec (object, pspec);
|
||||
}
|
||||
@@ -542,7 +543,7 @@ gtk_range_init (GtkRange *range)
|
||||
priv->fill_level = G_MAXDOUBLE;
|
||||
priv->timer = NULL;
|
||||
|
||||
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (range));
|
||||
gtk_widget_update_orientation (GTK_WIDGET (range), priv->orientation);
|
||||
|
||||
priv->trough_widget = gtk_gizmo_new ("trough",
|
||||
gtk_range_measure_trough,
|
||||
@@ -672,6 +673,15 @@ gtk_range_set_adjustment (GtkRange *range,
|
||||
|
||||
gtk_range_adjustment_changed (adjustment, range);
|
||||
gtk_range_adjustment_value_changed (adjustment, range);
|
||||
|
||||
{
|
||||
GtkRangeAccessible *accessible =
|
||||
GTK_RANGE_ACCESSIBLE (_gtk_widget_peek_accessible (GTK_WIDGET (range)));
|
||||
|
||||
if (accessible != NULL)
|
||||
gtk_range_accessible_update_adjustment (accessible);
|
||||
}
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (range), properties[PROP_ADJUSTMENT]);
|
||||
}
|
||||
}
|
||||
|
@@ -31,7 +31,6 @@
|
||||
#include "gtkadjustment.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkorientable.h"
|
||||
#include "gtkorientableprivate.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkboxlayout.h"
|
||||
@@ -162,8 +161,7 @@ gtk_scrollbar_set_property (GObject *object,
|
||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (layout), orientation);
|
||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->range), orientation);
|
||||
priv->orientation = orientation;
|
||||
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (self));
|
||||
|
||||
gtk_widget_update_orientation (GTK_WIDGET (self), priv->orientation);
|
||||
gtk_widget_queue_resize (GTK_WIDGET (self));
|
||||
g_object_notify_by_pspec (object, pspec);
|
||||
}
|
||||
@@ -223,8 +221,7 @@ gtk_scrollbar_init (GtkScrollbar *self)
|
||||
gtk_widget_set_hexpand (priv->range, TRUE);
|
||||
gtk_widget_set_vexpand (priv->range, TRUE);
|
||||
gtk_widget_set_parent (priv->range, GTK_WIDGET (self));
|
||||
|
||||
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (self));
|
||||
gtk_widget_update_orientation (GTK_WIDGET (self), priv->orientation);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -26,8 +26,8 @@
|
||||
|
||||
#include "gtkseparator.h"
|
||||
|
||||
#include "gtkorientableprivate.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkorientable.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
|
||||
@@ -85,7 +85,8 @@ gtk_separator_set_property (GObject *object,
|
||||
if (separator->orientation != g_value_get_enum (value))
|
||||
{
|
||||
separator->orientation = g_value_get_enum (value);
|
||||
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (object));
|
||||
gtk_widget_update_orientation (GTK_WIDGET (object),
|
||||
separator->orientation);
|
||||
gtk_widget_queue_resize (GTK_WIDGET (object));
|
||||
g_object_notify_by_pspec (object, pspec);
|
||||
}
|
||||
@@ -120,7 +121,7 @@ gtk_separator_init (GtkSeparator *separator)
|
||||
{
|
||||
separator->orientation = GTK_ORIENTATION_HORIZONTAL;
|
||||
|
||||
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (separator));
|
||||
gtk_widget_update_orientation (GTK_WIDGET (separator), separator->orientation);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -47,7 +47,6 @@
|
||||
#include "gtkintl.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkorientable.h"
|
||||
#include "gtkorientableprivate.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtksettings.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
@@ -922,7 +921,8 @@ gtk_spin_button_init (GtkSpinButton *spin_button)
|
||||
|
||||
spin_button->orientation = GTK_ORIENTATION_HORIZONTAL;
|
||||
|
||||
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (spin_button));
|
||||
gtk_widget_update_orientation (GTK_WIDGET (spin_button),
|
||||
spin_button->orientation);
|
||||
|
||||
spin_button->entry = gtk_text_new ();
|
||||
gtk_editable_init_delegate (GTK_EDITABLE (spin_button));
|
||||
@@ -1089,7 +1089,7 @@ gtk_spin_button_set_orientation (GtkSpinButton *spin,
|
||||
return;
|
||||
|
||||
spin->orientation = orientation;
|
||||
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (spin));
|
||||
gtk_widget_update_orientation (GTK_WIDGET (spin), spin->orientation);
|
||||
|
||||
/* change alignment if it's the default */
|
||||
if (spin->orientation == GTK_ORIENTATION_VERTICAL &&
|
||||
|
@@ -10303,10 +10303,18 @@ gtk_tree_view_set_model (GtkTreeView *tree_view,
|
||||
|
||||
gtk_tree_view_real_set_cursor (tree_view, NULL, CURSOR_INVALID);
|
||||
|
||||
{
|
||||
GtkTreeViewAccessible *accessible =
|
||||
GTK_TREE_VIEW_ACCESSIBLE (_gtk_widget_peek_accessible (GTK_WIDGET (tree_view)));
|
||||
|
||||
if (accessible != NULL)
|
||||
gtk_tree_view_accessible_update_model (accessible, tree_view->model);
|
||||
}
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (tree_view), tree_view_props[PROP_MODEL]);
|
||||
|
||||
if (tree_view->selection)
|
||||
_gtk_tree_selection_emit_changed (tree_view->selection);
|
||||
_gtk_tree_selection_emit_changed (tree_view->selection);
|
||||
|
||||
if (gtk_widget_get_realized (GTK_WIDGET (tree_view)))
|
||||
gtk_widget_queue_resize (GTK_WIDGET (tree_view));
|
||||
|
312
gtk/gtkwidget.c
312
gtk/gtkwidget.c
@@ -31,6 +31,7 @@
|
||||
#include "gtkapplicationprivate.h"
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkbuilderprivate.h"
|
||||
#include "gtkconstraint.h"
|
||||
#include "gtkcssboxesprivate.h"
|
||||
#include "gtkcssfiltervalueprivate.h"
|
||||
#include "gtkcsstransformvalueprivate.h"
|
||||
@@ -48,12 +49,13 @@
|
||||
#include "gtklayoutmanagerprivate.h"
|
||||
#include "gtkmain.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtknativeprivate.h"
|
||||
#include "gtkorientable.h"
|
||||
#include "gtkpopover.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkrenderbackgroundprivate.h"
|
||||
#include "gtkrenderborderprivate.h"
|
||||
#include "gtkrootprivate.h"
|
||||
#include "gtknativeprivate.h"
|
||||
#include "gtkscrollable.h"
|
||||
#include "gtksettingsprivate.h"
|
||||
#include "gtkshortcut.h"
|
||||
@@ -71,8 +73,6 @@
|
||||
#include "gtkwidgetpaintableprivate.h"
|
||||
#include "gtkwindowgroup.h"
|
||||
#include "gtkwindowprivate.h"
|
||||
#include "gtknativeprivate.h"
|
||||
#include "gtkconstraint.h"
|
||||
|
||||
#include "a11y/gtkwidgetaccessibleprivate.h"
|
||||
#include "inspector/window.h"
|
||||
@@ -686,7 +686,6 @@ GtkTextDirection gtk_default_direction = GTK_TEXT_DIR_LTR;
|
||||
|
||||
static GQuark quark_pango_context = 0;
|
||||
static GQuark quark_mnemonic_labels = 0;
|
||||
static GQuark quark_tooltip_markup = 0;
|
||||
static GQuark quark_size_groups = 0;
|
||||
static GQuark quark_auto_children = 0;
|
||||
static GQuark quark_action_muxer = 0;
|
||||
@@ -904,7 +903,6 @@ gtk_widget_class_init (GtkWidgetClass *klass)
|
||||
|
||||
quark_pango_context = g_quark_from_static_string ("gtk-pango-context");
|
||||
quark_mnemonic_labels = g_quark_from_static_string ("gtk-mnemonic-labels");
|
||||
quark_tooltip_markup = g_quark_from_static_string ("gtk-tooltip-markup");
|
||||
quark_size_groups = g_quark_from_static_string ("gtk-widget-size-groups");
|
||||
quark_auto_children = g_quark_from_static_string ("gtk-widget-auto-children");
|
||||
quark_action_muxer = g_quark_from_static_string ("gtk-widget-action-muxer");
|
||||
@@ -944,7 +942,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
|
||||
klass->system_setting_changed = gtk_widget_real_system_setting_changed;
|
||||
|
||||
/* Accessibility support */
|
||||
klass->priv->accessible_type = GTK_TYPE_ACCESSIBLE;
|
||||
klass->priv->accessible_type = GTK_TYPE_WIDGET_ACCESSIBLE;
|
||||
klass->priv->accessible_role = ATK_ROLE_INVALID;
|
||||
klass->get_accessible = gtk_widget_real_get_accessible;
|
||||
|
||||
@@ -1121,7 +1119,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
|
||||
P_("Tooltip Text"),
|
||||
P_("The contents of the tooltip for this widget"),
|
||||
NULL,
|
||||
GTK_PARAM_READWRITE);
|
||||
GTK_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkWidget:tooltip-markup:
|
||||
@@ -1143,7 +1141,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
|
||||
P_("Tooltip markup"),
|
||||
P_("The contents of the tooltip for this widget"),
|
||||
NULL,
|
||||
GTK_PARAM_READWRITE);
|
||||
GTK_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkWidget:halign:
|
||||
@@ -1666,7 +1664,6 @@ gtk_widget_class_init (GtkWidgetClass *klass)
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
_gtk_marshal_BOOLEAN__INT_INT_BOOLEAN_OBJECTv);
|
||||
|
||||
gtk_widget_class_set_accessible_type (klass, GTK_TYPE_WIDGET_ACCESSIBLE);
|
||||
gtk_widget_class_set_css_name (klass, I_("widget"));
|
||||
}
|
||||
|
||||
@@ -1689,9 +1686,6 @@ gtk_widget_set_property (GObject *object,
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
gchar *tooltip_markup;
|
||||
const gchar *tooltip_text;
|
||||
|
||||
case PROP_NAME:
|
||||
gtk_widget_set_name (widget, g_value_get_string (value));
|
||||
break;
|
||||
@@ -1729,41 +1723,10 @@ gtk_widget_set_property (GObject *object,
|
||||
gtk_widget_set_has_tooltip (widget, g_value_get_boolean (value));
|
||||
break;
|
||||
case PROP_TOOLTIP_MARKUP:
|
||||
tooltip_markup = g_value_dup_string (value);
|
||||
|
||||
/* Treat an empty string as a NULL string,
|
||||
* because an empty string would be useless for a tooltip:
|
||||
*/
|
||||
if (tooltip_markup && (strlen (tooltip_markup) == 0))
|
||||
{
|
||||
g_free (tooltip_markup);
|
||||
tooltip_markup = NULL;
|
||||
}
|
||||
|
||||
g_object_set_qdata_full (object, quark_tooltip_markup,
|
||||
tooltip_markup, g_free);
|
||||
|
||||
gtk_widget_set_has_tooltip (widget, tooltip_markup != NULL);
|
||||
if (_gtk_widget_get_visible (widget))
|
||||
gtk_widget_trigger_tooltip_query (widget);
|
||||
gtk_widget_set_tooltip_markup (widget, g_value_get_string (value));
|
||||
break;
|
||||
case PROP_TOOLTIP_TEXT:
|
||||
tooltip_text = g_value_get_string (value);
|
||||
|
||||
/* Treat an empty string as a NULL string,
|
||||
* because an empty string would be useless for a tooltip:
|
||||
*/
|
||||
if (tooltip_text && (strlen (tooltip_text) == 0))
|
||||
tooltip_text = NULL;
|
||||
|
||||
tooltip_markup = tooltip_text ? g_markup_escape_text (tooltip_text, -1) : NULL;
|
||||
|
||||
g_object_set_qdata_full (object, quark_tooltip_markup,
|
||||
tooltip_markup, g_free);
|
||||
|
||||
gtk_widget_set_has_tooltip (widget, tooltip_markup != NULL);
|
||||
if (_gtk_widget_get_visible (widget))
|
||||
gtk_widget_trigger_tooltip_query (widget);
|
||||
gtk_widget_set_tooltip_text (widget, g_value_get_string (value));
|
||||
break;
|
||||
case PROP_HALIGN:
|
||||
gtk_widget_set_halign (widget, g_value_get_enum (value));
|
||||
@@ -1888,18 +1851,10 @@ gtk_widget_get_property (GObject *object,
|
||||
g_value_set_boolean (value, gtk_widget_get_has_tooltip (widget));
|
||||
break;
|
||||
case PROP_TOOLTIP_TEXT:
|
||||
{
|
||||
gchar *escaped = g_object_get_qdata (object, quark_tooltip_markup);
|
||||
gchar *text = NULL;
|
||||
|
||||
if (escaped && !pango_parse_markup (escaped, -1, 0, NULL, &text, NULL, NULL))
|
||||
g_assert (NULL == text); /* text should still be NULL in case of markup errors */
|
||||
|
||||
g_value_take_string (value, text);
|
||||
}
|
||||
g_value_set_string (value, gtk_widget_get_tooltip_text (widget));
|
||||
break;
|
||||
case PROP_TOOLTIP_MARKUP:
|
||||
g_value_set_string (value, g_object_get_qdata (object, quark_tooltip_markup));
|
||||
g_value_set_string (value, gtk_widget_get_tooltip_markup (widget));
|
||||
break;
|
||||
case PROP_HALIGN:
|
||||
g_value_set_enum (value, gtk_widget_get_halign (widget));
|
||||
@@ -2686,6 +2641,9 @@ gtk_widget_show (GtkWidget *widget)
|
||||
g_signal_emit (widget, widget_signals[SHOW], 0);
|
||||
g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_VISIBLE]);
|
||||
|
||||
if (priv->accessible != NULL)
|
||||
gtk_widget_accessible_notify_visible (GTK_WIDGET_ACCESSIBLE (priv->accessible));
|
||||
|
||||
gtk_widget_pop_verify_invariants (widget);
|
||||
g_object_unref (widget);
|
||||
}
|
||||
@@ -2746,6 +2704,9 @@ gtk_widget_hide (GtkWidget *widget)
|
||||
g_signal_emit (widget, widget_signals[HIDE], 0);
|
||||
g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_VISIBLE]);
|
||||
|
||||
if (priv->accessible != NULL)
|
||||
gtk_widget_accessible_notify_visible (GTK_WIDGET_ACCESSIBLE (priv->accessible));
|
||||
|
||||
parent = gtk_widget_get_parent (widget);
|
||||
if (parent)
|
||||
gtk_widget_queue_resize (parent);
|
||||
@@ -2805,11 +2766,16 @@ gtk_widget_map (GtkWidget *widget)
|
||||
|
||||
if (!_gtk_widget_get_mapped (widget))
|
||||
{
|
||||
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
|
||||
|
||||
gtk_widget_push_verify_invariants (widget);
|
||||
|
||||
if (!_gtk_widget_get_realized (widget))
|
||||
gtk_widget_realize (widget);
|
||||
|
||||
if (priv->accessible != NULL)
|
||||
gtk_widget_accessible_notify_showing (GTK_WIDGET_ACCESSIBLE (priv->accessible));
|
||||
|
||||
g_signal_emit (widget, widget_signals[MAP], 0);
|
||||
|
||||
update_cursor_on_state_change (widget);
|
||||
@@ -2834,6 +2800,8 @@ gtk_widget_unmap (GtkWidget *widget)
|
||||
|
||||
if (_gtk_widget_get_mapped (widget))
|
||||
{
|
||||
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
|
||||
|
||||
g_object_ref (widget);
|
||||
gtk_widget_push_verify_invariants (widget);
|
||||
|
||||
@@ -2842,6 +2810,9 @@ gtk_widget_unmap (GtkWidget *widget)
|
||||
|
||||
g_signal_emit (widget, widget_signals[UNMAP], 0);
|
||||
|
||||
if (priv->accessible != NULL)
|
||||
gtk_widget_accessible_notify_showing (GTK_WIDGET_ACCESSIBLE (priv->accessible));
|
||||
|
||||
update_cursor_on_state_change (widget);
|
||||
|
||||
gtk_widget_pop_verify_invariants (widget);
|
||||
@@ -4705,13 +4676,15 @@ gtk_widget_real_query_tooltip (GtkWidget *widget,
|
||||
gboolean keyboard_tip,
|
||||
GtkTooltip *tooltip)
|
||||
{
|
||||
gchar *tooltip_markup;
|
||||
const char *tooltip_markup;
|
||||
gboolean has_tooltip;
|
||||
|
||||
tooltip_markup = g_object_get_qdata (G_OBJECT (widget), quark_tooltip_markup);
|
||||
has_tooltip = gtk_widget_get_has_tooltip (widget);
|
||||
tooltip_markup = gtk_widget_get_tooltip_markup (widget);
|
||||
if (tooltip_markup == NULL)
|
||||
tooltip_markup = gtk_widget_get_tooltip_text (widget);
|
||||
|
||||
if (has_tooltip && tooltip_markup)
|
||||
if (has_tooltip && tooltip_markup != NULL)
|
||||
{
|
||||
gtk_tooltip_set_markup (tooltip, tooltip_markup);
|
||||
return TRUE;
|
||||
@@ -5720,6 +5693,9 @@ gtk_widget_set_sensitive (GtkWidget *widget,
|
||||
update_cursor_on_state_change (widget);
|
||||
}
|
||||
|
||||
if (priv->accessible != NULL)
|
||||
gtk_widget_accessible_notify_sensitive (GTK_WIDGET_ACCESSIBLE (priv->accessible));
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_SENSITIVE]);
|
||||
}
|
||||
|
||||
@@ -7343,6 +7319,8 @@ gtk_widget_finalize (GObject *object)
|
||||
gtk_grab_remove (widget);
|
||||
|
||||
g_free (priv->name);
|
||||
g_free (priv->tooltip_markup);
|
||||
g_free (priv->tooltip_text);
|
||||
|
||||
g_clear_object (&priv->accessible);
|
||||
g_clear_pointer (&priv->transform, gsk_transform_unref);
|
||||
@@ -7965,44 +7943,26 @@ gtk_widget_real_get_accessible (GtkWidget *widget)
|
||||
{
|
||||
GtkWidgetClass *widget_class;
|
||||
GtkWidgetClassPrivate *priv;
|
||||
AtkObjectFactory *factory;
|
||||
AtkRegistry *default_registry;
|
||||
|
||||
widget_class = GTK_WIDGET_GET_CLASS (widget);
|
||||
priv = widget_class->priv;
|
||||
|
||||
if (priv->accessible_type == GTK_TYPE_ACCESSIBLE)
|
||||
{
|
||||
default_registry = atk_get_default_registry ();
|
||||
factory = atk_registry_get_factory (default_registry,
|
||||
G_TYPE_FROM_INSTANCE (widget));
|
||||
accessible = atk_object_factory_create_accessible (factory, G_OBJECT (widget));
|
||||
accessible = g_object_new (priv->accessible_type,
|
||||
"widget", widget,
|
||||
NULL);
|
||||
if (priv->accessible_role != ATK_ROLE_INVALID)
|
||||
atk_object_set_role (accessible, priv->accessible_role);
|
||||
|
||||
if (priv->accessible_role != ATK_ROLE_INVALID)
|
||||
atk_object_set_role (accessible, priv->accessible_role);
|
||||
widget->priv->accessible = accessible;
|
||||
|
||||
widget->priv->accessible = accessible;
|
||||
}
|
||||
else
|
||||
{
|
||||
accessible = g_object_new (priv->accessible_type,
|
||||
"widget", widget,
|
||||
NULL);
|
||||
if (priv->accessible_role != ATK_ROLE_INVALID)
|
||||
atk_object_set_role (accessible, priv->accessible_role);
|
||||
|
||||
widget->priv->accessible = accessible;
|
||||
|
||||
atk_object_initialize (accessible, widget);
|
||||
|
||||
/* Set the role again, since we don't want a role set
|
||||
* in some parent initialize() function to override
|
||||
* our own.
|
||||
*/
|
||||
if (priv->accessible_role != ATK_ROLE_INVALID)
|
||||
atk_object_set_role (accessible, priv->accessible_role);
|
||||
}
|
||||
atk_object_initialize (accessible, widget);
|
||||
|
||||
/* Set the role again, since we don't want a role set
|
||||
* in some parent initialize() function to override
|
||||
* our own.
|
||||
*/
|
||||
if (priv->accessible_role != ATK_ROLE_INVALID)
|
||||
atk_object_set_role (accessible, priv->accessible_role);
|
||||
}
|
||||
|
||||
return accessible;
|
||||
@@ -9641,21 +9601,60 @@ gtk_widget_trigger_tooltip_query (GtkWidget *widget)
|
||||
/**
|
||||
* gtk_widget_set_tooltip_text:
|
||||
* @widget: a #GtkWidget
|
||||
* @text: (allow-none): the contents of the tooltip for @widget
|
||||
* @text: (nullable): the contents of the tooltip for @widget
|
||||
*
|
||||
* Sets @text as the contents of the tooltip. This function will take
|
||||
* care of setting #GtkWidget:has-tooltip to %TRUE and of the default
|
||||
* handler for the #GtkWidget::query-tooltip signal.
|
||||
* Sets @text as the contents of the tooltip.
|
||||
*
|
||||
* See also the #GtkWidget:tooltip-text property and gtk_tooltip_set_text().
|
||||
* If @text contains any markup, it will be escaped.
|
||||
*
|
||||
* This function will take care of setting #GtkWidget:has-tooltip
|
||||
* as a side effect, and of the default handler for the
|
||||
* #GtkWidget::query-tooltip signal.
|
||||
*
|
||||
* See also the #GtkWidget:tooltip-text property and
|
||||
* gtk_tooltip_set_text().
|
||||
*/
|
||||
void
|
||||
gtk_widget_set_tooltip_text (GtkWidget *widget,
|
||||
const gchar *text)
|
||||
gtk_widget_set_tooltip_text (GtkWidget *widget,
|
||||
const char *text)
|
||||
{
|
||||
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
|
||||
GObject *object = G_OBJECT (widget);
|
||||
char *tooltip_text, *tooltip_markup;
|
||||
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
|
||||
g_object_set (G_OBJECT (widget), "tooltip-text", text, NULL);
|
||||
g_object_freeze_notify (object);
|
||||
|
||||
/* Treat an empty string as a NULL string,
|
||||
* because an empty string would be useless for a tooltip:
|
||||
*/
|
||||
if (text != NULL && *text == '\0')
|
||||
{
|
||||
tooltip_text = NULL;
|
||||
tooltip_markup = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
tooltip_text = g_strdup (text);
|
||||
tooltip_markup = text != NULL ? g_markup_escape_text (text, -1) : NULL;
|
||||
}
|
||||
|
||||
g_clear_pointer (&priv->tooltip_markup, g_free);
|
||||
g_clear_pointer (&priv->tooltip_text, g_free);
|
||||
|
||||
priv->tooltip_text = tooltip_text;
|
||||
priv->tooltip_markup = tooltip_markup;
|
||||
|
||||
gtk_widget_set_has_tooltip (widget, priv->tooltip_text != NULL);
|
||||
if (_gtk_widget_get_visible (widget))
|
||||
gtk_widget_trigger_tooltip_query (widget);
|
||||
|
||||
g_object_notify_by_pspec (object, widget_props[PROP_TOOLTIP_TEXT]);
|
||||
g_object_notify_by_pspec (object, widget_props[PROP_TOOLTIP_MARKUP]);
|
||||
g_object_notify_by_pspec (object, widget_props[PROP_HAS_TOOLTIP]);
|
||||
|
||||
g_object_thaw_notify (object);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -9664,63 +9663,99 @@ gtk_widget_set_tooltip_text (GtkWidget *widget,
|
||||
*
|
||||
* Gets the contents of the tooltip for @widget.
|
||||
*
|
||||
* Returns: (nullable): the tooltip text, or %NULL. You should free the
|
||||
* returned string with g_free() when done.
|
||||
* If the @widget's tooltip was set using gtk_widget_set_tooltip_markup(),
|
||||
* this function will return the escaped text.
|
||||
*
|
||||
* Returns: (nullable): the tooltip text
|
||||
*/
|
||||
gchar *
|
||||
const char *
|
||||
gtk_widget_get_tooltip_text (GtkWidget *widget)
|
||||
{
|
||||
gchar *text = NULL;
|
||||
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
||||
|
||||
g_object_get (G_OBJECT (widget), "tooltip-text", &text, NULL);
|
||||
|
||||
return text;
|
||||
return priv->tooltip_text;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_widget_set_tooltip_markup:
|
||||
* @widget: a #GtkWidget
|
||||
* @markup: (allow-none): the contents of the tooltip for @widget, or %NULL
|
||||
* @markup: (nullable): the contents of the tooltip for @widget
|
||||
*
|
||||
* Sets @markup as the contents of the tooltip, which is marked up with
|
||||
* the [Pango text markup language][PangoMarkupFormat].
|
||||
* the [Pango text markup language][PangoMarkupFormat].
|
||||
*
|
||||
* This function will take care of setting #GtkWidget:has-tooltip to %TRUE
|
||||
* and of the default handler for the #GtkWidget::query-tooltip signal.
|
||||
* This function will take care of setting the #GtkWidget:has-tooltip as
|
||||
* a side effect, and of the default handler for the #GtkWidget::query-tooltip signal.
|
||||
*
|
||||
* See also the #GtkWidget:tooltip-markup property and
|
||||
* gtk_tooltip_set_markup().
|
||||
*/
|
||||
void
|
||||
gtk_widget_set_tooltip_markup (GtkWidget *widget,
|
||||
const gchar *markup)
|
||||
gtk_widget_set_tooltip_markup (GtkWidget *widget,
|
||||
const char *markup)
|
||||
{
|
||||
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
|
||||
GObject *object = G_OBJECT (widget);
|
||||
char *tooltip_markup;
|
||||
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
|
||||
g_object_set (G_OBJECT (widget), "tooltip-markup", markup, NULL);
|
||||
g_object_freeze_notify (object);
|
||||
|
||||
/* Treat an empty string as a NULL string,
|
||||
* because an empty string would be useless for a tooltip:
|
||||
*/
|
||||
if (markup != NULL && *markup == '\0')
|
||||
tooltip_markup = NULL;
|
||||
else
|
||||
tooltip_markup = g_strdup (markup);
|
||||
|
||||
g_clear_pointer (&priv->tooltip_text, g_free);
|
||||
g_clear_pointer (&priv->tooltip_markup, g_free);
|
||||
|
||||
priv->tooltip_markup = tooltip_markup;
|
||||
|
||||
/* Store the tooltip without markup, as we might end up using
|
||||
* it for widget descriptions in the accessibility layer
|
||||
*/
|
||||
if (priv->tooltip_markup != NULL)
|
||||
{
|
||||
pango_parse_markup (priv->tooltip_markup, -1, 0, NULL,
|
||||
&priv->tooltip_text,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
gtk_widget_set_has_tooltip (widget, tooltip_markup != NULL);
|
||||
if (_gtk_widget_get_visible (widget))
|
||||
gtk_widget_trigger_tooltip_query (widget);
|
||||
|
||||
g_object_notify_by_pspec (object, widget_props[PROP_TOOLTIP_TEXT]);
|
||||
g_object_notify_by_pspec (object, widget_props[PROP_TOOLTIP_MARKUP]);
|
||||
g_object_notify_by_pspec (object, widget_props[PROP_HAS_TOOLTIP]);
|
||||
|
||||
g_object_thaw_notify (object);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_widget_get_tooltip_markup:
|
||||
* @widget: a #GtkWidget
|
||||
*
|
||||
* Gets the contents of the tooltip for @widget.
|
||||
* Gets the contents of the tooltip for @widget set using
|
||||
* gtk_widget_set_tooltip_markup().
|
||||
*
|
||||
* Returns: (nullable): the tooltip text, or %NULL. You should free the
|
||||
* returned string with g_free() when done.
|
||||
* Returns: (nullable): the tooltip text
|
||||
*/
|
||||
gchar *
|
||||
const char *
|
||||
gtk_widget_get_tooltip_markup (GtkWidget *widget)
|
||||
{
|
||||
gchar *text = NULL;
|
||||
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
||||
|
||||
g_object_get (G_OBJECT (widget), "tooltip-markup", &text, NULL);
|
||||
|
||||
return text;
|
||||
return priv->tooltip_markup;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -9745,6 +9780,9 @@ gtk_widget_set_has_tooltip (GtkWidget *widget,
|
||||
{
|
||||
priv->has_tooltip = has_tooltip;
|
||||
|
||||
if (priv->accessible != NULL)
|
||||
gtk_widget_accessible_notify_tooltip (GTK_WIDGET_ACCESSIBLE (priv->accessible));
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_HAS_TOOLTIP]);
|
||||
}
|
||||
}
|
||||
@@ -10370,6 +10408,10 @@ gtk_widget_set_has_focus (GtkWidget *widget,
|
||||
return;
|
||||
|
||||
priv->has_focus = has_focus;
|
||||
|
||||
if (priv->accessible != NULL)
|
||||
gtk_widget_accessible_notify_focus (GTK_WIDGET_ACCESSIBLE (priv->accessible));
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_HAS_FOCUS]);
|
||||
}
|
||||
|
||||
@@ -12737,3 +12779,35 @@ gtk_widget_set_css_classes (GtkWidget *widget,
|
||||
gtk_css_node_set_classes (priv->cssnode, classes);
|
||||
g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_CSS_CLASSES]);
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gtk_widget_update_orientation:
|
||||
* @widget: a #GtkWidget implementing #GtkOrientable
|
||||
* @orientation: the orientation
|
||||
*
|
||||
* Update the internal state associated to the given @orientation of a
|
||||
* #GtkWidget implementing the #GtkOrientable interface.
|
||||
*/
|
||||
void
|
||||
gtk_widget_update_orientation (GtkWidget *widget,
|
||||
GtkOrientation orientation)
|
||||
{
|
||||
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
|
||||
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
g_return_if_fail (GTK_IS_ORIENTABLE (widget));
|
||||
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
{
|
||||
gtk_widget_add_css_class (widget, GTK_STYLE_CLASS_HORIZONTAL);
|
||||
gtk_widget_remove_css_class (widget, GTK_STYLE_CLASS_VERTICAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_add_css_class (widget, GTK_STYLE_CLASS_VERTICAL);
|
||||
gtk_widget_remove_css_class (widget, GTK_STYLE_CLASS_HORIZONTAL);
|
||||
}
|
||||
|
||||
if (priv->accessible != NULL)
|
||||
gtk_widget_accessible_notify_orientation (GTK_WIDGET_ACCESSIBLE (priv->accessible));
|
||||
}
|
||||
|
@@ -720,22 +720,22 @@ void gtk_widget_remove_mnemonic_label (GtkWidget *widget,
|
||||
GtkWidget *label);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_widget_trigger_tooltip_query (GtkWidget *widget);
|
||||
void gtk_widget_trigger_tooltip_query (GtkWidget *widget);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_widget_set_tooltip_text (GtkWidget *widget,
|
||||
const gchar *text);
|
||||
void gtk_widget_set_tooltip_text (GtkWidget *widget,
|
||||
const char *text);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gchar * gtk_widget_get_tooltip_text (GtkWidget *widget);
|
||||
const char * gtk_widget_get_tooltip_text (GtkWidget *widget);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_widget_set_tooltip_markup (GtkWidget *widget,
|
||||
const gchar *markup);
|
||||
void gtk_widget_set_tooltip_markup (GtkWidget *widget,
|
||||
const char *markup);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gchar * gtk_widget_get_tooltip_markup (GtkWidget *widget);
|
||||
const char * gtk_widget_get_tooltip_markup (GtkWidget *widget);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_widget_set_has_tooltip (GtkWidget *widget,
|
||||
gboolean has_tooltip);
|
||||
void gtk_widget_set_has_tooltip (GtkWidget *widget,
|
||||
gboolean has_tooltip);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_widget_get_has_tooltip (GtkWidget *widget);
|
||||
gboolean gtk_widget_get_has_tooltip (GtkWidget *widget);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_requisition_get_type (void) G_GNUC_CONST;
|
||||
|
@@ -193,6 +193,10 @@ struct _GtkWidgetPrivate
|
||||
|
||||
/* Pointer cursor */
|
||||
GdkCursor *cursor;
|
||||
|
||||
/* Tooltip */
|
||||
char *tooltip_markup;
|
||||
char *tooltip_text;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
@@ -365,6 +369,9 @@ gboolean gtk_widget_grab_focus_self (GtkWidget *widget);
|
||||
gboolean gtk_widget_focus_self (GtkWidget *widget,
|
||||
GtkDirectionType direction);
|
||||
|
||||
void gtk_widget_update_orientation (GtkWidget *widget,
|
||||
GtkOrientation orientation);
|
||||
|
||||
/* inline getters */
|
||||
|
||||
static inline GtkWidget *
|
||||
|
@@ -293,7 +293,7 @@ main (int argc, char *argv[])
|
||||
GtkTextIter iter;
|
||||
GtkTextTag *tag;
|
||||
|
||||
gchar *text, *markup;
|
||||
const char *text, *markup;
|
||||
gboolean done = FALSE;
|
||||
|
||||
gtk_init ();
|
||||
@@ -319,9 +319,8 @@ main (int argc, char *argv[])
|
||||
|
||||
text = gtk_widget_get_tooltip_text (button);
|
||||
markup = gtk_widget_get_tooltip_markup (button);
|
||||
g_assert (g_str_equal ("Hello, I am a static tooltip.", text));
|
||||
g_assert (g_str_equal ("Hello, I am a static tooltip.", markup));
|
||||
g_free (text); g_free (markup);
|
||||
g_assert_true (g_str_equal ("Hello, I am a static tooltip.", text));
|
||||
g_assert_true (g_str_equal ("Hello, I am a static tooltip.", markup));
|
||||
|
||||
/* A check button using the query-tooltip signal */
|
||||
button = gtk_check_button_new_with_label ("I use the query-tooltip signal");
|
||||
@@ -338,9 +337,8 @@ main (int argc, char *argv[])
|
||||
|
||||
text = gtk_widget_get_tooltip_text (button);
|
||||
markup = gtk_widget_get_tooltip_markup (button);
|
||||
g_assert (g_str_equal ("Label & and tooltip", text));
|
||||
g_assert (g_str_equal ("Label & and tooltip", markup));
|
||||
g_free (text); g_free (markup);
|
||||
g_assert_true (g_str_equal ("Label & and tooltip", text));
|
||||
g_assert_true (g_str_equal ("Label & and tooltip", markup));
|
||||
|
||||
/* A selectable label */
|
||||
button = gtk_label_new ("I am a selectable label");
|
||||
@@ -350,9 +348,8 @@ main (int argc, char *argv[])
|
||||
|
||||
text = gtk_widget_get_tooltip_text (button);
|
||||
markup = gtk_widget_get_tooltip_markup (button);
|
||||
g_assert (g_str_equal ("Another Label tooltip", text));
|
||||
g_assert (g_str_equal ("<b>Another</b> Label tooltip", markup));
|
||||
g_free (text); g_free (markup);
|
||||
g_assert_true (g_str_equal ("Another Label tooltip", text));
|
||||
g_assert_true (g_str_equal ("<b>Another</b> Label tooltip", markup));
|
||||
|
||||
/* An insensitive button */
|
||||
button = gtk_button_new_with_label ("This one is insensitive");
|
||||
|
@@ -57,6 +57,7 @@ tests = [
|
||||
['textbuffer'],
|
||||
['textiter'],
|
||||
['theme-validate'],
|
||||
['tooltips'],
|
||||
['treelistmodel'],
|
||||
['treemodel', ['treemodel.c', 'liststore.c', 'treestore.c', 'filtermodel.c',
|
||||
'modelrefcount.c', 'sortmodel.c', 'gtktreemodelrefcount.c']],
|
||||
|
59
testsuite/gtk/tooltips.c
Normal file
59
testsuite/gtk/tooltips.c
Normal file
@@ -0,0 +1,59 @@
|
||||
/* tooltips.c: Unit test for GtkWidget tooltip accessors
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
* Copyright 2020 GNOME Foundation
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static void
|
||||
test_tooltips_widget_accessors (void)
|
||||
{
|
||||
GtkWidget *w;
|
||||
const char *text, *markup;
|
||||
|
||||
g_test_message ("A button using tooltip-markup");
|
||||
w = gtk_check_button_new_with_label ("This one uses the tooltip-markup property");
|
||||
g_object_ref_sink (w);
|
||||
gtk_widget_set_tooltip_text (w, "Hello, I am a static tooltip.");
|
||||
|
||||
text = gtk_widget_get_tooltip_text (w);
|
||||
markup = gtk_widget_get_tooltip_markup (w);
|
||||
g_assert_cmpstr (text, ==, "Hello, I am a static tooltip.");
|
||||
g_assert_cmpstr (markup, ==, "Hello, I am a static tooltip.");
|
||||
g_object_unref (w);
|
||||
|
||||
g_test_message ("A label using tooltip-text");
|
||||
w = gtk_label_new ("I am just a label");
|
||||
g_object_ref_sink (w);
|
||||
gtk_widget_set_tooltip_text (w, "Label & and tooltip");
|
||||
|
||||
text = gtk_widget_get_tooltip_text (w);
|
||||
markup = gtk_widget_get_tooltip_markup (w);
|
||||
g_assert_cmpstr (text, ==, "Label & and tooltip");
|
||||
g_assert_cmpstr (markup, ==, "Label & and tooltip");
|
||||
g_object_unref (w);
|
||||
|
||||
g_test_message ("A label using tooltip-markup");
|
||||
w = gtk_label_new ("I am a selectable label");
|
||||
g_object_ref_sink (w);
|
||||
gtk_label_set_selectable (GTK_LABEL (w), TRUE);
|
||||
gtk_widget_set_tooltip_markup (w, "<b>Another</b> Label tooltip");
|
||||
|
||||
text = gtk_widget_get_tooltip_text (w);
|
||||
markup = gtk_widget_get_tooltip_markup (w);
|
||||
g_assert_cmpstr (text, ==, "Another Label tooltip");
|
||||
g_assert_cmpstr (markup, ==,"<b>Another</b> Label tooltip");
|
||||
g_object_unref (w);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
{
|
||||
gtk_test_init (&argc, &argv);
|
||||
|
||||
g_test_add_func ("/tooltips/widget-accessors", test_tooltips_widget_accessors);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
Reference in New Issue
Block a user