mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-05 16:20:10 +00:00
Initial stab at getting the focus code to work.
Fri Jun 1 18:54:47 2001 Jonathan Blandford <jrb@redhat.com> * gtk/gtktreeview.c: (gtk_tree_view_focus): Initial stab at getting the focus code to work. (gtk_tree_view_class_init): Add a bunch of keybindings. * gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_cell_data_func): s/GtkCellDataFunc/GtkTreeCellDataFunc. (_gtk_tree_view_column_set_tree_view): Use "notify::model" instead of "properties_changed" to help justify the death of the latter signal. (-: * tests/testtreefocus.c (main): Let some columns be focussable to test focus better.
This commit is contained in:
parent
fe3e516aa1
commit
11043de66f
16
ChangeLog
16
ChangeLog
@ -1,3 +1,19 @@
|
||||
Fri Jun 1 18:54:47 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeview.c: (gtk_tree_view_focus): Initial stab at
|
||||
getting the focus code to work.
|
||||
(gtk_tree_view_class_init): Add a bunch of keybindings.
|
||||
|
||||
* gtk/gtktreeviewcolumn.c
|
||||
(gtk_tree_view_column_set_cell_data_func):
|
||||
s/GtkCellDataFunc/GtkTreeCellDataFunc.
|
||||
(_gtk_tree_view_column_set_tree_view): Use "notify::model" instead
|
||||
of "properties_changed" to help justify the death of the latter
|
||||
signal. (-:
|
||||
|
||||
* tests/testtreefocus.c (main): Let some columns be focussable to
|
||||
test focus better.
|
||||
|
||||
2001-06-01 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_commit_cb): implement overwrite mode
|
||||
|
@ -1,3 +1,19 @@
|
||||
Fri Jun 1 18:54:47 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeview.c: (gtk_tree_view_focus): Initial stab at
|
||||
getting the focus code to work.
|
||||
(gtk_tree_view_class_init): Add a bunch of keybindings.
|
||||
|
||||
* gtk/gtktreeviewcolumn.c
|
||||
(gtk_tree_view_column_set_cell_data_func):
|
||||
s/GtkCellDataFunc/GtkTreeCellDataFunc.
|
||||
(_gtk_tree_view_column_set_tree_view): Use "notify::model" instead
|
||||
of "properties_changed" to help justify the death of the latter
|
||||
signal. (-:
|
||||
|
||||
* tests/testtreefocus.c (main): Let some columns be focussable to
|
||||
test focus better.
|
||||
|
||||
2001-06-01 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_commit_cb): implement overwrite mode
|
||||
|
@ -1,3 +1,19 @@
|
||||
Fri Jun 1 18:54:47 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeview.c: (gtk_tree_view_focus): Initial stab at
|
||||
getting the focus code to work.
|
||||
(gtk_tree_view_class_init): Add a bunch of keybindings.
|
||||
|
||||
* gtk/gtktreeviewcolumn.c
|
||||
(gtk_tree_view_column_set_cell_data_func):
|
||||
s/GtkCellDataFunc/GtkTreeCellDataFunc.
|
||||
(_gtk_tree_view_column_set_tree_view): Use "notify::model" instead
|
||||
of "properties_changed" to help justify the death of the latter
|
||||
signal. (-:
|
||||
|
||||
* tests/testtreefocus.c (main): Let some columns be focussable to
|
||||
test focus better.
|
||||
|
||||
2001-06-01 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_commit_cb): implement overwrite mode
|
||||
|
@ -1,3 +1,19 @@
|
||||
Fri Jun 1 18:54:47 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeview.c: (gtk_tree_view_focus): Initial stab at
|
||||
getting the focus code to work.
|
||||
(gtk_tree_view_class_init): Add a bunch of keybindings.
|
||||
|
||||
* gtk/gtktreeviewcolumn.c
|
||||
(gtk_tree_view_column_set_cell_data_func):
|
||||
s/GtkCellDataFunc/GtkTreeCellDataFunc.
|
||||
(_gtk_tree_view_column_set_tree_view): Use "notify::model" instead
|
||||
of "properties_changed" to help justify the death of the latter
|
||||
signal. (-:
|
||||
|
||||
* tests/testtreefocus.c (main): Let some columns be focussable to
|
||||
test focus better.
|
||||
|
||||
2001-06-01 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_commit_cb): implement overwrite mode
|
||||
|
@ -1,3 +1,19 @@
|
||||
Fri Jun 1 18:54:47 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeview.c: (gtk_tree_view_focus): Initial stab at
|
||||
getting the focus code to work.
|
||||
(gtk_tree_view_class_init): Add a bunch of keybindings.
|
||||
|
||||
* gtk/gtktreeviewcolumn.c
|
||||
(gtk_tree_view_column_set_cell_data_func):
|
||||
s/GtkCellDataFunc/GtkTreeCellDataFunc.
|
||||
(_gtk_tree_view_column_set_tree_view): Use "notify::model" instead
|
||||
of "properties_changed" to help justify the death of the latter
|
||||
signal. (-:
|
||||
|
||||
* tests/testtreefocus.c (main): Let some columns be focussable to
|
||||
test focus better.
|
||||
|
||||
2001-06-01 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_commit_cb): implement overwrite mode
|
||||
|
@ -1,3 +1,19 @@
|
||||
Fri Jun 1 18:54:47 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeview.c: (gtk_tree_view_focus): Initial stab at
|
||||
getting the focus code to work.
|
||||
(gtk_tree_view_class_init): Add a bunch of keybindings.
|
||||
|
||||
* gtk/gtktreeviewcolumn.c
|
||||
(gtk_tree_view_column_set_cell_data_func):
|
||||
s/GtkCellDataFunc/GtkTreeCellDataFunc.
|
||||
(_gtk_tree_view_column_set_tree_view): Use "notify::model" instead
|
||||
of "properties_changed" to help justify the death of the latter
|
||||
signal. (-:
|
||||
|
||||
* tests/testtreefocus.c (main): Let some columns be focussable to
|
||||
test focus better.
|
||||
|
||||
2001-06-01 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_commit_cb): implement overwrite mode
|
||||
|
@ -1,3 +1,19 @@
|
||||
Fri Jun 1 18:54:47 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeview.c: (gtk_tree_view_focus): Initial stab at
|
||||
getting the focus code to work.
|
||||
(gtk_tree_view_class_init): Add a bunch of keybindings.
|
||||
|
||||
* gtk/gtktreeviewcolumn.c
|
||||
(gtk_tree_view_column_set_cell_data_func):
|
||||
s/GtkCellDataFunc/GtkTreeCellDataFunc.
|
||||
(_gtk_tree_view_column_set_tree_view): Use "notify::model" instead
|
||||
of "properties_changed" to help justify the death of the latter
|
||||
signal. (-:
|
||||
|
||||
* tests/testtreefocus.c (main): Let some columns be focussable to
|
||||
test focus better.
|
||||
|
||||
2001-06-01 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_commit_cb): implement overwrite mode
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "gtkhbox.h"
|
||||
#include "gtkarrow.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkbindings.h"
|
||||
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
|
||||
@ -95,6 +96,7 @@ enum
|
||||
EXPAND_ROW,
|
||||
COLLAPSE_ROW,
|
||||
COLUMNS_CHANGED,
|
||||
MOVE_CURSOR,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
@ -208,6 +210,10 @@ static void gtk_tree_view_drag_data_received (GtkWidget *widget,
|
||||
static void gtk_tree_view_set_adjustments (GtkTreeView *tree_view,
|
||||
GtkAdjustment *hadj,
|
||||
GtkAdjustment *vadj);
|
||||
static void gtk_tree_view_real_move_cursor (GtkTreeView *tree_view,
|
||||
GtkMovementStep step,
|
||||
gint count,
|
||||
gboolean extend_selection);
|
||||
static void gtk_tree_view_range_changed (GtkTreeModel *model,
|
||||
GtkTreePath *path,
|
||||
GtkTreeIter *iter,
|
||||
@ -231,6 +237,12 @@ static void gtk_tree_view_reordered (GtkTreeModel *model,
|
||||
gint *new_order,
|
||||
gpointer data);
|
||||
/* Internal functions */
|
||||
|
||||
static void gtk_tree_view_add_move_binding (GtkBindingSet *binding_set,
|
||||
guint keyval,
|
||||
guint modmask,
|
||||
GtkMovementStep step,
|
||||
gint count);
|
||||
static void gtk_tree_view_unref_tree (GtkTreeView *tree_view,
|
||||
GtkRBTree *tree);
|
||||
static void gtk_tree_view_queue_draw_node (GtkTreeView *tree_view,
|
||||
@ -284,7 +296,10 @@ static void gtk_tree_view_clamp_node_visible (GtkTreeView *tree_view,
|
||||
static gboolean gtk_tree_view_maybe_begin_dragging_row (GtkTreeView *tree_view,
|
||||
GdkEventMotion *event);
|
||||
static void _gtk_tree_view_update_col_width (GtkTreeView *tree_view);
|
||||
|
||||
static void gtk_tree_view_set_cursor_focus (GtkTreeView *tree_view);
|
||||
static void gtk_tree_view_move_cursor_up_down (GtkTreeView *tree_view,
|
||||
gint count,
|
||||
gboolean extend_selection);
|
||||
|
||||
static GtkContainerClass *parent_class = NULL;
|
||||
static guint tree_view_signals[LAST_SIGNAL] = { 0 };
|
||||
@ -327,8 +342,10 @@ gtk_tree_view_class_init (GtkTreeViewClass *class)
|
||||
GtkObjectClass *object_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
GtkContainerClass *container_class;
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
parent_class = g_type_class_peek_parent (class);
|
||||
binding_set = gtk_binding_set_by_class (class);
|
||||
|
||||
o_class = (GObjectClass *) class;
|
||||
object_class = (GtkObjectClass *) class;
|
||||
@ -374,6 +391,8 @@ gtk_tree_view_class_init (GtkTreeViewClass *class)
|
||||
container_class->set_focus_child = gtk_tree_view_set_focus_child;
|
||||
|
||||
class->set_scroll_adjustments = gtk_tree_view_set_adjustments;
|
||||
class->move_cursor = gtk_tree_view_real_move_cursor;
|
||||
/* Properties */
|
||||
|
||||
g_object_class_install_property (o_class,
|
||||
PROP_MODEL,
|
||||
@ -441,6 +460,50 @@ gtk_tree_view_class_init (GtkTreeViewClass *class)
|
||||
FALSE,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
/* Style properties */
|
||||
/* the width of the column resize windows */
|
||||
#define _TREE_VIEW_EXPANDER_WIDTH 14
|
||||
#define _TREE_VIEW_EXPANDER_HEIGHT 14
|
||||
#define _TREE_VIEW_VERTICAL_SEPARATOR 2
|
||||
#define _TREE_VIEW_HORIZONTAL_SEPARATOR 0
|
||||
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_int ("expander_width",
|
||||
_("Expander Width"),
|
||||
_("Width of the expander arrow"),
|
||||
0,
|
||||
G_MAXINT,
|
||||
_TREE_VIEW_EXPANDER_WIDTH,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_int ("expander_height",
|
||||
_("Expander Height"),
|
||||
_("Height of the expander arrow"),
|
||||
4,
|
||||
G_MAXINT,
|
||||
_TREE_VIEW_EXPANDER_HEIGHT,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_int ("vertical_separator",
|
||||
_("Vertical Separator Width"),
|
||||
_("Vertical space between cells"),
|
||||
0,
|
||||
G_MAXINT,
|
||||
_TREE_VIEW_VERTICAL_SEPARATOR,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_int ("horizontal_separator",
|
||||
_("Horizontal Separator Width"),
|
||||
_("Horizontal space between cells"),
|
||||
0,
|
||||
G_MAXINT,
|
||||
_TREE_VIEW_HORIZONTAL_SEPARATOR,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
/* Signals */
|
||||
widget_class->set_scroll_adjustments_signal =
|
||||
gtk_signal_new ("set_scroll_adjustments",
|
||||
GTK_RUN_LAST,
|
||||
@ -491,47 +554,51 @@ gtk_tree_view_class_init (GtkTreeViewClass *class)
|
||||
gtk_marshal_NONE__NONE,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
/* the width of the column resize windows */
|
||||
#define _TREE_VIEW_EXPANDER_WIDTH 14
|
||||
#define _TREE_VIEW_EXPANDER_HEIGHT 14
|
||||
#define _TREE_VIEW_VERTICAL_SEPARATOR 2
|
||||
#define _TREE_VIEW_HORIZONTAL_SEPARATOR 0
|
||||
tree_view_signals[MOVE_CURSOR] =
|
||||
g_signal_newc ("move_cursor",
|
||||
G_TYPE_FROM_CLASS (object_class),
|
||||
G_SIGNAL_RUN_LAST | GTK_RUN_ACTION,
|
||||
G_STRUCT_OFFSET (GtkTreeViewClass, move_cursor),
|
||||
NULL, NULL,
|
||||
gtk_marshal_VOID__ENUM_INT_BOOLEAN,
|
||||
GTK_TYPE_NONE, 3, GTK_TYPE_MOVEMENT_STEP, GTK_TYPE_INT, GTK_TYPE_BOOL);
|
||||
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_int ("expander_width",
|
||||
_("Expander Width"),
|
||||
_("Width of the expander arrow"),
|
||||
0,
|
||||
G_MAXINT,
|
||||
_TREE_VIEW_EXPANDER_WIDTH,
|
||||
G_PARAM_READABLE));
|
||||
/* Key bindings */
|
||||
gtk_tree_view_add_move_binding (binding_set, GDK_Right, 0,
|
||||
GTK_MOVEMENT_VISUAL_POSITIONS, 1);
|
||||
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_int ("expander_height",
|
||||
_("Expander Height"),
|
||||
_("Height of the expander arrow"),
|
||||
4,
|
||||
G_MAXINT,
|
||||
_TREE_VIEW_EXPANDER_HEIGHT,
|
||||
G_PARAM_READABLE));
|
||||
gtk_tree_view_add_move_binding (binding_set, GDK_Left, 0,
|
||||
GTK_MOVEMENT_VISUAL_POSITIONS, -1);
|
||||
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_int ("vertical_separator",
|
||||
_("Vertical Separator Width"),
|
||||
_("Vertical space between cells"),
|
||||
0,
|
||||
G_MAXINT,
|
||||
_TREE_VIEW_VERTICAL_SEPARATOR,
|
||||
G_PARAM_READABLE));
|
||||
gtk_tree_view_add_move_binding (binding_set, GDK_f, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_LOGICAL_POSITIONS, 1);
|
||||
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_int ("horizontal_separator",
|
||||
_("Horizontal Separator Width"),
|
||||
_("Horizontal space between cells"),
|
||||
0,
|
||||
G_MAXINT,
|
||||
_TREE_VIEW_HORIZONTAL_SEPARATOR,
|
||||
G_PARAM_READABLE));
|
||||
gtk_tree_view_add_move_binding (binding_set, GDK_b, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_LOGICAL_POSITIONS, -1);
|
||||
|
||||
gtk_tree_view_add_move_binding (binding_set, GDK_Up, 0,
|
||||
GTK_MOVEMENT_DISPLAY_LINES, -1);
|
||||
|
||||
gtk_tree_view_add_move_binding (binding_set, GDK_Down, 0,
|
||||
GTK_MOVEMENT_DISPLAY_LINES, 1);
|
||||
|
||||
gtk_tree_view_add_move_binding (binding_set, GDK_p, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_DISPLAY_LINES, -1);
|
||||
|
||||
gtk_tree_view_add_move_binding (binding_set, GDK_n, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_DISPLAY_LINES, 1);
|
||||
|
||||
gtk_tree_view_add_move_binding (binding_set, GDK_Home, 0,
|
||||
GTK_MOVEMENT_BUFFER_ENDS, -1);
|
||||
|
||||
gtk_tree_view_add_move_binding (binding_set, GDK_End, 0,
|
||||
GTK_MOVEMENT_BUFFER_ENDS, 1);
|
||||
|
||||
gtk_tree_view_add_move_binding (binding_set, GDK_Page_Up, 0,
|
||||
GTK_MOVEMENT_PAGES, -1);
|
||||
|
||||
gtk_tree_view_add_move_binding (binding_set, GDK_Page_Down, 0,
|
||||
GTK_MOVEMENT_PAGES, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2538,7 +2605,7 @@ gtk_tree_view_key_press (GtkWidget *widget,
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
return (* GTK_WIDGET_CLASS (parent_class)->key_press_event) (widget, event);
|
||||
}
|
||||
|
||||
/* FIXME Is this function necessary? Can I get an enter_notify event
|
||||
@ -3743,57 +3810,23 @@ gtk_tree_view_focus (GtkContainer *container,
|
||||
|
||||
focus_child = container->focus_child;
|
||||
|
||||
/* Case 1. Headers have focus. */
|
||||
/* Case 1. Headers currently have focus. */
|
||||
if (focus_child)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case GTK_DIR_LEFT:
|
||||
case GTK_DIR_RIGHT:
|
||||
return (gtk_tree_view_header_focus (tree_view, direction));
|
||||
gtk_tree_view_header_focus (tree_view, direction);
|
||||
return TRUE;
|
||||
case GTK_DIR_TAB_BACKWARD:
|
||||
case GTK_DIR_UP:
|
||||
return FALSE;
|
||||
case GTK_DIR_TAB_FORWARD:
|
||||
case GTK_DIR_DOWN:
|
||||
|
||||
if (tree_view->priv->tree == NULL)
|
||||
return FALSE;
|
||||
|
||||
GTK_TREE_VIEW_SET_FLAG (tree_view, GTK_TREE_VIEW_DRAW_KEYFOCUS);
|
||||
gtk_widget_grab_focus (GTK_WIDGET (container));
|
||||
|
||||
if (tree_view->priv->selection == NULL)
|
||||
tree_view->priv->selection =
|
||||
_gtk_tree_selection_new_with_tree_view (tree_view);
|
||||
|
||||
/* if there is no keyboard focus yet, we select the first node
|
||||
*/
|
||||
|
||||
cursor_path = NULL;
|
||||
|
||||
if (tree_view->priv->cursor)
|
||||
cursor_path = gtk_tree_row_reference_get_path (tree_view->priv->cursor);
|
||||
|
||||
if (cursor_path == NULL)
|
||||
{
|
||||
GtkTreePath *tmp_path = gtk_tree_path_new_root ();
|
||||
|
||||
if (tree_view->priv->cursor)
|
||||
gtk_tree_row_reference_free (tree_view->priv->cursor);
|
||||
|
||||
tree_view->priv->cursor =
|
||||
gtk_tree_row_reference_new_proxy (G_OBJECT (tree_view), tree_view->priv->model, tmp_path);
|
||||
cursor_path = tmp_path;
|
||||
}
|
||||
|
||||
gtk_tree_selection_select_path (tree_view->priv->selection,
|
||||
cursor_path);
|
||||
|
||||
gtk_tree_view_queue_draw_path (tree_view, cursor_path, NULL);
|
||||
|
||||
gtk_tree_path_free (cursor_path);
|
||||
|
||||
gtk_tree_view_set_cursor_focus (tree_view);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@ -3801,56 +3834,35 @@ gtk_tree_view_focus (GtkContainer *container,
|
||||
/* Case 2. We don't have focus at all. */
|
||||
if (!GTK_WIDGET_HAS_FOCUS (container))
|
||||
{
|
||||
if ((direction == GTK_DIR_TAB_FORWARD) ||
|
||||
(direction == GTK_DIR_RIGHT) ||
|
||||
(direction == GTK_DIR_DOWN) ||
|
||||
(direction == GTK_DIR_LEFT) ||
|
||||
(tree_view->priv->tree == NULL))
|
||||
if (tree_view->priv->tree == NULL &&
|
||||
(direction == GTK_DIR_TAB_BACKWARD ||
|
||||
direction == GTK_DIR_UP))
|
||||
return gtk_tree_view_header_focus (tree_view, direction);
|
||||
if (((direction == GTK_DIR_TAB_FORWARD) ||
|
||||
(direction == GTK_DIR_RIGHT) ||
|
||||
(direction == GTK_DIR_DOWN) ||
|
||||
(direction == GTK_DIR_LEFT)) &&
|
||||
gtk_tree_view_header_focus (tree_view, direction))
|
||||
return TRUE;
|
||||
|
||||
/* The headers didn't want the focus, so we take it. */
|
||||
GTK_TREE_VIEW_SET_FLAG (tree_view, GTK_TREE_VIEW_DRAW_KEYFOCUS);
|
||||
gtk_widget_grab_focus (GTK_WIDGET (container));
|
||||
|
||||
if (tree_view->priv->selection == NULL)
|
||||
tree_view->priv->selection =
|
||||
_gtk_tree_selection_new_with_tree_view (tree_view);
|
||||
|
||||
cursor_path = NULL;
|
||||
if (tree_view->priv->cursor)
|
||||
cursor_path = gtk_tree_row_reference_get_path (tree_view->priv->cursor);
|
||||
|
||||
if (cursor_path == NULL)
|
||||
{
|
||||
GtkTreePath *tmp_path = gtk_tree_path_new_root ();
|
||||
|
||||
if (tree_view->priv->cursor)
|
||||
gtk_tree_row_reference_free (tree_view->priv->cursor);
|
||||
|
||||
tree_view->priv->cursor =
|
||||
gtk_tree_row_reference_new_proxy (G_OBJECT (tree_view), tree_view->priv->model, tmp_path);
|
||||
cursor_path = tmp_path;
|
||||
}
|
||||
|
||||
gtk_tree_selection_select_path (tree_view->priv->selection,
|
||||
cursor_path);
|
||||
|
||||
gtk_tree_view_queue_draw_path (tree_view, cursor_path, NULL);
|
||||
|
||||
gtk_tree_path_free (cursor_path);
|
||||
|
||||
if (tree_view->priv->tree == NULL)
|
||||
return FALSE;
|
||||
gtk_tree_view_set_cursor_focus (tree_view);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Case 3. We have focus already. */
|
||||
if (tree_view->priv->tree == NULL)
|
||||
return FALSE;
|
||||
return gtk_tree_view_header_focus (tree_view, direction);
|
||||
|
||||
if (direction == GTK_DIR_TAB_BACKWARD)
|
||||
return (gtk_tree_view_header_focus (tree_view, direction));
|
||||
else if (direction == GTK_DIR_TAB_FORWARD)
|
||||
return FALSE;
|
||||
|
||||
/* Other directions caught by the keybindings */
|
||||
return TRUE;
|
||||
#if 0
|
||||
cursor_path = NULL;
|
||||
if (tree_view->priv->cursor)
|
||||
cursor_path = gtk_tree_row_reference_get_path (tree_view->priv->cursor);
|
||||
@ -3989,6 +4001,7 @@ gtk_tree_view_focus (GtkContainer *container,
|
||||
|
||||
/* we've reached the end of the tree. Go on. */
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -4069,6 +4082,48 @@ gtk_tree_view_set_adjustments (GtkTreeView *tree_view,
|
||||
gtk_tree_view_adjustment_changed (NULL, tree_view);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_tree_view_real_move_cursor (GtkTreeView *tree_view,
|
||||
GtkMovementStep step,
|
||||
gint count,
|
||||
gboolean extend_selection)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_TREE_VIEW (tree_view));
|
||||
g_return_if_fail (step == GTK_MOVEMENT_LOGICAL_POSITIONS ||
|
||||
step == GTK_MOVEMENT_VISUAL_POSITIONS ||
|
||||
step == GTK_MOVEMENT_DISPLAY_LINES ||
|
||||
step == GTK_MOVEMENT_PAGES ||
|
||||
step == GTK_MOVEMENT_BUFFER_ENDS);
|
||||
|
||||
switch (step)
|
||||
{
|
||||
/* currently we make no distinction. When we go bi-di, we need to */
|
||||
case GTK_MOVEMENT_LOGICAL_POSITIONS:
|
||||
case GTK_MOVEMENT_VISUAL_POSITIONS:
|
||||
if (count == 1)
|
||||
g_print ("go right\n");
|
||||
else
|
||||
g_print ("go_left\n");
|
||||
break;
|
||||
case GTK_MOVEMENT_DISPLAY_LINES:
|
||||
gtk_tree_view_move_cursor_up_down (tree_view, count, extend_selection);
|
||||
break;
|
||||
case GTK_MOVEMENT_PAGES:
|
||||
if (count == -1)
|
||||
g_print ("page up\n");
|
||||
else
|
||||
g_print ("page_down\n");
|
||||
break;
|
||||
case GTK_MOVEMENT_BUFFER_ENDS:
|
||||
if (count == -1)
|
||||
g_print ("start\n");
|
||||
else
|
||||
g_print ("end\n");
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
|
||||
/* TreeModel Callbacks
|
||||
*/
|
||||
@ -5053,6 +5108,29 @@ _gtk_tree_view_find_node (GtkTreeView *tree_view,
|
||||
while (1);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_tree_view_add_move_binding (GtkBindingSet *binding_set,
|
||||
guint keyval,
|
||||
guint modmask,
|
||||
GtkMovementStep step,
|
||||
gint count)
|
||||
{
|
||||
g_return_if_fail ((modmask & GDK_SHIFT_MASK) == 0);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, modmask,
|
||||
"move_cursor", 3,
|
||||
GTK_TYPE_ENUM, step,
|
||||
GTK_TYPE_INT, count,
|
||||
GTK_TYPE_BOOL, FALSE);
|
||||
|
||||
/* Selection-extending version */
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, modmask | GDK_SHIFT_MASK,
|
||||
"move_cursor", 3,
|
||||
GTK_TYPE_ENUM, step,
|
||||
GTK_TYPE_INT, count,
|
||||
GTK_TYPE_BOOL, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_tree_view_unref_tree_helper (GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
@ -5435,6 +5513,100 @@ _gtk_tree_view_update_col_width (GtkTreeView *tree_view)
|
||||
column->displayed_width = MAX (GTK_WIDGET (tree_view)->allocation.width, tree_view->priv->width) - width;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_tree_view_set_cursor_focus (GtkTreeView *tree_view)
|
||||
|
||||
{
|
||||
GtkTreePath *cursor_path;
|
||||
|
||||
if ((tree_view->priv->tree == NULL) ||
|
||||
(! GTK_WIDGET_REALIZED (tree_view)))
|
||||
return;
|
||||
|
||||
if (tree_view->priv->selection == NULL)
|
||||
tree_view->priv->selection =
|
||||
_gtk_tree_selection_new_with_tree_view (tree_view);
|
||||
|
||||
GTK_TREE_VIEW_SET_FLAG (tree_view, GTK_TREE_VIEW_DRAW_KEYFOCUS);
|
||||
gtk_widget_grab_focus (GTK_WIDGET (tree_view));
|
||||
|
||||
cursor_path = NULL;
|
||||
if (tree_view->priv->cursor)
|
||||
cursor_path = gtk_tree_row_reference_get_path (tree_view->priv->cursor);
|
||||
|
||||
if (cursor_path == NULL)
|
||||
{
|
||||
GtkTreePath *tmp_path = gtk_tree_path_new_root ();
|
||||
/* FIXME: Get the first one visible!!! */
|
||||
if (tree_view->priv->cursor)
|
||||
gtk_tree_row_reference_free (tree_view->priv->cursor);
|
||||
|
||||
tree_view->priv->cursor =
|
||||
gtk_tree_row_reference_new_proxy (G_OBJECT (tree_view), tree_view->priv->model, tmp_path);
|
||||
cursor_path = tmp_path;
|
||||
}
|
||||
|
||||
gtk_tree_selection_select_path (tree_view->priv->selection, cursor_path);
|
||||
gtk_tree_view_queue_draw_path (tree_view, cursor_path, NULL);
|
||||
gtk_tree_path_free (cursor_path);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_tree_view_move_cursor_up_down (GtkTreeView *tree_view,
|
||||
gint count,
|
||||
gboolean extend_selection)
|
||||
{
|
||||
GtkRBTree *cursor_tree = NULL;
|
||||
GtkRBNode *cursor_node = NULL;
|
||||
GtkTreePath *cursor_path = NULL;
|
||||
|
||||
cursor_path = NULL;
|
||||
if (tree_view->priv->cursor)
|
||||
cursor_path = gtk_tree_row_reference_get_path (tree_view->priv->cursor);
|
||||
|
||||
g_print ("up_down: cursor path is %s\n", cursor_path?"non NULL":"NULL");
|
||||
_gtk_tree_view_find_node (tree_view, cursor_path,
|
||||
&cursor_tree,
|
||||
&cursor_node);
|
||||
gtk_tree_view_queue_draw_path (tree_view, cursor_path, NULL);
|
||||
if (tree_view->priv->cursor)
|
||||
{
|
||||
gtk_tree_row_reference_free (tree_view->priv->cursor);
|
||||
tree_view->priv->cursor = NULL;
|
||||
}
|
||||
|
||||
if (count == -1)
|
||||
_gtk_rbtree_prev_full (cursor_tree, cursor_node,
|
||||
&cursor_tree, &cursor_node);
|
||||
else
|
||||
_gtk_rbtree_next_full (cursor_tree, cursor_node,
|
||||
&cursor_tree, &cursor_node);
|
||||
gtk_tree_path_free (cursor_path);
|
||||
|
||||
if (cursor_node)
|
||||
{
|
||||
cursor_path = _gtk_tree_view_find_path (tree_view,
|
||||
cursor_tree,
|
||||
cursor_node);
|
||||
if (cursor_path)
|
||||
{
|
||||
_gtk_tree_selection_internal_select_node (tree_view->priv->selection,
|
||||
cursor_node,
|
||||
cursor_tree,
|
||||
cursor_path,
|
||||
extend_selection?0:0);
|
||||
|
||||
tree_view->priv->cursor = gtk_tree_row_reference_new_proxy (G_OBJECT (tree_view), tree_view->priv->model, cursor_path);
|
||||
gtk_tree_view_queue_draw_path (tree_view, cursor_path, NULL);
|
||||
|
||||
gtk_tree_path_free (cursor_path);
|
||||
}
|
||||
gtk_tree_view_clamp_node_visible (tree_view, cursor_tree, cursor_node);
|
||||
gtk_widget_grab_focus (GTK_WIDGET (tree_view));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_tree_view_update_size (GtkTreeView *tree_view)
|
||||
{
|
||||
@ -6165,7 +6337,7 @@ gtk_tree_view_insert_column_with_data_func (GtkTreeView *tree_vie
|
||||
gint position,
|
||||
gchar *title,
|
||||
GtkCellRenderer *cell,
|
||||
GtkCellDataFunc func,
|
||||
GtkTreeCellDataFunc func,
|
||||
gpointer data,
|
||||
GDestroyNotify dnotify)
|
||||
{
|
||||
|
@ -77,6 +77,18 @@ struct _GtkTreeViewClass
|
||||
GtkTreeIter *iter,
|
||||
GtkTreePath *path);
|
||||
void (* columns_changed) (GtkTreeView *tree_view);
|
||||
|
||||
/* Key Binding signals */
|
||||
void (* move_cursor) (GtkTreeView *tree_view,
|
||||
GtkMovementStep step,
|
||||
gint count,
|
||||
gboolean extend_selection);
|
||||
void (* set_anchor) (GtkTreeView *tree_view);
|
||||
void (* expand_selected_row) (GtkTreeView *tree_view);
|
||||
void (* collapse_selected_row) (GtkTreeView *tree_view);
|
||||
void (* expand_all_selected_row)(GtkTreeView *tree_view);
|
||||
void (* select_selected_parent) (GtkTreeView *tree_view);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -142,7 +154,7 @@ gint gtk_tree_view_insert_column_with_data_func (GtkTreeView
|
||||
gint position,
|
||||
gchar *title,
|
||||
GtkCellRenderer *cell,
|
||||
GtkCellDataFunc func,
|
||||
GtkTreeCellDataFunc func,
|
||||
gpointer data,
|
||||
GDestroyNotify dnotify);
|
||||
GtkTreeViewColumn *gtk_tree_view_get_column (GtkTreeView *tree_view,
|
||||
|
@ -84,10 +84,6 @@ static void gtk_tree_view_column_button_clicked (GtkWidget
|
||||
gpointer data);
|
||||
|
||||
/* Property handlers */
|
||||
static void gtk_tree_view_model_property_changed (GtkTreeView *view,
|
||||
guint n_pspecs,
|
||||
GParamSpec **pspecs,
|
||||
GtkTreeViewColumn *tree_column);
|
||||
static void gtk_tree_view_model_sort_column_changed (GtkTreeSortable *sortable,
|
||||
GtkTreeViewColumn *tree_column);
|
||||
|
||||
@ -762,23 +758,6 @@ gtk_tree_view_column_button_clicked (GtkWidget *widget, gpointer data)
|
||||
g_signal_emit_by_name (G_OBJECT (data), "clicked");
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_tree_view_model_property_changed (GtkTreeView *view,
|
||||
guint n_pspecs,
|
||||
GParamSpec **pspecs,
|
||||
GtkTreeViewColumn *tree_column)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < n_pspecs; i++)
|
||||
{
|
||||
if (! strcmp (pspecs[i]->name, "model"))
|
||||
{
|
||||
gtk_tree_view_column_setup_sort_column_id_callback (tree_column);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_tree_view_model_sort_column_changed (GtkTreeSortable *sortable,
|
||||
GtkTreeViewColumn *column)
|
||||
@ -959,10 +938,11 @@ _gtk_tree_view_column_set_tree_view (GtkTreeViewColumn *column,
|
||||
column->tree_view = GTK_WIDGET (tree_view);
|
||||
gtk_tree_view_column_create_button (column);
|
||||
|
||||
column->property_changed_signal = gtk_signal_connect (GTK_OBJECT (tree_view),
|
||||
"properties_changed",
|
||||
GTK_SIGNAL_FUNC (gtk_tree_view_model_property_changed),
|
||||
column);
|
||||
column->property_changed_signal =
|
||||
g_signal_connect_data (GTK_OBJECT (tree_view),
|
||||
"notify::model",
|
||||
GTK_SIGNAL_FUNC (gtk_tree_view_column_setup_sort_column_id_callback),
|
||||
column, NULL, TRUE, FALSE);
|
||||
|
||||
gtk_tree_view_column_setup_sort_column_id_callback (column);
|
||||
}
|
||||
@ -1212,10 +1192,10 @@ gtk_tree_view_column_set_attributes (GtkTreeViewColumn *tree_column,
|
||||
* may be NULL to remove an older one.
|
||||
**/
|
||||
void
|
||||
gtk_tree_view_column_set_cell_data_func (GtkTreeViewColumn *tree_column,
|
||||
GtkCellDataFunc func,
|
||||
gpointer func_data,
|
||||
GtkDestroyNotify destroy)
|
||||
gtk_tree_view_column_set_cell_data_func (GtkTreeViewColumn *tree_column,
|
||||
GtkTreeCellDataFunc func,
|
||||
gpointer func_data,
|
||||
GtkDestroyNotify destroy)
|
||||
{
|
||||
g_return_if_fail (tree_column != NULL);
|
||||
g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
|
||||
|
@ -46,11 +46,11 @@ typedef enum
|
||||
typedef struct _GtkTreeViewColumn GtkTreeViewColumn;
|
||||
typedef struct _GtkTreeViewColumnClass GtkTreeViewColumnClass;
|
||||
|
||||
typedef void (* GtkCellDataFunc) (GtkTreeViewColumn *tree_column,
|
||||
GtkCellRenderer *cell,
|
||||
GtkTreeModel *tree_model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer data);
|
||||
typedef void (* GtkTreeCellDataFunc) (GtkTreeViewColumn *tree_column,
|
||||
GtkCellRenderer *cell,
|
||||
GtkTreeModel *tree_model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer data);
|
||||
|
||||
|
||||
struct _GtkTreeViewColumn
|
||||
@ -76,7 +76,7 @@ struct _GtkTreeViewColumn
|
||||
gint drag_x;
|
||||
gint drag_y;
|
||||
|
||||
GtkCellDataFunc func;
|
||||
GtkTreeCellDataFunc func;
|
||||
gpointer func_data;
|
||||
GtkDestroyNotify destroy;
|
||||
gchar *title;
|
||||
@ -120,7 +120,7 @@ void gtk_tree_view_column_add_attribute (GtkTreeViewColum
|
||||
void gtk_tree_view_column_set_attributes (GtkTreeViewColumn *tree_column,
|
||||
...);
|
||||
void gtk_tree_view_column_set_cell_data_func (GtkTreeViewColumn *tree_column,
|
||||
GtkCellDataFunc func,
|
||||
GtkTreeCellDataFunc func,
|
||||
gpointer func_data,
|
||||
GtkDestroyNotify destroy);
|
||||
void gtk_tree_view_column_clear_attributes (GtkTreeViewColumn *tree_column);
|
||||
|
@ -334,6 +334,8 @@ main (int argc, char *argv[])
|
||||
-1, "Holiday",
|
||||
renderer,
|
||||
"text", HOLIDAY_COLUMN, NULL);
|
||||
column = gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), col_offset - 1);
|
||||
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
|
||||
g_object_unref (renderer);
|
||||
|
||||
/* Alex Column */
|
||||
@ -351,6 +353,7 @@ main (int argc, char *argv[])
|
||||
column = gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), col_offset - 1);
|
||||
gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), GTK_TREE_VIEW_COLUMN_FIXED);
|
||||
gtk_tree_view_column_set_width (GTK_TREE_VIEW_COLUMN (column), 50);
|
||||
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
|
||||
g_object_unref (renderer);
|
||||
|
||||
/* Havoc Column */
|
||||
@ -367,6 +370,7 @@ main (int argc, char *argv[])
|
||||
column = gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), col_offset - 1);
|
||||
gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), GTK_TREE_VIEW_COLUMN_FIXED);
|
||||
gtk_tree_view_column_set_width (GTK_TREE_VIEW_COLUMN (column), 50);
|
||||
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
|
||||
g_object_unref (renderer);
|
||||
|
||||
/* Tim Column */
|
||||
@ -383,6 +387,7 @@ main (int argc, char *argv[])
|
||||
NULL);
|
||||
column = gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), col_offset - 1);
|
||||
gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), GTK_TREE_VIEW_COLUMN_FIXED);
|
||||
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
|
||||
gtk_tree_view_column_set_width (GTK_TREE_VIEW_COLUMN (column), 50);
|
||||
g_object_unref (renderer);
|
||||
|
||||
@ -398,6 +403,7 @@ main (int argc, char *argv[])
|
||||
NULL);
|
||||
column = gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), col_offset - 1);
|
||||
gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), GTK_TREE_VIEW_COLUMN_FIXED);
|
||||
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
|
||||
gtk_tree_view_column_set_width (GTK_TREE_VIEW_COLUMN (column), 50);
|
||||
g_object_unref (renderer);
|
||||
|
||||
@ -414,6 +420,7 @@ main (int argc, char *argv[])
|
||||
column = gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), col_offset - 1);
|
||||
gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), GTK_TREE_VIEW_COLUMN_FIXED);
|
||||
gtk_tree_view_column_set_width (GTK_TREE_VIEW_COLUMN (column), 50);
|
||||
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
|
||||
g_object_unref (renderer);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (scrolled_window), tree_view);
|
||||
|
Loading…
Reference in New Issue
Block a user