[g-a-devel]Activate action for TreeView cell



Following prompting from Michael, I have come to the conclusion that a cell in a 
GtkTreeView should have an activate action. This action would correspond to 
double clicking on the cell. 

The patch to implement the action is attached.

When using at-poke I have noticed that the table cells report no name. Should we 
report the text associated with the cell as the name in a similar way as we do 
for a GtkLabel?

Padraig
Index: gailtreeview.c
===================================================================
RCS file: /cvs/gnome/gail/gail/gailtreeview.c,v
retrieving revision 1.125
diff -u -p -r1.125 gailtreeview.c
--- gailtreeview.c	25 Mar 2002 14:06:24 -0000	1.125
+++ gailtreeview.c	26 Mar 2002 08:38:25 -0000
@@ -257,6 +257,7 @@ static void             add_cell_actions
 static gboolean         toggle_cell_expanded            (GailCell               *cell);
 static gboolean         toggle_cell_toggled             (GailCell               *cell);
 static gboolean         edit_cell                       (GailCell               *cell);
+static gboolean         activate_cell                   (GailCell               *cell);
 static void             cell_destroyed                  (gpointer               data);
 static void             cell_info_remove                (GailTreeView           *tree_view, 
                                                          GailCell               *cell);
@@ -3364,6 +3365,11 @@ add_cell_actions (GailCell *cell,
 	"creates a widget in which the contents of the cell can be edited", 
 	NULL,
 	edit_cell);
+  gail_cell_add_action (cell,
+	"activate",
+	"activate the cell", 
+	NULL,
+	activate_cell);
 }
 
 static gboolean
@@ -3476,6 +3482,36 @@ edit_cell (GailCell *cell)
   path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
   g_return_val_if_fail (path, FALSE);
   gtk_tree_view_set_cursor (tree_view, path, cell_info->cell_col_ref, TRUE);
+  gtk_tree_path_free (path);
+  return TRUE;
+}
+
+static gboolean
+activate_cell (GailCell *cell)
+{
+  GailTreeViewCellInfo *cell_info;
+  GtkTreeView *tree_view;
+  GtkTreePath *path;
+  AtkObject *parent;
+  gboolean is_container_cell = FALSE;
+
+  editing = TRUE;
+  parent = atk_object_get_parent (ATK_OBJECT (cell));
+  if (GAIL_IS_CONTAINER_CELL (parent))
+    {
+      is_container_cell = TRUE;
+      parent = atk_object_get_parent (parent);
+    }
+
+  cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, NULL);
+  g_return_val_if_fail (cell_info, FALSE);
+  g_return_val_if_fail (cell_info->cell_col_ref, FALSE);
+  g_return_val_if_fail (cell_info->cell_row_ref, FALSE);
+
+  tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (parent)->widget);
+  path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
+  g_return_val_if_fail (path, FALSE);
+  gtk_tree_view_row_activated (tree_view, path, cell_info->cell_col_ref);
   gtk_tree_path_free (path);
   return TRUE;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]