Activate threeview row using keyboard
- From: "Padraig O'Briain" <Padraig Obriain Sun COM>
- To: gtk-devel-list gnome org
- Subject: Activate threeview row using keyboard
- Date: Sat, 19 Jan 2002 12:25:43 +0000 (GMT)
While running the gtk-demo program I realized that I could not activate a row in
the GtkTreeView which contains the demo programs using the keyboard; I could
double click on a row to activate it.
I attach a patch to allow activation from the keyboard.
Permission to commit?
Padraig
Index: gtktreeview.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktreeview.c,v
retrieving revision 1.196
diff -u -p -r1.196 gtktreeview.c
--- gtktreeview.c 2002/01/18 00:23:25 1.196
+++ gtktreeview.c 2002/01/19 12:24:52
@@ -105,6 +105,7 @@ enum
EXPAND_COLLAPSE_CURSOR_ROW,
SELECT_CURSOR_PARENT,
START_INTERACTIVE_SEARCH,
+ ACTIVATE_SELECTION,
LAST_SIGNAL
};
@@ -387,6 +388,7 @@ static void gtk_tree_view_real_start_edi
static void gtk_tree_view_stop_editing (GtkTreeView *tree_view,
gboolean cancel_editing);
static void gtk_tree_view_real_start_interactive_search (GtkTreeView *tree_view);
+static void gtk_tree_view_real_activate_selection (GtkTreeView *tree_view);
static GtkContainerClass *parent_class = NULL;
@@ -486,6 +488,7 @@ gtk_tree_view_class_init (GtkTreeViewCla
class->expand_collapse_cursor_row = gtk_tree_view_real_expand_collapse_cursor_row;
class->select_cursor_parent = gtk_tree_view_real_select_cursor_parent;
class->start_interactive_search = gtk_tree_view_real_start_interactive_search;
+ class->activate_selection = gtk_tree_view_real_activate_selection;
/* Properties */
@@ -762,6 +765,16 @@ gtk_tree_view_class_init (GtkTreeViewCla
_gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
+ tree_view_signals[ACTIVATE_SELECTION] =
+ g_signal_new ("activate_selection",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST | GTK_RUN_ACTION,
+ G_STRUCT_OFFSET (GtkTreeViewClass, activate_selection),
+ NULL, NULL,
+ _gtk_marshal_NONE__NONE,
+ GTK_TYPE_NONE, 0);
+ widget_class->activate_signal = tree_view_signals[ACTIVATE_SELECTION];
+
/* Key bindings */
gtk_tree_view_add_move_binding (binding_set, GDK_Up, 0,
GTK_MOVEMENT_DISPLAY_LINES, -1);
@@ -6460,6 +6473,44 @@ gtk_tree_view_real_start_interactive_sea
/* search first matching iter */
gtk_tree_view_search_init (entry, tree_view);
+}
+
+static void
+gtk_tree_view_real_activate_selection (GtkTreeView *tree_view)
+{
+ GtkSelectionMode mode;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GtkTreePath *path = NULL;
+ GtkTreeViewColumn *column = NULL;
+
+ if (tree_view->priv->selection == NULL)
+ return;
+
+ mode = gtk_tree_selection_get_mode (tree_view->priv->selection);
+
+ switch (mode)
+ {
+ case GTK_SELECTION_SINGLE:
+ case GTK_SELECTION_BROWSE:
+
+ if (gtk_tree_selection_get_selected (tree_view->priv->selection, &model, &iter))
+ path = gtk_tree_model_get_path (model, &iter);
+ break;
+ default:
+ break;
+ }
+
+ if (path)
+ {
+ if (tree_view->priv->focus_column)
+ column = tree_view->priv->focus_column;
+
+ if (column)
+ gtk_tree_view_row_activated (tree_view, path, column);
+
+ gtk_tree_path_free (path);
+ }
}
/* this function returns the new width of the column being resized given
Index: gtktreeview.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktreeview.h,v
retrieving revision 1.49
diff -u -p -r1.49 gtktreeview.h
--- gtktreeview.h 2001/12/12 23:04:12 1.49
+++ gtktreeview.h 2002/01/19 12:24:52
@@ -85,6 +85,7 @@ struct _GtkTreeViewClass
GtkTreePath *path);
void (* columns_changed) (GtkTreeView *tree_view);
void (* cursor_changed) (GtkTreeView *tree_view);
+ void (* activate_selection) (GtkTreeView *tree_view);
/* Key Binding signals */
void (* move_cursor) (GtkTreeView *tree_view,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]