2012-10-30 14:21:44 +00:00
|
|
|
/* GTK+ - accessibility implementations
|
2007-12-18 13:51:12 +00:00
|
|
|
* Copyright 2001, 2002, 2003 Sun Microsystems 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
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2007-12-18 13:51:12 +00:00
|
|
|
*/
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
#include "config.h"
|
2007-12-23 12:27:33 +00:00
|
|
|
|
2007-12-18 13:51:12 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#ifdef GDK_WINDOWING_X11
|
|
|
|
#include <gdk/x11/gdkx.h>
|
|
|
|
#endif
|
2011-07-07 07:54:04 +00:00
|
|
|
|
|
|
|
#include "gtktreeprivate.h"
|
2011-11-12 02:39:48 +00:00
|
|
|
#include "gtkwidgetprivate.h"
|
2011-07-07 07:54:04 +00:00
|
|
|
|
2012-12-27 06:04:46 +00:00
|
|
|
#include "gtktreeviewaccessibleprivate.h"
|
|
|
|
|
2011-07-09 23:19:38 +00:00
|
|
|
#include "gtkrenderercellaccessible.h"
|
2011-07-09 23:02:42 +00:00
|
|
|
#include "gtkbooleancellaccessible.h"
|
2011-07-10 02:59:15 +00:00
|
|
|
#include "gtkimagecellaccessible.h"
|
2011-07-09 22:51:27 +00:00
|
|
|
#include "gtkcontainercellaccessible.h"
|
2011-07-10 03:26:59 +00:00
|
|
|
#include "gtktextcellaccessible.h"
|
2011-07-10 03:56:42 +00:00
|
|
|
#include "gtkcellaccessibleparent.h"
|
2012-12-27 06:04:46 +00:00
|
|
|
#include "gtkcellaccessibleprivate.h"
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2012-10-15 09:56:41 +00:00
|
|
|
struct _GtkTreeViewAccessiblePrivate
|
|
|
|
{
|
|
|
|
GHashTable *cell_infos;
|
|
|
|
};
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
typedef struct _GtkTreeViewAccessibleCellInfo GtkTreeViewAccessibleCellInfo;
|
|
|
|
struct _GtkTreeViewAccessibleCellInfo
|
|
|
|
{
|
2011-07-09 22:30:59 +00:00
|
|
|
GtkCellAccessible *cell;
|
2011-11-12 02:39:48 +00:00
|
|
|
GtkRBTree *tree;
|
|
|
|
GtkRBNode *node;
|
2011-06-30 00:50:50 +00:00
|
|
|
GtkTreeViewColumn *cell_col_ref;
|
|
|
|
GtkTreeViewAccessible *view;
|
|
|
|
};
|
2007-12-18 13:51:12 +00:00
|
|
|
|
|
|
|
/* Misc */
|
|
|
|
|
2011-11-11 01:48:40 +00:00
|
|
|
static int cell_info_get_index (GtkTreeView *tree_view,
|
|
|
|
GtkTreeViewAccessibleCellInfo *info);
|
2007-12-18 13:51:12 +00:00
|
|
|
static gboolean is_cell_showing (GtkTreeView *tree_view,
|
|
|
|
GdkRectangle *cell_rect);
|
|
|
|
|
2012-02-11 02:42:14 +00:00
|
|
|
static void cell_info_new (GtkTreeViewAccessible *accessible,
|
2011-11-12 03:56:29 +00:00
|
|
|
GtkRBTree *tree,
|
|
|
|
GtkRBNode *node,
|
2007-12-18 13:51:12 +00:00
|
|
|
GtkTreeViewColumn *tv_col,
|
2011-07-09 22:30:59 +00:00
|
|
|
GtkCellAccessible *cell);
|
2007-12-18 13:51:12 +00:00
|
|
|
static gint get_column_number (GtkTreeView *tree_view,
|
2011-11-15 19:24:51 +00:00
|
|
|
GtkTreeViewColumn *column);
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2011-11-12 03:56:29 +00:00
|
|
|
static gboolean get_rbtree_column_from_index (GtkTreeView *tree_view,
|
2007-12-18 13:51:12 +00:00
|
|
|
gint index,
|
2011-11-12 03:56:29 +00:00
|
|
|
GtkRBTree **tree,
|
|
|
|
GtkRBNode **node,
|
2007-12-18 13:51:12 +00:00
|
|
|
GtkTreeViewColumn **column);
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
static GtkTreeViewAccessibleCellInfo* find_cell_info (GtkTreeViewAccessible *view,
|
2011-11-13 03:28:52 +00:00
|
|
|
GtkCellAccessible *cell);
|
2007-12-18 13:51:12 +00:00
|
|
|
static AtkObject * get_header_from_column (GtkTreeViewColumn *tv_col);
|
|
|
|
|
|
|
|
|
2011-07-10 03:56:42 +00:00
|
|
|
static void atk_table_interface_init (AtkTableIface *iface);
|
|
|
|
static void atk_selection_interface_init (AtkSelectionIface *iface);
|
|
|
|
static void atk_component_interface_init (AtkComponentIface *iface);
|
|
|
|
static void gtk_cell_accessible_parent_interface_init (GtkCellAccessibleParentIface *iface);
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2012-12-27 06:04:46 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkTreeViewAccessible, gtk_tree_view_accessible, GTK_TYPE_CONTAINER_ACCESSIBLE,
|
2013-06-24 18:13:44 +00:00
|
|
|
G_ADD_PRIVATE (GtkTreeViewAccessible)
|
2007-12-23 12:24:59 +00:00
|
|
|
G_IMPLEMENT_INTERFACE (ATK_TYPE_TABLE, atk_table_interface_init)
|
|
|
|
G_IMPLEMENT_INTERFACE (ATK_TYPE_SELECTION, atk_selection_interface_init)
|
|
|
|
G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, atk_component_interface_init)
|
2011-07-10 03:56:42 +00:00
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_ACCESSIBLE_PARENT, gtk_cell_accessible_parent_interface_init))
|
2007-12-18 13:51:12 +00:00
|
|
|
|
|
|
|
|
2011-11-11 20:03:49 +00:00
|
|
|
static GQuark
|
|
|
|
gtk_tree_view_accessible_get_data_quark (void)
|
|
|
|
{
|
|
|
|
static GQuark quark = 0;
|
|
|
|
|
|
|
|
if (G_UNLIKELY (quark == 0))
|
|
|
|
quark = g_quark_from_static_string ("gtk-tree-view-accessible-data");
|
|
|
|
|
|
|
|
return quark;
|
|
|
|
}
|
|
|
|
|
2011-11-09 13:31:43 +00:00
|
|
|
static void
|
|
|
|
cell_info_free (GtkTreeViewAccessibleCellInfo *cell_info)
|
|
|
|
{
|
2012-02-12 15:44:21 +00:00
|
|
|
gtk_accessible_set_widget (GTK_ACCESSIBLE (cell_info->cell), NULL);
|
2012-02-11 02:37:25 +00:00
|
|
|
g_object_unref (cell_info->cell);
|
2011-11-11 20:03:49 +00:00
|
|
|
|
2011-11-09 13:31:43 +00:00
|
|
|
g_free (cell_info);
|
|
|
|
}
|
|
|
|
|
2011-11-12 02:18:13 +00:00
|
|
|
static GtkTreePath *
|
|
|
|
cell_info_get_path (GtkTreeViewAccessibleCellInfo *cell_info)
|
|
|
|
{
|
2011-11-26 01:54:34 +00:00
|
|
|
return _gtk_tree_path_new_from_rbtree (cell_info->tree, cell_info->node);
|
2011-11-12 02:18:13 +00:00
|
|
|
}
|
|
|
|
|
2011-11-12 04:38:52 +00:00
|
|
|
static guint
|
|
|
|
cell_info_hash (gconstpointer info)
|
|
|
|
{
|
|
|
|
const GtkTreeViewAccessibleCellInfo *cell_info = info;
|
|
|
|
guint node, col;
|
|
|
|
|
|
|
|
node = GPOINTER_TO_UINT (cell_info->node);
|
|
|
|
col = GPOINTER_TO_UINT (cell_info->cell_col_ref);
|
|
|
|
|
|
|
|
return ((node << sizeof (guint) / 2) | (node >> sizeof (guint) / 2)) ^ col;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
cell_info_equal (gconstpointer a, gconstpointer b)
|
|
|
|
{
|
|
|
|
const GtkTreeViewAccessibleCellInfo *cell_info_a = a;
|
|
|
|
const GtkTreeViewAccessibleCellInfo *cell_info_b = b;
|
|
|
|
|
|
|
|
return cell_info_a->node == cell_info_b->node &&
|
|
|
|
cell_info_a->cell_col_ref == cell_info_b->cell_col_ref;
|
|
|
|
}
|
|
|
|
|
2007-12-18 13:51:12 +00:00
|
|
|
static void
|
2011-06-30 00:50:50 +00:00
|
|
|
gtk_tree_view_accessible_initialize (AtkObject *obj,
|
|
|
|
gpointer data)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-06-30 00:50:50 +00:00
|
|
|
GtkTreeViewAccessible *accessible;
|
2007-12-18 13:51:12 +00:00
|
|
|
GtkTreeView *tree_view;
|
2010-10-22 17:28:32 +00:00
|
|
|
GtkTreeModel *tree_model;
|
2007-12-18 13:51:12 +00:00
|
|
|
GtkWidget *widget;
|
|
|
|
|
2012-12-27 06:04:46 +00:00
|
|
|
ATK_OBJECT_CLASS (gtk_tree_view_accessible_parent_class)->initialize (obj, data);
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
accessible = GTK_TREE_VIEW_ACCESSIBLE (obj);
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2012-10-15 09:56:41 +00:00
|
|
|
accessible->priv->cell_infos = g_hash_table_new_full (cell_info_hash,
|
2011-11-12 04:38:52 +00:00
|
|
|
cell_info_equal, NULL, (GDestroyNotify) cell_info_free);
|
2011-06-23 02:27:10 +00:00
|
|
|
|
2007-12-18 13:51:12 +00:00
|
|
|
widget = GTK_WIDGET (data);
|
|
|
|
tree_view = GTK_TREE_VIEW (widget);
|
|
|
|
tree_model = gtk_tree_view_get_model (tree_view);
|
2011-06-30 00:50:50 +00:00
|
|
|
|
2007-12-18 13:51:12 +00:00
|
|
|
if (tree_model)
|
|
|
|
{
|
2010-08-10 01:09:30 +00:00
|
|
|
if (gtk_tree_model_get_flags (tree_model) & GTK_TREE_MODEL_LIST_ONLY)
|
2007-12-18 13:51:12 +00:00
|
|
|
obj->role = ATK_ROLE_TABLE;
|
2010-08-10 01:09:30 +00:00
|
|
|
else
|
|
|
|
obj->role = ATK_ROLE_TREE_TABLE;
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-06-30 00:50:50 +00:00
|
|
|
gtk_tree_view_accessible_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GtkTreeViewAccessible *accessible = GTK_TREE_VIEW_ACCESSIBLE (object);
|
|
|
|
|
2012-10-15 09:56:41 +00:00
|
|
|
if (accessible->priv->cell_infos)
|
|
|
|
g_hash_table_destroy (accessible->priv->cell_infos);
|
2011-06-30 00:50:50 +00:00
|
|
|
|
2012-12-27 06:04:46 +00:00
|
|
|
G_OBJECT_CLASS (gtk_tree_view_accessible_parent_class)->finalize (object);
|
2011-06-30 00:50:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_tree_view_accessible_notify_gtk (GObject *obj,
|
|
|
|
GParamSpec *pspec)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkTreeView *tree_view;
|
2011-06-30 00:50:50 +00:00
|
|
|
GtkTreeViewAccessible *accessible;
|
2007-12-18 13:51:12 +00:00
|
|
|
|
|
|
|
widget = GTK_WIDGET (obj);
|
2011-06-30 00:50:50 +00:00
|
|
|
accessible = GTK_TREE_VIEW_ACCESSIBLE (gtk_widget_get_accessible (widget));
|
2007-12-18 13:51:12 +00:00
|
|
|
tree_view = GTK_TREE_VIEW (widget);
|
|
|
|
|
2011-07-10 04:20:17 +00:00
|
|
|
if (g_strcmp0 (pspec->name, "model") == 0)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
GtkTreeModel *tree_model;
|
|
|
|
AtkRole role;
|
|
|
|
|
|
|
|
tree_model = gtk_tree_view_get_model (tree_view);
|
2012-10-15 09:56:41 +00:00
|
|
|
g_hash_table_remove_all (accessible->priv->cell_infos);
|
2011-06-30 00:50:50 +00:00
|
|
|
|
2007-12-18 13:51:12 +00:00
|
|
|
if (tree_model)
|
|
|
|
{
|
2010-08-10 01:09:30 +00:00
|
|
|
if (gtk_tree_model_get_flags (tree_model) & GTK_TREE_MODEL_LIST_ONLY)
|
2007-12-18 13:51:12 +00:00
|
|
|
role = ATK_ROLE_TABLE;
|
2010-08-10 01:09:30 +00:00
|
|
|
else
|
|
|
|
role = ATK_ROLE_TREE_TABLE;
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
role = ATK_ROLE_UNKNOWN;
|
|
|
|
}
|
2011-06-30 00:50:50 +00:00
|
|
|
atk_object_set_role (ATK_OBJECT (accessible), role);
|
|
|
|
g_object_freeze_notify (G_OBJECT (accessible));
|
2011-07-17 22:47:19 +00:00
|
|
|
g_signal_emit_by_name (accessible, "model-changed");
|
|
|
|
g_signal_emit_by_name (accessible, "visible-data-changed");
|
2011-06-30 00:50:50 +00:00
|
|
|
g_object_thaw_notify (G_OBJECT (accessible));
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
else
|
2012-12-27 06:04:46 +00:00
|
|
|
GTK_WIDGET_ACCESSIBLE_CLASS (gtk_tree_view_accessible_parent_class)->notify_gtk (obj, pspec);
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-12-18 18:20:15 +00:00
|
|
|
gtk_tree_view_accessible_widget_unset (GtkAccessible *gtkaccessible)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-12-18 18:20:15 +00:00
|
|
|
GtkTreeViewAccessible *accessible = GTK_TREE_VIEW_ACCESSIBLE (gtkaccessible);
|
2011-12-12 06:09:32 +00:00
|
|
|
|
2012-10-15 09:56:41 +00:00
|
|
|
g_hash_table_remove_all (accessible->priv->cell_infos);
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2012-12-27 06:04:46 +00:00
|
|
|
GTK_ACCESSIBLE_CLASS (gtk_tree_view_accessible_parent_class)->widget_unset (gtkaccessible);
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2011-11-12 03:56:29 +00:00
|
|
|
static gint
|
|
|
|
get_n_rows (GtkTreeView *tree_view)
|
|
|
|
{
|
|
|
|
GtkRBTree *tree;
|
|
|
|
|
|
|
|
tree = _gtk_tree_view_get_rbtree (tree_view);
|
|
|
|
|
|
|
|
if (tree == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return tree->root->total_count;
|
|
|
|
}
|
|
|
|
|
2011-11-15 15:45:48 +00:00
|
|
|
static gint
|
|
|
|
get_n_columns (GtkTreeView *tree_view)
|
|
|
|
{
|
|
|
|
guint i, visible_columns;
|
|
|
|
|
|
|
|
visible_columns = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < gtk_tree_view_get_n_columns (tree_view); i++)
|
|
|
|
{
|
|
|
|
GtkTreeViewColumn *column = gtk_tree_view_get_column (tree_view, i);
|
|
|
|
|
|
|
|
if (gtk_tree_view_column_get_visible (column))
|
|
|
|
visible_columns++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return visible_columns;
|
|
|
|
}
|
2012-12-27 06:04:46 +00:00
|
|
|
|
2007-12-18 13:51:12 +00:00
|
|
|
static gint
|
2011-06-30 00:50:50 +00:00
|
|
|
gtk_tree_view_accessible_get_n_children (AtkObject *obj)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
2011-11-12 03:56:29 +00:00
|
|
|
GtkTreeView *tree_view;
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2010-05-22 23:55:33 +00:00
|
|
|
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
|
2007-12-18 13:51:12 +00:00
|
|
|
if (widget == NULL)
|
|
|
|
return 0;
|
|
|
|
|
2011-11-12 03:56:29 +00:00
|
|
|
tree_view = GTK_TREE_VIEW (widget);
|
2011-11-15 15:45:48 +00:00
|
|
|
return (get_n_rows (tree_view) + 1) * get_n_columns (tree_view);
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2011-11-16 01:40:49 +00:00
|
|
|
static GtkTreeViewColumn *
|
|
|
|
get_visible_column (GtkTreeView *tree_view,
|
|
|
|
guint id)
|
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
for (i = 0; i < gtk_tree_view_get_n_columns (tree_view); i++)
|
|
|
|
{
|
|
|
|
GtkTreeViewColumn *column = gtk_tree_view_get_column (tree_view, i);
|
|
|
|
|
|
|
|
if (!gtk_tree_view_column_get_visible (column))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (id == 0)
|
|
|
|
return column;
|
|
|
|
|
|
|
|
id--;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_return_val_if_reached (NULL);
|
|
|
|
}
|
|
|
|
|
2011-12-16 00:02:06 +00:00
|
|
|
static void
|
|
|
|
set_cell_data (GtkTreeView *treeview,
|
|
|
|
GtkTreeViewAccessible *accessible,
|
|
|
|
GtkCellAccessible *cell)
|
|
|
|
{
|
|
|
|
GtkTreeViewAccessibleCellInfo *cell_info;
|
|
|
|
gboolean is_expander, is_expanded;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
|
|
|
cell_info = find_cell_info (accessible, cell);
|
|
|
|
if (!cell_info)
|
|
|
|
return;
|
|
|
|
|
|
|
|
model = gtk_tree_view_get_model (treeview);
|
|
|
|
|
|
|
|
if (GTK_RBNODE_FLAG_SET (cell_info->node, GTK_RBNODE_IS_PARENT) &&
|
|
|
|
cell_info->cell_col_ref == gtk_tree_view_get_expander_column (treeview))
|
|
|
|
{
|
|
|
|
is_expander = TRUE;
|
|
|
|
is_expanded = cell_info->node->children != NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
is_expander = FALSE;
|
|
|
|
is_expanded = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
path = cell_info_get_path (cell_info);
|
|
|
|
if (path == NULL ||
|
|
|
|
!gtk_tree_model_get_iter (model, &iter, path))
|
|
|
|
{
|
|
|
|
/* We only track valid cells, this should never happen */
|
|
|
|
g_return_if_reached ();
|
|
|
|
}
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
|
|
|
gtk_tree_view_column_cell_set_cell_data (cell_info->cell_col_ref,
|
|
|
|
model,
|
|
|
|
&iter,
|
|
|
|
is_expander,
|
|
|
|
is_expanded);
|
|
|
|
}
|
|
|
|
|
2011-12-16 22:11:45 +00:00
|
|
|
static GtkCellAccessible *
|
|
|
|
peek_cell (GtkTreeViewAccessible *accessible,
|
|
|
|
GtkRBTree *tree,
|
|
|
|
GtkRBNode *node,
|
|
|
|
GtkTreeViewColumn *column)
|
|
|
|
{
|
|
|
|
GtkTreeViewAccessibleCellInfo lookup, *cell_info;
|
|
|
|
|
|
|
|
lookup.tree = tree;
|
|
|
|
lookup.node = node;
|
|
|
|
lookup.cell_col_ref = column;
|
|
|
|
|
2012-10-15 09:56:41 +00:00
|
|
|
cell_info = g_hash_table_lookup (accessible->priv->cell_infos, &lookup);
|
2011-12-16 22:11:45 +00:00
|
|
|
if (cell_info == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return cell_info->cell;
|
|
|
|
}
|
|
|
|
|
2014-02-24 17:02:41 +00:00
|
|
|
static GtkCellAccessible *
|
|
|
|
create_cell_accessible_for_renderer (GtkCellRenderer *renderer,
|
|
|
|
GtkWidget *widget,
|
|
|
|
AtkObject *parent)
|
|
|
|
{
|
|
|
|
GtkCellAccessible *cell;
|
|
|
|
|
|
|
|
cell = GTK_CELL_ACCESSIBLE (gtk_renderer_cell_accessible_new (renderer));
|
|
|
|
|
|
|
|
_gtk_cell_accessible_initialize (cell, widget, parent);
|
|
|
|
|
|
|
|
return cell;
|
|
|
|
}
|
|
|
|
|
2012-02-11 03:36:40 +00:00
|
|
|
static GtkCellAccessible *
|
2014-02-24 13:07:57 +00:00
|
|
|
create_cell_accessible (GtkTreeView *treeview,
|
|
|
|
GtkTreeViewAccessible *accessible,
|
|
|
|
GtkTreeViewColumn *column)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
GList *renderer_list;
|
|
|
|
GList *l;
|
2012-02-11 03:36:40 +00:00
|
|
|
GtkCellAccessible *cell;
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2012-02-11 03:36:40 +00:00
|
|
|
renderer_list = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column));
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2014-02-26 00:47:50 +00:00
|
|
|
/* If there is exactly one renderer in the list (which is a
|
|
|
|
* common case), shortcut and don't make a container
|
2011-06-30 00:50:50 +00:00
|
|
|
*/
|
2014-02-26 00:47:50 +00:00
|
|
|
if (g_list_length (renderer_list) == 1)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2014-02-26 00:47:50 +00:00
|
|
|
cell = create_cell_accessible_for_renderer (renderer_list->data, GTK_WIDGET (treeview), ATK_OBJECT (accessible));
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
else
|
2014-02-26 00:47:50 +00:00
|
|
|
{
|
|
|
|
GtkContainerCellAccessible *container;
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2014-02-26 00:47:50 +00:00
|
|
|
container = gtk_container_cell_accessible_new ();
|
|
|
|
_gtk_cell_accessible_initialize (GTK_CELL_ACCESSIBLE (container), GTK_WIDGET (treeview), ATK_OBJECT (accessible));
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2014-02-26 00:47:50 +00:00
|
|
|
for (l = renderer_list; l; l = l->next)
|
|
|
|
{
|
|
|
|
cell = create_cell_accessible_for_renderer (l->data, GTK_WIDGET (treeview), ATK_OBJECT (container));
|
|
|
|
gtk_container_cell_accessible_add_child (container, cell);
|
|
|
|
}
|
|
|
|
|
|
|
|
cell = GTK_CELL_ACCESSIBLE (container);
|
2011-06-30 00:50:50 +00:00
|
|
|
}
|
2014-02-26 00:47:50 +00:00
|
|
|
|
2011-11-23 16:54:49 +00:00
|
|
|
g_list_free (renderer_list);
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2014-02-24 13:07:57 +00:00
|
|
|
return cell;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkCellAccessible *
|
|
|
|
create_cell (GtkTreeView *treeview,
|
|
|
|
GtkTreeViewAccessible *accessible,
|
|
|
|
GtkRBTree *tree,
|
|
|
|
GtkRBNode *node,
|
|
|
|
GtkTreeViewColumn *column)
|
|
|
|
{
|
|
|
|
GtkCellAccessible *cell;
|
|
|
|
|
2014-02-24 13:17:28 +00:00
|
|
|
cell = create_cell_accessible (treeview, accessible, column);
|
|
|
|
cell_info_new (accessible, tree, node, column, cell);
|
2014-02-24 13:07:57 +00:00
|
|
|
|
2012-02-11 03:36:40 +00:00
|
|
|
set_cell_data (treeview, accessible, cell);
|
2015-04-09 00:08:25 +00:00
|
|
|
_gtk_cell_accessible_update_cache (cell, FALSE);
|
2011-12-16 00:02:06 +00:00
|
|
|
|
2012-02-11 03:36:40 +00:00
|
|
|
return cell;
|
|
|
|
}
|
|
|
|
|
|
|
|
static AtkObject *
|
|
|
|
gtk_tree_view_accessible_ref_child (AtkObject *obj,
|
|
|
|
gint i)
|
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkTreeViewAccessible *accessible;
|
|
|
|
GtkCellAccessible *cell;
|
|
|
|
GtkTreeView *tree_view;
|
|
|
|
GtkTreeViewColumn *tv_col;
|
|
|
|
GtkRBTree *tree;
|
|
|
|
GtkRBNode *node;
|
|
|
|
AtkObject *child;
|
|
|
|
|
|
|
|
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
|
|
|
|
if (widget == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (i >= gtk_tree_view_accessible_get_n_children (obj))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
accessible = GTK_TREE_VIEW_ACCESSIBLE (obj);
|
|
|
|
tree_view = GTK_TREE_VIEW (widget);
|
|
|
|
if (i < get_n_columns (tree_view))
|
|
|
|
{
|
|
|
|
tv_col = get_visible_column (tree_view, i);
|
|
|
|
child = get_header_from_column (tv_col);
|
|
|
|
if (child)
|
|
|
|
g_object_ref (child);
|
|
|
|
return child;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Find the RBTree and GtkTreeViewColumn for the index */
|
|
|
|
if (!get_rbtree_column_from_index (tree_view, i, &tree, &node, &tv_col))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
cell = peek_cell (accessible, tree, node, tv_col);
|
|
|
|
if (cell == NULL)
|
|
|
|
cell = create_cell (tree_view, accessible, tree, node, tv_col);
|
|
|
|
|
2017-12-08 22:48:47 +00:00
|
|
|
return (AtkObject *) g_object_ref (cell);
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static AtkStateSet*
|
2011-06-30 00:50:50 +00:00
|
|
|
gtk_tree_view_accessible_ref_state_set (AtkObject *obj)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
AtkStateSet *state_set;
|
|
|
|
GtkWidget *widget;
|
|
|
|
|
2012-12-27 06:04:46 +00:00
|
|
|
state_set = ATK_OBJECT_CLASS (gtk_tree_view_accessible_parent_class)->ref_state_set (obj);
|
2010-05-22 23:55:33 +00:00
|
|
|
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
|
2007-12-18 13:51:12 +00:00
|
|
|
|
|
|
|
if (widget != NULL)
|
|
|
|
atk_state_set_add_state (state_set, ATK_STATE_MANAGES_DESCENDANTS);
|
|
|
|
|
|
|
|
return state_set;
|
|
|
|
}
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
static void
|
2012-12-27 06:04:46 +00:00
|
|
|
gtk_tree_view_accessible_class_init (GtkTreeViewAccessibleClass *klass)
|
2011-06-30 00:50:50 +00:00
|
|
|
{
|
|
|
|
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
2011-07-02 19:23:52 +00:00
|
|
|
GtkAccessibleClass *accessible_class = (GtkAccessibleClass*)klass;
|
|
|
|
GtkWidgetAccessibleClass *widget_class = (GtkWidgetAccessibleClass*)klass;
|
|
|
|
GtkContainerAccessibleClass *container_class = (GtkContainerAccessibleClass*)klass;
|
2011-06-30 00:50:50 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2011-12-18 18:20:15 +00:00
|
|
|
accessible_class->widget_unset = gtk_tree_view_accessible_widget_unset;
|
2011-06-30 00:50:50 +00:00
|
|
|
|
|
|
|
/* The children of a GtkTreeView are the buttons at the top of the columns
|
|
|
|
* we do not represent these as children so we do not want to report
|
|
|
|
* children added or deleted when these changed.
|
|
|
|
*/
|
|
|
|
container_class->add_gtk = NULL;
|
|
|
|
container_class->remove_gtk = NULL;
|
|
|
|
|
|
|
|
gobject_class->finalize = gtk_tree_view_accessible_finalize;
|
|
|
|
}
|
2007-12-18 13:51:12 +00:00
|
|
|
|
|
|
|
static void
|
2012-12-27 06:04:46 +00:00
|
|
|
gtk_tree_view_accessible_init (GtkTreeViewAccessible *view)
|
2011-06-30 00:50:50 +00:00
|
|
|
{
|
2013-06-24 18:13:44 +00:00
|
|
|
view->priv = gtk_tree_view_accessible_get_instance_private (view);
|
2011-06-30 00:50:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* atkcomponent.h */
|
|
|
|
|
|
|
|
static AtkObject *
|
|
|
|
gtk_tree_view_accessible_ref_accessible_at_point (AtkComponent *component,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
AtkCoordType coord_type)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkTreeView *tree_view;
|
|
|
|
GtkTreePath *path;
|
2012-02-11 04:01:34 +00:00
|
|
|
GtkTreeViewColumn *column;
|
2007-12-18 13:51:12 +00:00
|
|
|
gint x_pos, y_pos;
|
2009-02-25 09:55:14 +00:00
|
|
|
gint bx, by;
|
2012-02-11 04:01:34 +00:00
|
|
|
GtkCellAccessible *cell;
|
|
|
|
GtkRBTree *tree;
|
|
|
|
GtkRBNode *node;
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2010-05-22 23:55:33 +00:00
|
|
|
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (component));
|
2007-12-18 13:51:12 +00:00
|
|
|
if (widget == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
tree_view = GTK_TREE_VIEW (widget);
|
|
|
|
|
|
|
|
atk_component_get_extents (component, &x_pos, &y_pos, NULL, NULL, coord_type);
|
2018-03-21 10:49:14 +00:00
|
|
|
gtk_tree_view_convert_widget_to_bin_window_coords (tree_view, x, y, &bx, &by);
|
2012-02-11 04:01:34 +00:00
|
|
|
if (!gtk_tree_view_get_path_at_pos (tree_view,
|
|
|
|
bx - x_pos, by - y_pos,
|
|
|
|
&path, &column, NULL, NULL))
|
|
|
|
return NULL;
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2012-02-11 04:01:34 +00:00
|
|
|
if (_gtk_tree_view_find_node (tree_view, path, &tree, &node))
|
|
|
|
{
|
2007-12-18 13:51:12 +00:00
|
|
|
gtk_tree_path_free (path);
|
2012-02-11 04:01:34 +00:00
|
|
|
return NULL;
|
2011-06-30 00:50:50 +00:00
|
|
|
}
|
2011-11-10 14:01:21 +00:00
|
|
|
|
2012-02-11 04:01:34 +00:00
|
|
|
cell = peek_cell (GTK_TREE_VIEW_ACCESSIBLE (component), tree, node, column);
|
|
|
|
if (cell == NULL)
|
|
|
|
cell = create_cell (tree_view, GTK_TREE_VIEW_ACCESSIBLE (component), tree, node, column);
|
|
|
|
|
2017-12-08 22:48:47 +00:00
|
|
|
return (AtkObject *) g_object_ref (cell);
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
static void
|
|
|
|
atk_component_interface_init (AtkComponentIface *iface)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-06-30 00:50:50 +00:00
|
|
|
iface->ref_accessible_at_point = gtk_tree_view_accessible_ref_accessible_at_point;
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
/* atktable.h */
|
|
|
|
|
2007-12-18 13:51:12 +00:00
|
|
|
static gint
|
2011-06-30 00:50:50 +00:00
|
|
|
gtk_tree_view_accessible_get_index_at (AtkTable *table,
|
|
|
|
gint row,
|
|
|
|
gint column)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
gint n_cols, n_rows;
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
|
|
|
|
if (widget == NULL)
|
|
|
|
return -1;
|
|
|
|
|
2007-12-18 13:51:12 +00:00
|
|
|
n_cols = atk_table_get_n_columns (table);
|
|
|
|
n_rows = atk_table_get_n_rows (table);
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
if (row >= n_rows || column >= n_cols)
|
2007-12-18 13:51:12 +00:00
|
|
|
return -1;
|
|
|
|
|
2011-11-12 04:05:19 +00:00
|
|
|
return (row + 1) * n_cols + column;
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
2011-06-30 00:50:50 +00:00
|
|
|
gtk_tree_view_accessible_get_column_at_index (AtkTable *table,
|
|
|
|
gint index)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
gint n_columns;
|
|
|
|
|
2010-05-22 23:55:33 +00:00
|
|
|
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
|
2007-12-18 13:51:12 +00:00
|
|
|
if (widget == NULL)
|
|
|
|
return -1;
|
|
|
|
|
2011-11-15 20:30:46 +00:00
|
|
|
if (index >= gtk_tree_view_accessible_get_n_children (ATK_OBJECT (table)))
|
|
|
|
return -1;
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2011-11-15 15:45:48 +00:00
|
|
|
n_columns = get_n_columns (GTK_TREE_VIEW (widget));
|
2011-06-30 00:50:50 +00:00
|
|
|
|
2011-11-15 20:30:46 +00:00
|
|
|
/* checked by the n_children() check above */
|
|
|
|
g_assert (n_columns > 0);
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2011-11-15 20:30:46 +00:00
|
|
|
return index % n_columns;
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
2011-06-30 00:50:50 +00:00
|
|
|
gtk_tree_view_accessible_get_row_at_index (AtkTable *table,
|
|
|
|
gint index)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkTreeView *tree_view;
|
|
|
|
|
2010-05-22 23:55:33 +00:00
|
|
|
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
|
2007-12-18 13:51:12 +00:00
|
|
|
if (widget == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
tree_view = GTK_TREE_VIEW (widget);
|
2011-11-12 03:56:29 +00:00
|
|
|
|
2011-11-15 15:45:48 +00:00
|
|
|
index /= get_n_columns (tree_view);
|
2011-11-12 03:56:29 +00:00
|
|
|
index--;
|
|
|
|
if (index >= get_n_rows (tree_view))
|
2007-12-18 13:51:12 +00:00
|
|
|
return -1;
|
2011-11-12 03:56:29 +00:00
|
|
|
|
|
|
|
return index;
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
static AtkObject *
|
|
|
|
gtk_tree_view_accessible_table_ref_at (AtkTable *table,
|
|
|
|
gint row,
|
|
|
|
gint column)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
gint index;
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
index = gtk_tree_view_accessible_get_index_at (table, row, column);
|
2007-12-18 13:51:12 +00:00
|
|
|
if (index == -1)
|
|
|
|
return NULL;
|
2011-06-30 00:50:50 +00:00
|
|
|
|
|
|
|
return gtk_tree_view_accessible_ref_child (ATK_OBJECT (table), index);
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
static gint
|
|
|
|
gtk_tree_view_accessible_get_n_rows (AtkTable *table)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
|
2010-05-22 23:55:33 +00:00
|
|
|
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
|
2007-12-18 13:51:12 +00:00
|
|
|
if (widget == NULL)
|
|
|
|
return 0;
|
|
|
|
|
2011-11-12 03:56:29 +00:00
|
|
|
return get_n_rows (GTK_TREE_VIEW (widget));
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2011-06-23 02:27:10 +00:00
|
|
|
static gint
|
2011-06-30 00:50:50 +00:00
|
|
|
gtk_tree_view_accessible_get_n_columns (AtkTable *table)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
|
2010-05-22 23:55:33 +00:00
|
|
|
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
|
2007-12-18 13:51:12 +00:00
|
|
|
if (widget == NULL)
|
|
|
|
return 0;
|
|
|
|
|
2011-11-15 15:45:48 +00:00
|
|
|
return get_n_columns (GTK_TREE_VIEW (widget));
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
static gboolean
|
|
|
|
gtk_tree_view_accessible_is_row_selected (AtkTable *table,
|
|
|
|
gint row)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
2011-12-12 16:59:36 +00:00
|
|
|
GtkRBTree *tree;
|
|
|
|
GtkRBNode *node;
|
|
|
|
|
|
|
|
if (row < 0)
|
|
|
|
return FALSE;
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2010-05-22 23:55:33 +00:00
|
|
|
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
|
2007-12-18 13:51:12 +00:00
|
|
|
if (widget == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
2011-12-12 16:59:36 +00:00
|
|
|
if (!_gtk_rbtree_find_index (_gtk_tree_view_get_rbtree (GTK_TREE_VIEW (widget)),
|
|
|
|
row,
|
|
|
|
&tree,
|
|
|
|
&node))
|
2007-12-18 13:51:12 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2011-12-12 16:59:36 +00:00
|
|
|
return GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED);
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
static gboolean
|
|
|
|
gtk_tree_view_accessible_is_selected (AtkTable *table,
|
|
|
|
gint row,
|
|
|
|
gint column)
|
|
|
|
{
|
|
|
|
return gtk_tree_view_accessible_is_row_selected (table, row);
|
|
|
|
}
|
|
|
|
|
2011-12-12 17:00:19 +00:00
|
|
|
typedef struct {
|
|
|
|
GArray *array;
|
|
|
|
GtkTreeView *treeview;
|
|
|
|
} SelectedRowsData;
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
static void
|
|
|
|
get_selected_rows (GtkTreeModel *model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeIter *iter,
|
2011-12-12 17:00:19 +00:00
|
|
|
gpointer datap)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-12-12 17:00:19 +00:00
|
|
|
SelectedRowsData *data = datap;
|
|
|
|
GtkRBTree *tree;
|
|
|
|
GtkRBNode *node;
|
|
|
|
int id;
|
|
|
|
|
|
|
|
if (_gtk_tree_view_find_node (data->treeview,
|
|
|
|
path,
|
|
|
|
&tree, &node))
|
|
|
|
{
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
2011-06-30 00:50:50 +00:00
|
|
|
|
2011-12-12 17:00:19 +00:00
|
|
|
id = _gtk_rbtree_node_get_index (tree, node);
|
|
|
|
|
|
|
|
g_array_append_val (data->array, id);
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
static gint
|
|
|
|
gtk_tree_view_accessible_get_selected_rows (AtkTable *table,
|
|
|
|
gint **rows_selected)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-12-12 17:00:19 +00:00
|
|
|
SelectedRowsData data;
|
2007-12-18 13:51:12 +00:00
|
|
|
GtkWidget *widget;
|
2011-12-12 17:00:19 +00:00
|
|
|
gint n_rows;
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2010-05-22 23:55:33 +00:00
|
|
|
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
|
2007-12-18 13:51:12 +00:00
|
|
|
if (widget == NULL)
|
2013-11-20 17:25:25 +00:00
|
|
|
{
|
|
|
|
if (rows_selected != NULL)
|
|
|
|
*rows_selected = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2011-12-12 17:00:19 +00:00
|
|
|
data.treeview = GTK_TREE_VIEW (widget);
|
|
|
|
data.array = g_array_new (FALSE, FALSE, sizeof (gint));
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2011-12-12 17:00:19 +00:00
|
|
|
gtk_tree_selection_selected_foreach (gtk_tree_view_get_selection (data.treeview),
|
|
|
|
get_selected_rows,
|
|
|
|
&data);
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2011-12-12 17:00:19 +00:00
|
|
|
n_rows = data.array->len;
|
|
|
|
if (rows_selected)
|
|
|
|
*rows_selected = (gint *) g_array_free (data.array, FALSE);
|
|
|
|
else
|
|
|
|
g_array_free (data.array, TRUE);
|
|
|
|
|
|
|
|
return n_rows;
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
static gboolean
|
|
|
|
gtk_tree_view_accessible_add_row_selection (AtkTable *table,
|
|
|
|
gint row)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-12-12 17:10:04 +00:00
|
|
|
GtkTreeView *treeview;
|
|
|
|
GtkTreePath *path;
|
|
|
|
GtkRBTree *tree;
|
|
|
|
GtkRBNode *node;
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2011-12-12 17:10:04 +00:00
|
|
|
if (row < 0)
|
2007-12-18 13:51:12 +00:00
|
|
|
return FALSE;
|
2011-06-30 00:50:50 +00:00
|
|
|
|
2011-12-12 17:10:04 +00:00
|
|
|
treeview = GTK_TREE_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (table)));
|
|
|
|
if (treeview == NULL)
|
|
|
|
return FALSE;
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2011-12-12 17:10:04 +00:00
|
|
|
if (!_gtk_rbtree_find_index (_gtk_tree_view_get_rbtree (treeview),
|
|
|
|
row,
|
|
|
|
&tree,
|
|
|
|
&node))
|
|
|
|
return FALSE;
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2011-12-12 17:10:04 +00:00
|
|
|
if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
path = _gtk_tree_path_new_from_rbtree (tree, node);
|
|
|
|
gtk_tree_selection_select_path (gtk_tree_view_get_selection (treeview), path);
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
|
|
|
return TRUE;
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
static gboolean
|
|
|
|
gtk_tree_view_accessible_remove_row_selection (AtkTable *table,
|
|
|
|
gint row)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-12-12 17:10:04 +00:00
|
|
|
GtkTreeView *treeview;
|
|
|
|
GtkTreePath *path;
|
|
|
|
GtkRBTree *tree;
|
|
|
|
GtkRBNode *node;
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2011-12-12 17:10:04 +00:00
|
|
|
if (row < 0)
|
2007-12-18 13:51:12 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2011-12-12 17:10:04 +00:00
|
|
|
treeview = GTK_TREE_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (table)));
|
|
|
|
if (treeview == NULL)
|
|
|
|
return FALSE;
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2011-12-12 17:10:04 +00:00
|
|
|
if (!_gtk_rbtree_find_index (_gtk_tree_view_get_rbtree (treeview),
|
|
|
|
row,
|
|
|
|
&tree,
|
|
|
|
&node))
|
|
|
|
return FALSE;
|
2011-06-30 00:50:50 +00:00
|
|
|
|
2011-12-12 17:10:04 +00:00
|
|
|
if (! GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
path = _gtk_tree_path_new_from_rbtree (tree, node);
|
|
|
|
gtk_tree_selection_unselect_path (gtk_tree_view_get_selection (treeview), path);
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
|
|
|
return TRUE;
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
static AtkObject *
|
|
|
|
gtk_tree_view_accessible_get_column_header (AtkTable *table,
|
|
|
|
gint in_col)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkTreeView *tree_view;
|
|
|
|
GtkTreeViewColumn *tv_col;
|
|
|
|
|
2010-05-22 23:55:33 +00:00
|
|
|
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
|
2007-12-18 13:51:12 +00:00
|
|
|
if (widget == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
tree_view = GTK_TREE_VIEW (widget);
|
2011-11-16 01:40:49 +00:00
|
|
|
if (in_col < 0 || in_col >= get_n_columns (tree_view))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
tv_col = get_visible_column (tree_view, in_col);
|
2007-12-18 13:51:12 +00:00
|
|
|
return get_header_from_column (tv_col);
|
|
|
|
}
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
static const gchar *
|
|
|
|
gtk_tree_view_accessible_get_column_description (AtkTable *table,
|
|
|
|
gint in_col)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkTreeView *tree_view;
|
|
|
|
GtkTreeViewColumn *tv_col;
|
|
|
|
|
2010-05-22 23:55:33 +00:00
|
|
|
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
|
2007-12-18 13:51:12 +00:00
|
|
|
if (widget == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
tree_view = GTK_TREE_VIEW (widget);
|
2011-11-16 01:40:49 +00:00
|
|
|
if (in_col < 0 || in_col >= get_n_columns (tree_view))
|
|
|
|
return NULL;
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2011-11-16 01:40:49 +00:00
|
|
|
tv_col = get_visible_column (tree_view, in_col);
|
2011-06-30 00:50:50 +00:00
|
|
|
return gtk_tree_view_column_get_title (tv_col);
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
static void
|
|
|
|
atk_table_interface_init (AtkTableIface *iface)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-06-30 00:50:50 +00:00
|
|
|
iface->ref_at = gtk_tree_view_accessible_table_ref_at;
|
|
|
|
iface->get_n_rows = gtk_tree_view_accessible_get_n_rows;
|
|
|
|
iface->get_n_columns = gtk_tree_view_accessible_get_n_columns;
|
|
|
|
iface->get_index_at = gtk_tree_view_accessible_get_index_at;
|
|
|
|
iface->get_column_at_index = gtk_tree_view_accessible_get_column_at_index;
|
|
|
|
iface->get_row_at_index = gtk_tree_view_accessible_get_row_at_index;
|
|
|
|
iface->is_row_selected = gtk_tree_view_accessible_is_row_selected;
|
|
|
|
iface->is_selected = gtk_tree_view_accessible_is_selected;
|
|
|
|
iface->get_selected_rows = gtk_tree_view_accessible_get_selected_rows;
|
|
|
|
iface->add_row_selection = gtk_tree_view_accessible_add_row_selection;
|
|
|
|
iface->remove_row_selection = gtk_tree_view_accessible_remove_row_selection;
|
|
|
|
iface->get_column_extent_at = NULL;
|
|
|
|
iface->get_row_extent_at = NULL;
|
|
|
|
iface->get_column_header = gtk_tree_view_accessible_get_column_header;
|
|
|
|
iface->get_column_description = gtk_tree_view_accessible_get_column_description;
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
/* atkselection.h */
|
|
|
|
|
2007-12-18 13:51:12 +00:00
|
|
|
static gboolean
|
2011-06-30 00:50:50 +00:00
|
|
|
gtk_tree_view_accessible_add_selection (AtkSelection *selection,
|
|
|
|
gint i)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
AtkTable *table;
|
|
|
|
gint n_columns;
|
|
|
|
gint row;
|
|
|
|
|
|
|
|
table = ATK_TABLE (selection);
|
2011-06-30 00:50:50 +00:00
|
|
|
n_columns = gtk_tree_view_accessible_get_n_columns (table);
|
2007-12-18 13:51:12 +00:00
|
|
|
if (n_columns != 1)
|
|
|
|
return FALSE;
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
row = gtk_tree_view_accessible_get_row_at_index (table, i);
|
|
|
|
return gtk_tree_view_accessible_add_row_selection (table, row);
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2011-06-30 00:50:50 +00:00
|
|
|
gtk_tree_view_accessible_clear_selection (AtkSelection *selection)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkTreeView *tree_view;
|
|
|
|
GtkTreeSelection *tree_selection;
|
|
|
|
|
2010-05-22 23:55:33 +00:00
|
|
|
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
|
2007-12-18 13:51:12 +00:00
|
|
|
if (widget == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
tree_view = GTK_TREE_VIEW (widget);
|
2007-12-18 13:51:12 +00:00
|
|
|
tree_selection = gtk_tree_view_get_selection (tree_view);
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
gtk_tree_selection_unselect_all (tree_selection);
|
2007-12-18 13:51:12 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
static AtkObject *
|
|
|
|
gtk_tree_view_accessible_ref_selection (AtkSelection *selection,
|
|
|
|
gint i)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
AtkTable *table;
|
|
|
|
gint row;
|
|
|
|
gint n_selected;
|
|
|
|
gint n_columns;
|
|
|
|
gint *selected;
|
|
|
|
|
|
|
|
table = ATK_TABLE (selection);
|
2011-06-30 00:50:50 +00:00
|
|
|
n_columns = gtk_tree_view_accessible_get_n_columns (table);
|
|
|
|
n_selected = gtk_tree_view_accessible_get_selected_rows (table, &selected);
|
2013-11-20 17:25:48 +00:00
|
|
|
if (n_columns == 0 || i >= n_columns * n_selected)
|
2007-12-18 13:51:12 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
row = selected[i / n_columns];
|
|
|
|
g_free (selected);
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
return gtk_tree_view_accessible_table_ref_at (table, row, i % n_columns);
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
2011-06-30 00:50:50 +00:00
|
|
|
gtk_tree_view_accessible_get_selection_count (AtkSelection *selection)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
AtkTable *table;
|
|
|
|
gint n_selected;
|
|
|
|
|
|
|
|
table = ATK_TABLE (selection);
|
2011-06-30 00:50:50 +00:00
|
|
|
n_selected = gtk_tree_view_accessible_get_selected_rows (table, NULL);
|
2007-12-18 13:51:12 +00:00
|
|
|
if (n_selected > 0)
|
2011-06-30 00:50:50 +00:00
|
|
|
n_selected *= gtk_tree_view_accessible_get_n_columns (table);
|
2007-12-18 13:51:12 +00:00
|
|
|
return n_selected;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2011-06-30 00:50:50 +00:00
|
|
|
gtk_tree_view_accessible_is_child_selected (AtkSelection *selection,
|
|
|
|
gint i)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
gint row;
|
|
|
|
|
2010-05-22 23:55:33 +00:00
|
|
|
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
|
2007-12-18 13:51:12 +00:00
|
|
|
if (widget == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
2014-03-29 20:51:31 +00:00
|
|
|
row = gtk_tree_view_accessible_get_row_at_index (ATK_TABLE (selection), i);
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
return gtk_tree_view_accessible_is_row_selected (ATK_TABLE (selection), row);
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
static void atk_selection_interface_init (AtkSelectionIface *iface)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-06-30 00:50:50 +00:00
|
|
|
iface->add_selection = gtk_tree_view_accessible_add_selection;
|
|
|
|
iface->clear_selection = gtk_tree_view_accessible_clear_selection;
|
|
|
|
iface->ref_selection = gtk_tree_view_accessible_ref_selection;
|
|
|
|
iface->get_selection_count = gtk_tree_view_accessible_get_selection_count;
|
|
|
|
iface->is_child_selected = gtk_tree_view_accessible_is_child_selected;
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define EXTRA_EXPANDER_PADDING 4
|
|
|
|
|
|
|
|
static void
|
2011-07-10 03:56:42 +00:00
|
|
|
gtk_tree_view_accessible_get_cell_area (GtkCellAccessibleParent *parent,
|
|
|
|
GtkCellAccessible *cell,
|
|
|
|
GdkRectangle *cell_rect)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkTreeView *tree_view;
|
|
|
|
GtkTreeViewColumn *tv_col;
|
|
|
|
GtkTreePath *path;
|
|
|
|
AtkObject *parent_cell;
|
2011-06-30 00:50:50 +00:00
|
|
|
GtkTreeViewAccessibleCellInfo *cell_info;
|
2011-07-09 22:30:59 +00:00
|
|
|
GtkCellAccessible *top_cell;
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2013-11-20 17:25:25 +00:00
|
|
|
/* Default value. */
|
|
|
|
cell_rect->x = 0;
|
|
|
|
cell_rect->y = 0;
|
|
|
|
cell_rect->width = 0;
|
|
|
|
cell_rect->height = 0;
|
|
|
|
|
2010-05-22 23:55:33 +00:00
|
|
|
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (parent));
|
2007-12-18 13:51:12 +00:00
|
|
|
if (widget == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
tree_view = GTK_TREE_VIEW (widget);
|
|
|
|
parent_cell = atk_object_get_parent (ATK_OBJECT (cell));
|
|
|
|
if (parent_cell != ATK_OBJECT (parent))
|
2011-07-09 22:30:59 +00:00
|
|
|
top_cell = GTK_CELL_ACCESSIBLE (parent_cell);
|
2007-12-18 13:51:12 +00:00
|
|
|
else
|
2011-07-09 22:30:59 +00:00
|
|
|
top_cell = cell;
|
2011-11-13 03:28:52 +00:00
|
|
|
cell_info = find_cell_info (GTK_TREE_VIEW_ACCESSIBLE (parent), top_cell);
|
2011-11-12 02:20:12 +00:00
|
|
|
if (!cell_info)
|
2011-06-29 03:42:50 +00:00
|
|
|
return;
|
2011-11-12 02:18:13 +00:00
|
|
|
path = cell_info_get_path (cell_info);
|
2007-12-18 13:51:12 +00:00
|
|
|
tv_col = cell_info->cell_col_ref;
|
2011-11-11 19:30:39 +00:00
|
|
|
if (path)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
GtkTreeViewColumn *expander_column;
|
|
|
|
|
|
|
|
gtk_tree_view_get_cell_area (tree_view, path, tv_col, cell_rect);
|
|
|
|
expander_column = gtk_tree_view_get_expander_column (tree_view);
|
|
|
|
if (expander_column == tv_col)
|
|
|
|
{
|
2017-06-18 10:54:27 +00:00
|
|
|
/* Values from gtktreeview.c ... */
|
|
|
|
#define _TREE_VIEW_EXPANDER_SIZE 16
|
|
|
|
#define _TREE_VIEW_HORIZONTAL_SEPARATOR 4
|
|
|
|
gint expander_size = _TREE_VIEW_EXPANDER_SIZE + (_TREE_VIEW_HORIZONTAL_SEPARATOR / 2);
|
2007-12-18 13:51:12 +00:00
|
|
|
cell_rect->x += expander_size + EXTRA_EXPANDER_PADDING;
|
|
|
|
cell_rect->width -= expander_size + EXTRA_EXPANDER_PADDING;
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
/* A column has more than one renderer so we find the position
|
|
|
|
* and width of each
|
2007-12-18 13:51:12 +00:00
|
|
|
*/
|
|
|
|
if (top_cell != cell)
|
|
|
|
{
|
|
|
|
gint cell_index;
|
|
|
|
gboolean found;
|
|
|
|
gint cell_start;
|
|
|
|
gint cell_width;
|
|
|
|
GList *renderers;
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
cell_index = atk_object_get_index_in_parent (ATK_OBJECT (cell));
|
|
|
|
renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (tv_col));
|
|
|
|
renderer = g_list_nth_data (renderers, cell_index);
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
found = gtk_tree_view_column_cell_get_position (tv_col, renderer, &cell_start, &cell_width);
|
2007-12-18 13:51:12 +00:00
|
|
|
if (found)
|
|
|
|
{
|
|
|
|
cell_rect->x += cell_start;
|
|
|
|
cell_rect->width = cell_width;
|
|
|
|
}
|
2011-06-30 00:50:50 +00:00
|
|
|
g_list_free (renderers);
|
|
|
|
}
|
2007-12-18 13:51:12 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
static void
|
2011-07-10 03:56:42 +00:00
|
|
|
gtk_tree_view_accessible_get_cell_extents (GtkCellAccessibleParent *parent,
|
|
|
|
GtkCellAccessible *cell,
|
|
|
|
gint *x,
|
|
|
|
gint *y,
|
|
|
|
gint *width,
|
|
|
|
gint *height,
|
|
|
|
AtkCoordType coord_type)
|
2011-06-30 00:50:50 +00:00
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkTreeView *tree_view;
|
|
|
|
GdkRectangle cell_rect;
|
|
|
|
gint w_x, w_y;
|
|
|
|
|
|
|
|
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (parent));
|
|
|
|
if (widget == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
tree_view = GTK_TREE_VIEW (widget);
|
|
|
|
gtk_tree_view_accessible_get_cell_area (parent, cell, &cell_rect);
|
2018-03-21 10:49:14 +00:00
|
|
|
gtk_tree_view_convert_widget_to_bin_window_coords (tree_view,
|
2017-01-07 15:07:21 +00:00
|
|
|
0, 0,
|
|
|
|
&w_x, &w_y);
|
2011-06-30 00:50:50 +00:00
|
|
|
|
2017-01-07 15:07:21 +00:00
|
|
|
if (coord_type != ATK_XY_WINDOW)
|
2011-06-30 00:50:50 +00:00
|
|
|
{
|
2018-03-21 10:49:14 +00:00
|
|
|
GdkSurface *surface;
|
2011-06-30 00:50:50 +00:00
|
|
|
gint x_toplevel, y_toplevel;
|
|
|
|
|
2018-03-21 10:49:14 +00:00
|
|
|
surface = gdk_surface_get_toplevel (gtk_widget_get_surface (widget));
|
|
|
|
gdk_surface_get_origin (surface, &x_toplevel, &y_toplevel);
|
2011-06-30 00:50:50 +00:00
|
|
|
|
2017-01-07 15:07:21 +00:00
|
|
|
w_x += x_toplevel;
|
|
|
|
w_y += y_toplevel;
|
2011-06-30 00:50:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
*width = cell_rect.width;
|
|
|
|
*height = cell_rect.height;
|
|
|
|
if (is_cell_showing (tree_view, &cell_rect))
|
|
|
|
{
|
|
|
|
*x = cell_rect.x + w_x;
|
|
|
|
*y = cell_rect.y + w_y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*x = G_MININT;
|
|
|
|
*y = G_MININT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-18 13:51:12 +00:00
|
|
|
static gboolean
|
2011-07-10 03:56:42 +00:00
|
|
|
gtk_tree_view_accessible_grab_cell_focus (GtkCellAccessibleParent *parent,
|
|
|
|
GtkCellAccessible *cell)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkTreeView *tree_view;
|
|
|
|
GtkTreeViewColumn *tv_col;
|
|
|
|
GtkTreePath *path;
|
|
|
|
AtkObject *parent_cell;
|
|
|
|
AtkObject *cell_object;
|
2011-06-30 00:50:50 +00:00
|
|
|
GtkTreeViewAccessibleCellInfo *cell_info;
|
2007-12-18 13:51:12 +00:00
|
|
|
GtkCellRenderer *renderer = NULL;
|
|
|
|
GtkWidget *toplevel;
|
|
|
|
gint index;
|
|
|
|
|
2010-05-22 23:55:33 +00:00
|
|
|
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (parent));
|
2007-12-18 13:51:12 +00:00
|
|
|
if (widget == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
tree_view = GTK_TREE_VIEW (widget);
|
|
|
|
|
2011-11-13 03:28:52 +00:00
|
|
|
cell_info = find_cell_info (GTK_TREE_VIEW_ACCESSIBLE (parent), cell);
|
2011-11-12 02:20:12 +00:00
|
|
|
if (!cell_info)
|
2011-06-29 03:42:50 +00:00
|
|
|
return FALSE;
|
2007-12-18 13:51:12 +00:00
|
|
|
cell_object = ATK_OBJECT (cell);
|
|
|
|
parent_cell = atk_object_get_parent (cell_object);
|
|
|
|
tv_col = cell_info->cell_col_ref;
|
|
|
|
if (parent_cell != ATK_OBJECT (parent))
|
|
|
|
{
|
2011-07-09 22:51:27 +00:00
|
|
|
/* GtkCellAccessible is in a GtkContainerCellAccessible.
|
2011-06-30 00:50:50 +00:00
|
|
|
* The GtkTreeViewColumn has multiple renderers;
|
2007-12-18 13:51:12 +00:00
|
|
|
* find the corresponding one.
|
|
|
|
*/
|
|
|
|
GList *renderers;
|
|
|
|
|
2009-06-16 16:37:33 +00:00
|
|
|
renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (tv_col));
|
2011-11-11 19:30:39 +00:00
|
|
|
index = atk_object_get_index_in_parent (cell_object);
|
|
|
|
renderer = g_list_nth_data (renderers, index);
|
2007-12-18 13:51:12 +00:00
|
|
|
g_list_free (renderers);
|
|
|
|
}
|
2011-11-12 02:18:13 +00:00
|
|
|
path = cell_info_get_path (cell_info);
|
2011-11-11 19:30:39 +00:00
|
|
|
if (path)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
if (renderer)
|
|
|
|
gtk_tree_view_set_cursor_on_cell (tree_view, path, tv_col, renderer, FALSE);
|
|
|
|
else
|
|
|
|
gtk_tree_view_set_cursor (tree_view, path, tv_col, FALSE);
|
|
|
|
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
gtk_widget_grab_focus (widget);
|
|
|
|
toplevel = gtk_widget_get_toplevel (widget);
|
2010-01-04 06:49:26 +00:00
|
|
|
if (gtk_widget_is_toplevel (toplevel))
|
2011-06-30 00:50:50 +00:00
|
|
|
{
|
2007-12-18 13:51:12 +00:00
|
|
|
#ifdef GDK_WINDOWING_X11
|
2011-06-30 00:50:50 +00:00
|
|
|
gtk_window_present_with_time (GTK_WINDOW (toplevel),
|
2018-03-20 14:21:12 +00:00
|
|
|
gdk_x11_get_server_time (gtk_widget_get_surface (widget)));
|
2007-12-18 13:51:12 +00:00
|
|
|
#else
|
2011-06-30 00:50:50 +00:00
|
|
|
gtk_window_present (GTK_WINDOW (toplevel));
|
2007-12-18 13:51:12 +00:00
|
|
|
#endif
|
2011-06-30 00:50:50 +00:00
|
|
|
}
|
2007-12-18 13:51:12 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
2011-06-30 00:50:50 +00:00
|
|
|
return FALSE;
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2011-11-11 01:19:28 +00:00
|
|
|
static int
|
2011-11-11 01:48:40 +00:00
|
|
|
gtk_tree_view_accessible_get_child_index (GtkCellAccessibleParent *parent,
|
|
|
|
GtkCellAccessible *cell)
|
2011-11-11 01:19:28 +00:00
|
|
|
{
|
|
|
|
GtkTreeViewAccessibleCellInfo *cell_info;
|
2011-11-11 01:48:40 +00:00
|
|
|
GtkTreeView *tree_view;
|
2011-11-11 01:19:28 +00:00
|
|
|
|
2011-11-13 03:28:52 +00:00
|
|
|
cell_info = find_cell_info (GTK_TREE_VIEW_ACCESSIBLE (parent), cell);
|
2011-11-12 02:20:12 +00:00
|
|
|
if (!cell_info)
|
2011-11-11 01:19:28 +00:00
|
|
|
return -1;
|
|
|
|
|
2011-11-11 01:48:40 +00:00
|
|
|
tree_view = GTK_TREE_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (parent)));
|
|
|
|
|
|
|
|
return cell_info_get_index (tree_view, cell_info);
|
2011-11-11 01:19:28 +00:00
|
|
|
}
|
|
|
|
|
2011-11-24 00:55:38 +00:00
|
|
|
static GtkCellRendererState
|
|
|
|
gtk_tree_view_accessible_get_renderer_state (GtkCellAccessibleParent *parent,
|
2011-12-11 02:02:12 +00:00
|
|
|
GtkCellAccessible *cell)
|
2011-11-24 00:55:38 +00:00
|
|
|
{
|
|
|
|
GtkTreeViewAccessibleCellInfo *cell_info;
|
|
|
|
GtkTreeView *treeview;
|
|
|
|
GtkCellRendererState flags;
|
|
|
|
|
|
|
|
cell_info = find_cell_info (GTK_TREE_VIEW_ACCESSIBLE (parent), cell);
|
|
|
|
if (!cell_info)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
flags = 0;
|
|
|
|
|
|
|
|
if (GTK_RBNODE_FLAG_SET (cell_info->node, GTK_RBNODE_IS_SELECTED))
|
|
|
|
flags |= GTK_CELL_RENDERER_SELECTED;
|
|
|
|
|
|
|
|
if (GTK_RBNODE_FLAG_SET (cell_info->node, GTK_RBNODE_IS_PRELIT))
|
|
|
|
flags |= GTK_CELL_RENDERER_PRELIT;
|
|
|
|
|
|
|
|
if (gtk_tree_view_column_get_sort_indicator (cell_info->cell_col_ref))
|
|
|
|
flags |= GTK_CELL_RENDERER_SORTED;
|
|
|
|
|
|
|
|
treeview = GTK_TREE_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (parent)));
|
2011-12-11 01:57:36 +00:00
|
|
|
|
|
|
|
if (cell_info->cell_col_ref == gtk_tree_view_get_expander_column (treeview))
|
|
|
|
{
|
|
|
|
if (GTK_RBNODE_FLAG_SET (cell_info->node, GTK_RBNODE_IS_PARENT))
|
|
|
|
flags |= GTK_CELL_RENDERER_EXPANDABLE;
|
|
|
|
|
|
|
|
if (cell_info->node->children)
|
|
|
|
flags |= GTK_CELL_RENDERER_EXPANDED;
|
|
|
|
}
|
|
|
|
|
2011-11-24 00:55:38 +00:00
|
|
|
if (gtk_widget_has_focus (GTK_WIDGET (treeview)))
|
|
|
|
{
|
|
|
|
GtkTreeViewColumn *column;
|
|
|
|
GtkTreePath *path;
|
|
|
|
GtkRBTree *tree;
|
2013-11-20 17:25:25 +00:00
|
|
|
GtkRBNode *node = NULL;
|
2011-11-24 00:55:38 +00:00
|
|
|
|
|
|
|
gtk_tree_view_get_cursor (treeview, &path, &column);
|
|
|
|
if (path)
|
|
|
|
{
|
|
|
|
_gtk_tree_view_find_node (treeview, path, &tree, &node);
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
tree = NULL;
|
|
|
|
|
|
|
|
if (cell_info->cell_col_ref == column
|
|
|
|
&& cell_info->tree == tree
|
|
|
|
&& cell_info->node == node)
|
|
|
|
flags |= GTK_CELL_RENDERER_FOCUSED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
2011-12-12 14:18:54 +00:00
|
|
|
static void
|
|
|
|
gtk_tree_view_accessible_expand_collapse (GtkCellAccessibleParent *parent,
|
|
|
|
GtkCellAccessible *cell)
|
|
|
|
{
|
|
|
|
GtkTreeViewAccessibleCellInfo *cell_info;
|
|
|
|
GtkTreeView *treeview;
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
|
|
|
treeview = GTK_TREE_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (parent)));
|
|
|
|
|
|
|
|
cell_info = find_cell_info (GTK_TREE_VIEW_ACCESSIBLE (parent), cell);
|
|
|
|
if (!cell_info ||
|
|
|
|
cell_info->cell_col_ref != gtk_tree_view_get_expander_column (treeview))
|
|
|
|
return;
|
|
|
|
|
|
|
|
path = cell_info_get_path (cell_info);
|
|
|
|
|
|
|
|
if (cell_info->node->children)
|
|
|
|
gtk_tree_view_collapse_row (treeview, path);
|
|
|
|
else
|
|
|
|
gtk_tree_view_expand_row (treeview, path, FALSE);
|
|
|
|
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_tree_view_accessible_activate (GtkCellAccessibleParent *parent,
|
|
|
|
GtkCellAccessible *cell)
|
|
|
|
{
|
|
|
|
GtkTreeViewAccessibleCellInfo *cell_info;
|
|
|
|
GtkTreeView *treeview;
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
|
|
|
treeview = GTK_TREE_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (parent)));
|
|
|
|
|
|
|
|
cell_info = find_cell_info (GTK_TREE_VIEW_ACCESSIBLE (parent), cell);
|
|
|
|
if (!cell_info)
|
|
|
|
return;
|
|
|
|
|
|
|
|
path = cell_info_get_path (cell_info);
|
|
|
|
|
|
|
|
gtk_tree_view_row_activated (treeview, path, cell_info->cell_col_ref);
|
|
|
|
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_tree_view_accessible_edit (GtkCellAccessibleParent *parent,
|
|
|
|
GtkCellAccessible *cell)
|
|
|
|
{
|
|
|
|
GtkTreeView *treeview;
|
|
|
|
|
|
|
|
if (!gtk_tree_view_accessible_grab_cell_focus (parent, cell))
|
|
|
|
return;
|
|
|
|
|
|
|
|
treeview = GTK_TREE_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (parent)));
|
|
|
|
|
|
|
|
g_signal_emit_by_name (treeview,
|
|
|
|
"real-select-cursor-row",
|
|
|
|
TRUE);
|
|
|
|
}
|
|
|
|
|
2014-03-24 15:34:08 +00:00
|
|
|
static void
|
|
|
|
gtk_tree_view_accessible_update_relationset (GtkCellAccessibleParent *parent,
|
|
|
|
GtkCellAccessible *cell,
|
|
|
|
AtkRelationSet *relationset)
|
|
|
|
{
|
|
|
|
GtkTreeViewAccessibleCellInfo *cell_info;
|
|
|
|
GtkTreeViewAccessible *accessible;
|
|
|
|
GtkTreeViewColumn *column;
|
|
|
|
GtkTreeView *treeview;
|
|
|
|
AtkRelation *relation;
|
|
|
|
GtkRBTree *tree;
|
|
|
|
GtkRBNode *node;
|
|
|
|
AtkObject *object;
|
|
|
|
|
|
|
|
/* Don't set relations on cells that aren't direct descendants of the treeview.
|
|
|
|
* So only set it on the container, not on the renderer accessibles */
|
|
|
|
if (atk_object_get_parent (ATK_OBJECT (cell)) != ATK_OBJECT (parent))
|
|
|
|
return;
|
|
|
|
|
|
|
|
accessible = GTK_TREE_VIEW_ACCESSIBLE (parent);
|
|
|
|
cell_info = find_cell_info (accessible, cell);
|
|
|
|
if (!cell_info)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* only set parent/child rows on the expander column */
|
|
|
|
treeview = GTK_TREE_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (parent)));
|
|
|
|
column = gtk_tree_view_get_expander_column (treeview);
|
|
|
|
if (column != cell_info->cell_col_ref)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Update CHILD_OF relation to parent cell */
|
|
|
|
relation = atk_relation_set_get_relation_by_type (relationset, ATK_RELATION_NODE_CHILD_OF);
|
|
|
|
if (relation)
|
|
|
|
atk_relation_set_remove (relationset, relation);
|
|
|
|
|
|
|
|
if (cell_info->tree->parent_tree)
|
|
|
|
{
|
|
|
|
object = ATK_OBJECT (peek_cell (accessible, cell_info->tree->parent_tree, cell_info->tree->parent_node, column));
|
|
|
|
if (object == NULL)
|
|
|
|
object = ATK_OBJECT (create_cell (treeview, accessible, cell_info->tree->parent_tree, cell_info->tree->parent_node, column));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
object = ATK_OBJECT (accessible);
|
|
|
|
|
|
|
|
atk_relation_set_add_relation_by_type (relationset, ATK_RELATION_NODE_CHILD_OF, object);
|
|
|
|
|
|
|
|
/* Update PARENT_OF relation for all child cells */
|
|
|
|
relation = atk_relation_set_get_relation_by_type (relationset, ATK_RELATION_NODE_PARENT_OF);
|
|
|
|
if (relation)
|
|
|
|
atk_relation_set_remove (relationset, relation);
|
|
|
|
|
|
|
|
tree = cell_info->node->children;
|
|
|
|
if (tree)
|
|
|
|
{
|
|
|
|
for (node = _gtk_rbtree_first (tree);
|
|
|
|
node != NULL;
|
|
|
|
node = _gtk_rbtree_next (tree, node))
|
|
|
|
{
|
|
|
|
object = ATK_OBJECT (peek_cell (accessible, tree, node, column));
|
|
|
|
if (object == NULL)
|
|
|
|
object = ATK_OBJECT (create_cell (treeview, accessible, tree, node, column));
|
|
|
|
|
|
|
|
atk_relation_set_add_relation_by_type (relationset, ATK_RELATION_NODE_PARENT_OF, ATK_OBJECT (object));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-10 03:56:42 +00:00
|
|
|
static void
|
|
|
|
gtk_cell_accessible_parent_interface_init (GtkCellAccessibleParentIface *iface)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-06-30 00:50:50 +00:00
|
|
|
iface->get_cell_extents = gtk_tree_view_accessible_get_cell_extents;
|
|
|
|
iface->get_cell_area = gtk_tree_view_accessible_get_cell_area;
|
|
|
|
iface->grab_focus = gtk_tree_view_accessible_grab_cell_focus;
|
2011-11-11 01:19:28 +00:00
|
|
|
iface->get_child_index = gtk_tree_view_accessible_get_child_index;
|
2011-11-24 00:55:38 +00:00
|
|
|
iface->get_renderer_state = gtk_tree_view_accessible_get_renderer_state;
|
2011-12-12 14:18:54 +00:00
|
|
|
iface->expand_collapse = gtk_tree_view_accessible_expand_collapse;
|
|
|
|
iface->activate = gtk_tree_view_accessible_activate;
|
|
|
|
iface->edit = gtk_tree_view_accessible_edit;
|
2014-03-24 15:34:08 +00:00
|
|
|
iface->update_relationset = gtk_tree_view_accessible_update_relationset;
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2011-11-23 02:21:57 +00:00
|
|
|
void
|
|
|
|
_gtk_tree_view_accessible_reorder (GtkTreeView *treeview)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-06-30 00:50:50 +00:00
|
|
|
GtkTreeViewAccessible *accessible;
|
|
|
|
|
2011-11-23 02:21:57 +00:00
|
|
|
accessible = GTK_TREE_VIEW_ACCESSIBLE (_gtk_widget_peek_accessible (GTK_WIDGET (treeview)));
|
|
|
|
if (accessible == NULL)
|
|
|
|
return;
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2011-11-23 02:21:57 +00:00
|
|
|
g_signal_emit_by_name (accessible, "row-reordered");
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
static gboolean
|
|
|
|
is_cell_showing (GtkTreeView *tree_view,
|
|
|
|
GdkRectangle *cell_rect)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
GdkRectangle rect, *visible_rect;
|
|
|
|
GdkRectangle rect1, *tree_cell_rect;
|
2009-02-25 08:41:49 +00:00
|
|
|
gint bx, by;
|
2007-12-18 13:51:12 +00:00
|
|
|
gboolean is_showing;
|
2011-06-30 00:50:50 +00:00
|
|
|
|
|
|
|
/* A cell is considered "SHOWING" if any part of the cell is
|
|
|
|
* in the visible area. Other ways we could do this is by a
|
|
|
|
* cell's midpoint or if the cell is fully in the visible range.
|
|
|
|
* Since we have the cell_rect x, y, width, height of the cell,
|
|
|
|
* any of these is easy to compute.
|
2007-12-18 13:51:12 +00:00
|
|
|
*
|
2011-06-30 00:50:50 +00:00
|
|
|
* It is assumed that cell's rectangle is in widget coordinates
|
|
|
|
* so we must transform to tree cordinates.
|
2007-12-18 13:51:12 +00:00
|
|
|
*/
|
|
|
|
visible_rect = ▭
|
|
|
|
tree_cell_rect = &rect1;
|
|
|
|
tree_cell_rect->x = cell_rect->x;
|
2009-02-25 08:41:49 +00:00
|
|
|
tree_cell_rect->y = cell_rect->y;
|
2007-12-18 13:51:12 +00:00
|
|
|
tree_cell_rect->width = cell_rect->width;
|
|
|
|
tree_cell_rect->height = cell_rect->height;
|
|
|
|
|
|
|
|
gtk_tree_view_get_visible_rect (tree_view, visible_rect);
|
2018-03-21 10:49:14 +00:00
|
|
|
gtk_tree_view_convert_tree_to_bin_window_coords (tree_view, visible_rect->x,
|
2009-02-25 08:41:49 +00:00
|
|
|
visible_rect->y, &bx, &by);
|
|
|
|
|
|
|
|
if (((tree_cell_rect->x + tree_cell_rect->width) < bx) ||
|
|
|
|
((tree_cell_rect->y + tree_cell_rect->height) < by) ||
|
|
|
|
(tree_cell_rect->x > (bx + visible_rect->width)) ||
|
|
|
|
(tree_cell_rect->y > (by + visible_rect->height)))
|
2007-12-18 13:51:12 +00:00
|
|
|
is_showing = FALSE;
|
|
|
|
else
|
|
|
|
is_showing = TRUE;
|
|
|
|
|
|
|
|
return is_showing;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Misc Private */
|
|
|
|
|
2011-11-11 00:35:50 +00:00
|
|
|
static int
|
2011-06-30 00:50:50 +00:00
|
|
|
cell_info_get_index (GtkTreeView *tree_view,
|
2011-11-11 00:35:50 +00:00
|
|
|
GtkTreeViewAccessibleCellInfo *info)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-11-11 00:35:50 +00:00
|
|
|
int index;
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2011-11-12 04:24:32 +00:00
|
|
|
index = _gtk_rbtree_node_get_index (info->tree, info->node) + 1;
|
2011-11-15 15:45:48 +00:00
|
|
|
index *= get_n_columns (tree_view);
|
2011-11-15 19:24:51 +00:00
|
|
|
index += get_column_number (tree_view, info->cell_col_ref);
|
2011-11-11 00:35:50 +00:00
|
|
|
|
|
|
|
return index;
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-06-30 00:50:50 +00:00
|
|
|
cell_info_new (GtkTreeViewAccessible *accessible,
|
2011-11-12 03:56:29 +00:00
|
|
|
GtkRBTree *tree,
|
|
|
|
GtkRBNode *node,
|
2011-06-30 00:50:50 +00:00
|
|
|
GtkTreeViewColumn *tv_col,
|
2011-07-09 22:30:59 +00:00
|
|
|
GtkCellAccessible *cell)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-06-30 00:50:50 +00:00
|
|
|
GtkTreeViewAccessibleCellInfo *cell_info;
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
cell_info = g_new (GtkTreeViewAccessibleCellInfo, 1);
|
2011-11-12 02:39:48 +00:00
|
|
|
|
2011-11-12 03:56:29 +00:00
|
|
|
cell_info->tree = tree;
|
|
|
|
cell_info->node = node;
|
2007-12-18 13:51:12 +00:00
|
|
|
cell_info->cell_col_ref = tv_col;
|
2014-02-26 01:29:36 +00:00
|
|
|
cell_info->cell = cell;
|
2011-06-30 00:50:50 +00:00
|
|
|
cell_info->view = accessible;
|
2011-06-23 02:27:10 +00:00
|
|
|
|
2012-02-11 02:37:25 +00:00
|
|
|
g_object_set_qdata (G_OBJECT (cell),
|
|
|
|
gtk_tree_view_accessible_get_data_quark (),
|
|
|
|
cell_info);
|
2011-11-11 19:18:09 +00:00
|
|
|
|
2012-10-15 09:56:41 +00:00
|
|
|
g_hash_table_replace (accessible->priv->cell_infos, cell_info, cell_info);
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
/* Returns the column number of the specified GtkTreeViewColumn
|
2011-11-16 02:47:33 +00:00
|
|
|
* The column must be visible.
|
2007-12-18 13:51:12 +00:00
|
|
|
*/
|
|
|
|
static gint
|
2011-11-16 02:47:33 +00:00
|
|
|
get_column_number (GtkTreeView *treeview,
|
2011-11-15 19:24:51 +00:00
|
|
|
GtkTreeViewColumn *column)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-11-16 02:47:33 +00:00
|
|
|
GtkTreeViewColumn *cur;
|
|
|
|
guint i, number;
|
2011-06-23 02:27:10 +00:00
|
|
|
|
2011-11-16 02:47:33 +00:00
|
|
|
number = 0;
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2011-11-16 02:47:33 +00:00
|
|
|
for (i = 0; i < gtk_tree_view_get_n_columns (treeview); i++)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-11-16 02:47:33 +00:00
|
|
|
cur = gtk_tree_view_get_column (treeview, i);
|
|
|
|
|
|
|
|
if (!gtk_tree_view_column_get_visible (cur))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (cur == column)
|
2007-12-18 13:51:12 +00:00
|
|
|
break;
|
2011-11-16 02:47:33 +00:00
|
|
|
|
|
|
|
number++;
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
2011-06-23 02:27:10 +00:00
|
|
|
|
2011-11-16 02:47:33 +00:00
|
|
|
g_return_val_if_fail (i < gtk_tree_view_get_n_columns (treeview), 0);
|
|
|
|
|
|
|
|
return number;
|
2011-06-23 02:27:10 +00:00
|
|
|
}
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
static gboolean
|
2011-11-12 03:56:29 +00:00
|
|
|
get_rbtree_column_from_index (GtkTreeView *tree_view,
|
|
|
|
gint index,
|
|
|
|
GtkRBTree **tree,
|
|
|
|
GtkRBNode **node,
|
|
|
|
GtkTreeViewColumn **column)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-11-15 15:45:48 +00:00
|
|
|
guint n_columns = get_n_columns (tree_view);
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2011-11-15 15:45:48 +00:00
|
|
|
if (n_columns == 0)
|
2007-12-18 13:51:12 +00:00
|
|
|
return FALSE;
|
|
|
|
/* First row is the column headers */
|
2011-11-15 15:45:48 +00:00
|
|
|
index -= n_columns;
|
2007-12-18 13:51:12 +00:00
|
|
|
if (index < 0)
|
|
|
|
return FALSE;
|
|
|
|
|
2011-11-12 03:56:29 +00:00
|
|
|
if (tree)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-11-12 03:56:29 +00:00
|
|
|
g_return_val_if_fail (node != NULL, FALSE);
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2011-11-12 03:56:29 +00:00
|
|
|
if (!_gtk_rbtree_find_index (_gtk_tree_view_get_rbtree (tree_view),
|
2011-11-15 15:45:48 +00:00
|
|
|
index / n_columns,
|
2011-11-12 03:56:29 +00:00
|
|
|
tree,
|
|
|
|
node))
|
2007-12-18 13:51:12 +00:00
|
|
|
return FALSE;
|
2011-06-30 00:50:50 +00:00
|
|
|
}
|
2007-12-18 13:51:12 +00:00
|
|
|
|
|
|
|
if (column)
|
|
|
|
{
|
2011-11-16 01:40:49 +00:00
|
|
|
*column = get_visible_column (tree_view, index % n_columns);
|
2007-12-18 13:51:12 +00:00
|
|
|
if (*column == NULL)
|
2011-11-12 03:56:29 +00:00
|
|
|
return FALSE;
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-06-30 00:50:50 +00:00
|
|
|
static GtkTreeViewAccessibleCellInfo *
|
|
|
|
find_cell_info (GtkTreeViewAccessible *accessible,
|
2011-11-13 03:28:52 +00:00
|
|
|
GtkCellAccessible *cell)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-11-13 01:47:42 +00:00
|
|
|
AtkObject *parent;
|
|
|
|
|
|
|
|
parent = atk_object_get_parent (ATK_OBJECT (cell));
|
|
|
|
while (parent != ATK_OBJECT (accessible))
|
|
|
|
{
|
|
|
|
cell = GTK_CELL_ACCESSIBLE (parent);
|
|
|
|
parent = atk_object_get_parent (ATK_OBJECT (cell));
|
|
|
|
}
|
|
|
|
|
2011-11-11 19:30:39 +00:00
|
|
|
return g_object_get_qdata (G_OBJECT (cell),
|
2011-11-13 01:47:42 +00:00
|
|
|
gtk_tree_view_accessible_get_data_quark ());
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static AtkObject *
|
|
|
|
get_header_from_column (GtkTreeViewColumn *tv_col)
|
|
|
|
{
|
|
|
|
AtkObject *rc;
|
|
|
|
GtkWidget *header_widget;
|
|
|
|
|
|
|
|
if (tv_col == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2011-06-23 21:45:36 +00:00
|
|
|
header_widget = gtk_tree_view_column_get_button (tv_col);
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2011-06-23 21:45:36 +00:00
|
|
|
if (header_widget)
|
|
|
|
rc = gtk_widget_get_accessible (header_widget);
|
|
|
|
else
|
|
|
|
rc = NULL;
|
2007-12-18 13:51:12 +00:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
2011-11-12 02:39:48 +00:00
|
|
|
|
2011-12-12 15:02:02 +00:00
|
|
|
void
|
|
|
|
_gtk_tree_view_accessible_add (GtkTreeView *treeview,
|
|
|
|
GtkRBTree *tree,
|
|
|
|
GtkRBNode *node)
|
|
|
|
{
|
|
|
|
GtkTreeViewAccessible *accessible;
|
2011-12-12 15:20:11 +00:00
|
|
|
guint row, n_rows, n_cols, i;
|
2011-12-12 15:02:02 +00:00
|
|
|
|
|
|
|
accessible = GTK_TREE_VIEW_ACCESSIBLE (_gtk_widget_peek_accessible (GTK_WIDGET (treeview)));
|
|
|
|
if (accessible == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (node == NULL)
|
|
|
|
{
|
|
|
|
row = tree->parent_tree ? _gtk_rbtree_node_get_index (tree->parent_tree, tree->parent_node) : 0;
|
|
|
|
n_rows = tree->root->total_count;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
row = _gtk_rbtree_node_get_index (tree, node);
|
|
|
|
n_rows = 1 + (node->children ? node->children->root->total_count : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_signal_emit_by_name (accessible, "row-inserted", row, n_rows);
|
2011-12-12 15:20:11 +00:00
|
|
|
|
|
|
|
n_cols = get_n_columns (treeview);
|
2011-12-16 11:57:06 +00:00
|
|
|
if (n_cols)
|
2011-12-12 15:20:11 +00:00
|
|
|
{
|
2011-12-16 11:57:06 +00:00
|
|
|
for (i = (row + 1) * n_cols; i < (row + n_rows + 1) * n_cols; i++)
|
|
|
|
{
|
|
|
|
/* Pass NULL as the child object, i.e. 4th argument */
|
|
|
|
g_signal_emit_by_name (accessible, "children-changed::add", i, NULL, NULL);
|
|
|
|
}
|
2011-12-12 15:20:11 +00:00
|
|
|
}
|
2011-12-12 15:02:02 +00:00
|
|
|
}
|
|
|
|
|
2011-11-12 02:39:48 +00:00
|
|
|
void
|
|
|
|
_gtk_tree_view_accessible_remove (GtkTreeView *treeview,
|
|
|
|
GtkRBTree *tree,
|
|
|
|
GtkRBNode *node)
|
|
|
|
{
|
|
|
|
GtkTreeViewAccessibleCellInfo *cell_info;
|
|
|
|
GHashTableIter iter;
|
|
|
|
GtkTreeViewAccessible *accessible;
|
2011-12-12 15:20:11 +00:00
|
|
|
guint row, n_rows, n_cols, i;
|
2011-11-12 02:39:48 +00:00
|
|
|
|
|
|
|
accessible = GTK_TREE_VIEW_ACCESSIBLE (_gtk_widget_peek_accessible (GTK_WIDGET (treeview)));
|
|
|
|
if (accessible == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* if this shows up in profiles, special-case node->children == NULL */
|
|
|
|
|
2011-12-12 10:30:24 +00:00
|
|
|
if (node == NULL)
|
|
|
|
{
|
|
|
|
row = tree->parent_tree ? _gtk_rbtree_node_get_index (tree->parent_tree, tree->parent_node) : 0;
|
|
|
|
n_rows = tree->root->total_count + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
row = _gtk_rbtree_node_get_index (tree, node);
|
|
|
|
n_rows = 1 + (node->children ? node->children->root->total_count : 0);
|
|
|
|
|
|
|
|
tree = node->children;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_signal_emit_by_name (accessible, "row-deleted", row, n_rows);
|
2011-12-10 01:03:46 +00:00
|
|
|
|
2011-12-12 15:20:11 +00:00
|
|
|
n_cols = get_n_columns (treeview);
|
2011-12-16 11:57:06 +00:00
|
|
|
if (n_cols)
|
2011-12-12 15:20:11 +00:00
|
|
|
{
|
2011-12-16 11:57:06 +00:00
|
|
|
for (i = (n_rows + row + 1) * n_cols - 1; i >= (row + 1) * n_cols; i--)
|
|
|
|
{
|
|
|
|
/* Pass NULL as the child object, i.e. 4th argument */
|
|
|
|
g_signal_emit_by_name (accessible, "children-changed::remove", i, NULL, NULL);
|
|
|
|
}
|
2011-12-12 15:20:11 +00:00
|
|
|
|
2012-10-15 09:56:41 +00:00
|
|
|
g_hash_table_iter_init (&iter, accessible->priv->cell_infos);
|
2011-12-16 11:57:06 +00:00
|
|
|
while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&cell_info))
|
|
|
|
{
|
|
|
|
if (node == cell_info->node ||
|
|
|
|
tree == cell_info->tree ||
|
|
|
|
(tree && _gtk_rbtree_contains (tree, cell_info->tree)))
|
|
|
|
g_hash_table_iter_remove (&iter);
|
|
|
|
}
|
2011-11-12 02:39:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-14 17:14:47 +00:00
|
|
|
void
|
|
|
|
_gtk_tree_view_accessible_changed (GtkTreeView *treeview,
|
|
|
|
GtkRBTree *tree,
|
|
|
|
GtkRBNode *node)
|
|
|
|
{
|
|
|
|
GtkTreeViewAccessible *accessible;
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
accessible = GTK_TREE_VIEW_ACCESSIBLE (gtk_widget_get_accessible (GTK_WIDGET (treeview)));
|
|
|
|
|
|
|
|
for (i = 0; i < gtk_tree_view_get_n_columns (treeview); i++)
|
|
|
|
{
|
|
|
|
GtkCellAccessible *cell = peek_cell (accessible,
|
|
|
|
tree, node,
|
|
|
|
gtk_tree_view_get_column (treeview, i));
|
|
|
|
|
2011-12-15 23:28:05 +00:00
|
|
|
if (cell == NULL)
|
2011-12-14 17:14:47 +00:00
|
|
|
continue;
|
|
|
|
|
2011-12-16 00:02:06 +00:00
|
|
|
set_cell_data (treeview, accessible, cell);
|
2015-04-09 00:08:25 +00:00
|
|
|
_gtk_cell_accessible_update_cache (cell, TRUE);
|
2011-12-14 17:14:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_signal_emit_by_name (accessible, "visible-data-changed");
|
|
|
|
}
|
|
|
|
|
2011-11-16 02:47:33 +00:00
|
|
|
/* NB: id is not checked, only columns < id are.
|
|
|
|
* This is important so the function works for notification of removal of a column */
|
2011-11-19 23:08:18 +00:00
|
|
|
static guint
|
2011-11-16 02:47:33 +00:00
|
|
|
to_visible_column_id (GtkTreeView *treeview,
|
|
|
|
guint id)
|
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
guint invisible;
|
|
|
|
|
|
|
|
invisible = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < id; i++)
|
|
|
|
{
|
|
|
|
GtkTreeViewColumn *column = gtk_tree_view_get_column (treeview, i);
|
|
|
|
|
|
|
|
if (!gtk_tree_view_column_get_visible (column))
|
|
|
|
invisible++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return id - invisible;
|
|
|
|
}
|
|
|
|
|
2012-10-02 17:13:30 +00:00
|
|
|
static void
|
|
|
|
gtk_tree_view_accessible_do_add_column (GtkTreeViewAccessible *accessible,
|
|
|
|
GtkTreeView *treeview,
|
|
|
|
GtkTreeViewColumn *column,
|
|
|
|
guint id)
|
2011-11-16 02:47:33 +00:00
|
|
|
{
|
|
|
|
guint row, n_rows, n_cols;
|
|
|
|
|
|
|
|
/* Generate column-inserted signal */
|
|
|
|
g_signal_emit_by_name (accessible, "column-inserted", id, 1);
|
|
|
|
|
|
|
|
n_rows = get_n_rows (treeview);
|
|
|
|
n_cols = get_n_columns (treeview);
|
|
|
|
|
|
|
|
/* Generate children-changed signals */
|
|
|
|
for (row = 0; row <= n_rows; row++)
|
|
|
|
{
|
|
|
|
/* Pass NULL as the child object, i.e. 4th argument */
|
|
|
|
g_signal_emit_by_name (accessible, "children-changed::add",
|
|
|
|
(row * n_cols) + id, NULL, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_gtk_tree_view_accessible_add_column (GtkTreeView *treeview,
|
|
|
|
GtkTreeViewColumn *column,
|
|
|
|
guint id)
|
|
|
|
{
|
|
|
|
AtkObject *obj;
|
|
|
|
|
|
|
|
if (!gtk_tree_view_column_get_visible (column))
|
|
|
|
return;
|
|
|
|
|
|
|
|
obj = _gtk_widget_peek_accessible (GTK_WIDGET (treeview));
|
|
|
|
if (obj == NULL)
|
|
|
|
return;
|
|
|
|
|
2012-10-02 17:13:30 +00:00
|
|
|
gtk_tree_view_accessible_do_add_column (GTK_TREE_VIEW_ACCESSIBLE (obj),
|
|
|
|
treeview,
|
|
|
|
column,
|
|
|
|
to_visible_column_id (treeview, id));
|
2011-11-16 02:47:33 +00:00
|
|
|
}
|
|
|
|
|
2012-10-02 17:13:30 +00:00
|
|
|
static void
|
|
|
|
gtk_tree_view_accessible_do_remove_column (GtkTreeViewAccessible *accessible,
|
|
|
|
GtkTreeView *treeview,
|
|
|
|
GtkTreeViewColumn *column,
|
|
|
|
guint id)
|
2011-11-16 02:47:33 +00:00
|
|
|
{
|
2011-11-16 02:52:02 +00:00
|
|
|
GtkTreeViewAccessibleCellInfo *cell_info;
|
|
|
|
GHashTableIter iter;
|
|
|
|
gpointer value;
|
2011-11-16 02:47:33 +00:00
|
|
|
guint row, n_rows, n_cols;
|
|
|
|
|
2011-11-16 02:52:02 +00:00
|
|
|
/* Clean column from cache */
|
2012-10-15 09:56:41 +00:00
|
|
|
g_hash_table_iter_init (&iter, accessible->priv->cell_infos);
|
2011-11-16 02:52:02 +00:00
|
|
|
while (g_hash_table_iter_next (&iter, NULL, &value))
|
|
|
|
{
|
|
|
|
cell_info = value;
|
|
|
|
if (cell_info->cell_col_ref == column)
|
|
|
|
g_hash_table_iter_remove (&iter);
|
|
|
|
}
|
2011-11-16 02:47:33 +00:00
|
|
|
|
|
|
|
/* Generate column-deleted signal */
|
|
|
|
g_signal_emit_by_name (accessible, "column-deleted", id, 1);
|
|
|
|
|
|
|
|
n_rows = get_n_rows (treeview);
|
|
|
|
n_cols = get_n_columns (treeview);
|
|
|
|
|
|
|
|
/* Generate children-changed signals */
|
|
|
|
for (row = 0; row <= n_rows; row++)
|
|
|
|
{
|
|
|
|
/* Pass NULL as the child object, 4th argument */
|
|
|
|
g_signal_emit_by_name (accessible, "children-changed::remove",
|
|
|
|
(row * n_cols) + id, NULL, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_gtk_tree_view_accessible_remove_column (GtkTreeView *treeview,
|
|
|
|
GtkTreeViewColumn *column,
|
|
|
|
guint id)
|
|
|
|
{
|
|
|
|
AtkObject *obj;
|
|
|
|
|
|
|
|
if (!gtk_tree_view_column_get_visible (column))
|
|
|
|
return;
|
|
|
|
|
|
|
|
obj = _gtk_widget_peek_accessible (GTK_WIDGET (treeview));
|
|
|
|
if (obj == NULL)
|
|
|
|
return;
|
|
|
|
|
2012-10-02 17:13:30 +00:00
|
|
|
gtk_tree_view_accessible_do_remove_column (GTK_TREE_VIEW_ACCESSIBLE (obj),
|
|
|
|
treeview,
|
|
|
|
column,
|
|
|
|
to_visible_column_id (treeview, id));
|
2011-11-16 02:47:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_gtk_tree_view_accessible_reorder_column (GtkTreeView *treeview,
|
|
|
|
GtkTreeViewColumn *column)
|
|
|
|
{
|
|
|
|
AtkObject *obj;
|
|
|
|
|
|
|
|
obj = _gtk_widget_peek_accessible (GTK_WIDGET (treeview));
|
|
|
|
if (obj == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_signal_emit_by_name (obj, "column-reordered");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_gtk_tree_view_accessible_toggle_visibility (GtkTreeView *treeview,
|
|
|
|
GtkTreeViewColumn *column)
|
|
|
|
{
|
|
|
|
AtkObject *obj;
|
2012-07-08 23:28:26 +00:00
|
|
|
guint i, id;
|
2011-11-16 02:47:33 +00:00
|
|
|
|
|
|
|
obj = _gtk_widget_peek_accessible (GTK_WIDGET (treeview));
|
|
|
|
if (obj == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (gtk_tree_view_column_get_visible (column))
|
2012-07-08 23:28:26 +00:00
|
|
|
{
|
|
|
|
id = get_column_number (treeview, column);
|
|
|
|
|
2012-10-02 17:13:30 +00:00
|
|
|
gtk_tree_view_accessible_do_add_column (GTK_TREE_VIEW_ACCESSIBLE (obj),
|
|
|
|
treeview,
|
|
|
|
column,
|
|
|
|
id);
|
2012-07-08 23:28:26 +00:00
|
|
|
}
|
2011-11-16 02:47:33 +00:00
|
|
|
else
|
2012-07-08 23:28:26 +00:00
|
|
|
{
|
|
|
|
id = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < gtk_tree_view_get_n_columns (treeview); i++)
|
|
|
|
{
|
|
|
|
GtkTreeViewColumn *cur = gtk_tree_view_get_column (treeview, i);
|
|
|
|
|
|
|
|
if (gtk_tree_view_column_get_visible (cur))
|
|
|
|
id++;
|
|
|
|
|
|
|
|
if (cur == column)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-10-02 17:13:30 +00:00
|
|
|
gtk_tree_view_accessible_do_remove_column (GTK_TREE_VIEW_ACCESSIBLE (obj),
|
|
|
|
treeview,
|
|
|
|
column,
|
|
|
|
id);
|
2012-07-08 23:28:26 +00:00
|
|
|
}
|
2011-11-16 02:47:33 +00:00
|
|
|
}
|
2011-12-12 09:25:27 +00:00
|
|
|
|
2012-02-21 00:46:40 +00:00
|
|
|
static GtkTreeViewColumn *
|
2012-02-11 01:50:26 +00:00
|
|
|
get_effective_focus_column (GtkTreeView *treeview,
|
|
|
|
GtkTreeViewColumn *column)
|
|
|
|
{
|
2017-11-13 02:51:53 +00:00
|
|
|
if (column == NULL && get_n_columns (treeview) > 0)
|
2012-02-11 01:50:26 +00:00
|
|
|
column = get_visible_column (treeview, 0);
|
|
|
|
|
|
|
|
return column;
|
|
|
|
}
|
|
|
|
|
2012-02-11 00:59:19 +00:00
|
|
|
void
|
|
|
|
_gtk_tree_view_accessible_update_focus_column (GtkTreeView *treeview,
|
|
|
|
GtkTreeViewColumn *old_focus,
|
|
|
|
GtkTreeViewColumn *new_focus)
|
|
|
|
{
|
2012-02-11 02:00:04 +00:00
|
|
|
GtkTreeViewAccessible *accessible;
|
|
|
|
AtkObject *obj;
|
|
|
|
GtkRBTree *cursor_tree;
|
|
|
|
GtkRBNode *cursor_node;
|
|
|
|
GtkCellAccessible *cell;
|
|
|
|
|
|
|
|
old_focus = get_effective_focus_column (treeview, old_focus);
|
|
|
|
new_focus = get_effective_focus_column (treeview, new_focus);
|
|
|
|
if (old_focus == new_focus)
|
|
|
|
return;
|
|
|
|
|
|
|
|
obj = _gtk_widget_peek_accessible (GTK_WIDGET (treeview));
|
|
|
|
if (obj == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
accessible = GTK_TREE_VIEW_ACCESSIBLE (obj);
|
|
|
|
|
|
|
|
if (!_gtk_tree_view_get_cursor_node (treeview, &cursor_tree, &cursor_node))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (old_focus)
|
|
|
|
{
|
|
|
|
cell = peek_cell (accessible, cursor_tree, cursor_node, old_focus);
|
|
|
|
if (cell != NULL)
|
|
|
|
_gtk_cell_accessible_state_changed (cell, GTK_CELL_RENDERER_FOCUSED, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (new_focus)
|
|
|
|
{
|
|
|
|
cell = peek_cell (accessible, cursor_tree, cursor_node, new_focus);
|
|
|
|
if (cell != NULL)
|
2012-02-11 03:43:15 +00:00
|
|
|
_gtk_cell_accessible_state_changed (cell, 0, GTK_CELL_RENDERER_FOCUSED);
|
|
|
|
else
|
|
|
|
cell = create_cell (treeview, accessible, cursor_tree, cursor_node, new_focus);
|
2012-12-27 06:04:46 +00:00
|
|
|
|
2012-02-11 03:43:15 +00:00
|
|
|
g_signal_emit_by_name (accessible, "active-descendant-changed", cell);
|
2012-02-11 02:00:04 +00:00
|
|
|
}
|
2012-02-11 00:59:19 +00:00
|
|
|
}
|
|
|
|
|
2011-12-12 09:25:27 +00:00
|
|
|
void
|
|
|
|
_gtk_tree_view_accessible_add_state (GtkTreeView *treeview,
|
|
|
|
GtkRBTree *tree,
|
|
|
|
GtkRBNode *node,
|
|
|
|
GtkCellRendererState state)
|
|
|
|
{
|
|
|
|
GtkTreeViewAccessible *accessible;
|
2013-02-20 01:42:50 +00:00
|
|
|
GtkTreeViewColumn *single_column;
|
2011-12-12 09:25:27 +00:00
|
|
|
AtkObject *obj;
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
obj = _gtk_widget_peek_accessible (GTK_WIDGET (treeview));
|
|
|
|
if (obj == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
accessible = GTK_TREE_VIEW_ACCESSIBLE (obj);
|
|
|
|
|
2012-02-11 01:38:48 +00:00
|
|
|
if (state == GTK_CELL_RENDERER_FOCUSED)
|
|
|
|
{
|
2013-02-20 01:42:50 +00:00
|
|
|
single_column = get_effective_focus_column (treeview, _gtk_tree_view_get_focus_column (treeview));
|
|
|
|
}
|
|
|
|
else if (state == GTK_CELL_RENDERER_EXPANDED ||
|
|
|
|
state == GTK_CELL_RENDERER_EXPANDABLE)
|
|
|
|
{
|
|
|
|
single_column = gtk_tree_view_get_expander_column (treeview);
|
2012-02-11 01:38:48 +00:00
|
|
|
}
|
2013-02-20 01:42:50 +00:00
|
|
|
else
|
|
|
|
single_column = NULL;
|
2012-02-11 01:38:48 +00:00
|
|
|
|
2013-02-20 01:42:50 +00:00
|
|
|
if (single_column)
|
2011-12-12 09:25:27 +00:00
|
|
|
{
|
|
|
|
GtkCellAccessible *cell = peek_cell (accessible,
|
|
|
|
tree, node,
|
2013-02-20 01:42:50 +00:00
|
|
|
single_column);
|
2011-12-12 09:25:27 +00:00
|
|
|
|
2013-02-20 01:42:50 +00:00
|
|
|
if (cell != NULL)
|
|
|
|
_gtk_cell_accessible_state_changed (cell, state, 0);
|
2013-03-05 10:55:28 +00:00
|
|
|
|
|
|
|
if (state == GTK_CELL_RENDERER_FOCUSED)
|
|
|
|
{
|
|
|
|
if (cell == NULL)
|
|
|
|
cell = create_cell (treeview, accessible, tree, node, single_column);
|
|
|
|
|
|
|
|
g_signal_emit_by_name (accessible, "active-descendant-changed", cell);
|
|
|
|
}
|
2013-02-20 01:42:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = 0; i < gtk_tree_view_get_n_columns (treeview); i++)
|
|
|
|
{
|
|
|
|
GtkCellAccessible *cell = peek_cell (accessible,
|
|
|
|
tree, node,
|
|
|
|
gtk_tree_view_get_column (treeview, i));
|
|
|
|
|
|
|
|
if (cell == NULL)
|
|
|
|
continue;
|
2011-12-12 09:25:27 +00:00
|
|
|
|
2013-02-20 01:42:50 +00:00
|
|
|
_gtk_cell_accessible_state_changed (cell, state, 0);
|
|
|
|
}
|
2011-12-12 09:25:27 +00:00
|
|
|
}
|
2011-12-12 15:41:21 +00:00
|
|
|
|
|
|
|
if (state == GTK_CELL_RENDERER_SELECTED)
|
|
|
|
g_signal_emit_by_name (accessible, "selection-changed");
|
2011-12-12 09:25:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_gtk_tree_view_accessible_remove_state (GtkTreeView *treeview,
|
|
|
|
GtkRBTree *tree,
|
|
|
|
GtkRBNode *node,
|
|
|
|
GtkCellRendererState state)
|
|
|
|
{
|
|
|
|
GtkTreeViewAccessible *accessible;
|
2013-02-20 01:42:50 +00:00
|
|
|
GtkTreeViewColumn *single_column;
|
2011-12-12 09:25:27 +00:00
|
|
|
AtkObject *obj;
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
obj = _gtk_widget_peek_accessible (GTK_WIDGET (treeview));
|
|
|
|
if (obj == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
accessible = GTK_TREE_VIEW_ACCESSIBLE (obj);
|
|
|
|
|
2012-02-11 01:38:48 +00:00
|
|
|
if (state == GTK_CELL_RENDERER_FOCUSED)
|
|
|
|
{
|
2013-02-20 01:42:50 +00:00
|
|
|
single_column = get_effective_focus_column (treeview, _gtk_tree_view_get_focus_column (treeview));
|
|
|
|
}
|
|
|
|
else if (state == GTK_CELL_RENDERER_EXPANDED ||
|
|
|
|
state == GTK_CELL_RENDERER_EXPANDABLE)
|
|
|
|
{
|
|
|
|
single_column = gtk_tree_view_get_expander_column (treeview);
|
2012-02-11 01:38:48 +00:00
|
|
|
}
|
2013-02-20 01:42:50 +00:00
|
|
|
else
|
|
|
|
single_column = NULL;
|
2012-02-11 01:38:48 +00:00
|
|
|
|
2013-02-20 01:42:50 +00:00
|
|
|
if (single_column)
|
2011-12-12 09:25:27 +00:00
|
|
|
{
|
|
|
|
GtkCellAccessible *cell = peek_cell (accessible,
|
|
|
|
tree, node,
|
2013-02-20 01:42:50 +00:00
|
|
|
single_column);
|
2011-12-12 09:25:27 +00:00
|
|
|
|
2013-02-20 01:42:50 +00:00
|
|
|
if (cell != NULL)
|
|
|
|
_gtk_cell_accessible_state_changed (cell, 0, state);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = 0; i < gtk_tree_view_get_n_columns (treeview); i++)
|
|
|
|
{
|
|
|
|
GtkCellAccessible *cell = peek_cell (accessible,
|
|
|
|
tree, node,
|
|
|
|
gtk_tree_view_get_column (treeview, i));
|
|
|
|
|
|
|
|
if (cell == NULL)
|
|
|
|
continue;
|
2011-12-12 09:25:27 +00:00
|
|
|
|
2013-02-20 01:42:50 +00:00
|
|
|
_gtk_cell_accessible_state_changed (cell, 0, state);
|
|
|
|
}
|
2011-12-12 09:25:27 +00:00
|
|
|
}
|
2011-12-12 15:41:21 +00:00
|
|
|
|
|
|
|
if (state == GTK_CELL_RENDERER_SELECTED)
|
|
|
|
g_signal_emit_by_name (accessible, "selection-changed");
|
2011-12-12 09:25:27 +00:00
|
|
|
}
|