[gtk/wip/matthiasc/focus2: 1/4] Remove no-longer used code
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/focus2: 1/4] Remove no-longer used code
- Date: Sun, 3 Mar 2019 05:53:46 +0000 (UTC)
commit ba07d214036cc8242210e05fd18bacf10d6f80bd
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Mar 3 00:04:54 2019 -0500
Remove no-longer used code
We no longer call the ::focus vfunc, so remove
all existing implementations. This needs careful
review to determine how to bring the functionality
in these handlers back.
gtk/gtkflowbox.c | 157 ---------------------------------
gtk/gtklabel.c | 146 -------------------------------
gtk/gtklistbox.c | 198 ------------------------------------------
gtk/gtkmenu.c | 16 ++--
gtk/gtknotebook.c | 224 ------------------------------------------------
gtk/gtkpaned.c | 21 -----
gtk/gtkpopover.c | 34 --------
gtk/gtkradiobutton.c | 96 ---------------------
gtk/gtkscrolledwindow.c | 42 ---------
gtk/gtktextview.c | 36 --------
gtk/gtktoolbar.c | 40 ---------
gtk/gtktreeview.c | 220 -----------------------------------------------
gtk/gtkwidget.c | 47 +---------
gtk/gtkwidget.h | 4 +-
14 files changed, 14 insertions(+), 1267 deletions(-)
---
diff --git a/gtk/gtkflowbox.c b/gtk/gtkflowbox.c
index 65c491fe4b..b40ffca25a 100644
--- a/gtk/gtkflowbox.c
+++ b/gtk/gtkflowbox.c
@@ -303,92 +303,8 @@ gtk_flow_box_child_get_box (GtkFlowBoxChild *child)
return NULL;
}
-static void
-gtk_flow_box_child_set_focus (GtkFlowBoxChild *child)
-{
- GtkFlowBox *box = gtk_flow_box_child_get_box (child);
- gboolean modify;
- gboolean extend;
-
- get_current_selection_modifiers (GTK_WIDGET (box), &modify, &extend);
-
- if (modify)
- gtk_flow_box_update_cursor (box, child);
- else
- gtk_flow_box_update_selection (box, child, FALSE, FALSE);
-}
-
/* GtkWidget implementation {{{2 */
-static gboolean
-gtk_flow_box_child_focus (GtkWidget *widget,
- GtkDirectionType direction)
-{
- gboolean had_focus = FALSE;
- GtkWidget *child;
-
- child = gtk_bin_get_child (GTK_BIN (widget));
-
- /* Without "can-focus" flag try to pass the focus to the child immediately */
- if (!gtk_widget_get_can_focus (widget))
- {
- if (child)
- {
- if (gtk_widget_child_focus (child, direction))
- {
- GtkFlowBox *box;
- box = gtk_flow_box_child_get_box (GTK_FLOW_BOX_CHILD (widget));
- if (box)
- gtk_flow_box_update_cursor (box, GTK_FLOW_BOX_CHILD (widget));
- return TRUE;
- }
- }
- return FALSE;
- }
-
- g_object_get (widget, "has-focus", &had_focus, NULL);
- if (had_focus)
- {
- /* If on row, going right, enter into possible container */
- if (child &&
- (direction == GTK_DIR_RIGHT || direction == GTK_DIR_TAB_FORWARD))
- {
- if (gtk_widget_child_focus (GTK_WIDGET (child), direction))
- return TRUE;
- }
-
- return FALSE;
- }
- else if (gtk_widget_get_focus_child (widget) != NULL)
- {
- /* Child has focus, always navigate inside it first */
- if (gtk_widget_child_focus (child, direction))
- return TRUE;
-
- /* If exiting child container to the left, select child */
- if (direction == GTK_DIR_LEFT || direction == GTK_DIR_TAB_BACKWARD)
- {
- gtk_flow_box_child_set_focus (GTK_FLOW_BOX_CHILD (widget));
- return TRUE;
- }
-
- return FALSE;
- }
- else
- {
- /* If coming from the left, enter into possible container */
- if (child &&
- (direction == GTK_DIR_LEFT || direction == GTK_DIR_TAB_BACKWARD))
- {
- if (gtk_widget_child_focus (child, direction))
- return TRUE;
- }
-
- gtk_flow_box_child_set_focus (GTK_FLOW_BOX_CHILD (widget));
- return TRUE;
- }
-}
-
static void
gtk_flow_box_child_activate (GtkFlowBoxChild *child)
{
@@ -422,7 +338,6 @@ gtk_flow_box_child_class_init (GtkFlowBoxChildClass *class)
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
widget_class->get_request_mode = gtk_flow_box_child_get_request_mode;
- widget_class->focus = gtk_flow_box_child_focus;
class->activate = gtk_flow_box_child_activate;
@@ -2893,77 +2808,6 @@ gtk_flow_box_child_type (GtkContainer *container)
/* Keynav {{{2 */
-static gboolean
-gtk_flow_box_focus (GtkWidget *widget,
- GtkDirectionType direction)
-{
- GtkFlowBox *box = GTK_FLOW_BOX (widget);
- GtkWidget *focus_child;
- GSequenceIter *iter;
- GtkFlowBoxChild *next_focus_child;
-
- /* Without "can-focus" flag fall back to the default behavior immediately */
- if (!gtk_widget_get_can_focus (widget))
- {
- return GTK_WIDGET_CLASS (gtk_flow_box_parent_class)->focus (widget, direction);
- }
-
- focus_child = gtk_widget_get_focus_child (widget);
- next_focus_child = NULL;
-
- if (focus_child != NULL)
- {
- if (gtk_widget_child_focus (focus_child, direction))
- return TRUE;
-
- iter = CHILD_PRIV (focus_child)->iter;
-
- if (direction == GTK_DIR_LEFT || direction == GTK_DIR_TAB_BACKWARD)
- iter = gtk_flow_box_get_previous_focusable (box, iter);
- else if (direction == GTK_DIR_RIGHT || direction == GTK_DIR_TAB_FORWARD)
- iter = gtk_flow_box_get_next_focusable (box, iter);
- else if (direction == GTK_DIR_UP)
- iter = gtk_flow_box_get_above_focusable (box, iter);
- else if (direction == GTK_DIR_DOWN)
- iter = gtk_flow_box_get_below_focusable (box, iter);
-
- if (iter != NULL)
- next_focus_child = g_sequence_get (iter);
- }
- else
- {
- if (BOX_PRIV (box)->selected_child)
- next_focus_child = BOX_PRIV (box)->selected_child;
- else
- {
- if (direction == GTK_DIR_UP || direction == GTK_DIR_TAB_BACKWARD)
- iter = gtk_flow_box_get_last_focusable (box);
- else
- iter = gtk_flow_box_get_first_focusable (box);
-
- if (iter != NULL)
- next_focus_child = g_sequence_get (iter);
- }
- }
-
- if (next_focus_child == NULL)
- {
- if (direction == GTK_DIR_UP || direction == GTK_DIR_DOWN ||
- direction == GTK_DIR_LEFT || direction == GTK_DIR_RIGHT)
- {
- if (gtk_widget_keynav_failed (GTK_WIDGET (box), direction))
- return TRUE;
- }
-
- return FALSE;
- }
-
- if (gtk_widget_child_focus (GTK_WIDGET (next_focus_child), direction))
- return TRUE;
-
- return TRUE;
-}
-
static void
gtk_flow_box_add_move_binding (GtkBindingSet *binding_set,
guint keyval,
@@ -3373,7 +3217,6 @@ gtk_flow_box_class_init (GtkFlowBoxClass *class)
widget_class->size_allocate = gtk_flow_box_size_allocate;
widget_class->unmap = gtk_flow_box_unmap;
- widget_class->focus = gtk_flow_box_focus;
widget_class->snapshot = gtk_flow_box_snapshot;
widget_class->get_request_mode = gtk_flow_box_get_request_mode;
widget_class->measure = gtk_flow_box_measure;
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index e3be68e02e..e8b3355c92 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -413,8 +413,6 @@ static void gtk_label_state_flags_changed (GtkWidget *widget,
static void gtk_label_style_updated (GtkWidget *widget);
static void gtk_label_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot);
-static gboolean gtk_label_focus (GtkWidget *widget,
- GtkDirectionType direction);
static void gtk_label_realize (GtkWidget *widget);
static void gtk_label_unrealize (GtkWidget *widget);
@@ -612,7 +610,6 @@ gtk_label_class_init (GtkLabelClass *class)
widget_class->drag_data_get = gtk_label_drag_data_get;
widget_class->grab_focus = gtk_label_grab_focus;
widget_class->popup_menu = gtk_label_popup_menu;
- widget_class->focus = gtk_label_focus;
widget_class->get_request_mode = gtk_label_get_request_mode;
widget_class->measure = gtk_label_measure;
@@ -4298,149 +4295,6 @@ gtk_label_grab_focus (GtkWidget *widget)
}
}
-static gboolean
-gtk_label_focus (GtkWidget *widget,
- GtkDirectionType direction)
-{
- GtkLabel *label = GTK_LABEL (widget);
- GtkLabelPrivate *priv = gtk_label_get_instance_private (label);
- GtkLabelSelectionInfo *info = priv->select_info;
- GtkLabelLink *focus_link;
- GList *l;
-
- if (!gtk_widget_is_focus (widget))
- {
- gtk_widget_grab_focus (widget);
- if (info)
- {
- focus_link = gtk_label_get_focus_link (label);
- if (focus_link && direction == GTK_DIR_TAB_BACKWARD)
- {
- for (l = g_list_last (info->links); l; l = l->prev)
- {
- focus_link = l->data;
- if (!range_is_in_ellipsis (label, focus_link->start, focus_link->end))
- {
- info->selection_anchor = focus_link->start;
- info->selection_end = focus_link->start;
- _gtk_label_accessible_focus_link_changed (label);
- }
- }
- }
-
- return TRUE;
- }
-
- return FALSE;
- }
-
- if (!info)
- return FALSE;
-
- if (info->selectable)
- {
- gint index;
-
- if (info->selection_anchor != info->selection_end)
- goto out;
-
- index = info->selection_anchor;
-
- if (direction == GTK_DIR_TAB_FORWARD)
- for (l = info->links; l; l = l->next)
- {
- GtkLabelLink *link = l->data;
-
- if (link->start > index)
- {
- if (!range_is_in_ellipsis (label, link->start, link->end))
- {
- gtk_label_select_region_index (label, link->start, link->start);
- _gtk_label_accessible_focus_link_changed (label);
- return TRUE;
- }
- }
- }
- else if (direction == GTK_DIR_TAB_BACKWARD)
- for (l = g_list_last (info->links); l; l = l->prev)
- {
- GtkLabelLink *link = l->data;
-
- if (link->end < index)
- {
- if (!range_is_in_ellipsis (label, link->start, link->end))
- {
- gtk_label_select_region_index (label, link->start, link->start);
- _gtk_label_accessible_focus_link_changed (label);
- return TRUE;
- }
- }
- }
-
- goto out;
- }
- else
- {
- focus_link = gtk_label_get_focus_link (label);
- switch (direction)
- {
- case GTK_DIR_TAB_FORWARD:
- if (focus_link)
- {
- l = g_list_find (info->links, focus_link);
- l = l->next;
- }
- else
- l = info->links;
- for (; l; l = l->next)
- {
- GtkLabelLink *link = l->data;
- if (!range_is_in_ellipsis (label, link->start, link->end))
- break;
- }
- break;
-
- case GTK_DIR_TAB_BACKWARD:
- if (focus_link)
- {
- l = g_list_find (info->links, focus_link);
- l = l->prev;
- }
- else
- l = g_list_last (info->links);
- for (; l; l = l->prev)
- {
- GtkLabelLink *link = l->data;
- if (!range_is_in_ellipsis (label, link->start, link->end))
- break;
- }
- break;
-
- default:
- case GTK_DIR_UP:
- case GTK_DIR_DOWN:
- case GTK_DIR_LEFT:
- case GTK_DIR_RIGHT:
- goto out;
- }
-
- if (l)
- {
- focus_link = l->data;
- info->selection_anchor = focus_link->start;
- info->selection_end = focus_link->start;
- _gtk_label_accessible_focus_link_changed (label);
- gtk_widget_queue_draw (widget);
-
- return TRUE;
- }
- }
-
-out:
-
- return FALSE;
-}
-
static void
gtk_label_multipress_gesture_pressed (GtkGestureMultiPress *gesture,
gint n_press,
diff --git a/gtk/gtklistbox.c b/gtk/gtklistbox.c
index f6ccfb1931..b3edb45fec 100644
--- a/gtk/gtklistbox.c
+++ b/gtk/gtklistbox.c
@@ -208,8 +208,6 @@ static void gtk_list_box_update_cursor (GtkListBo
GtkListBoxRow *row,
gboolean grab_focus);
static void gtk_list_box_show (GtkWidget *widget);
-static gboolean gtk_list_box_focus (GtkWidget *widget,
- GtkDirectionType direction);
static GSequenceIter* gtk_list_box_get_previous_visible (GtkListBox *box,
GSequenceIter *iter);
static GtkListBoxRow *gtk_list_box_get_first_focusable (GtkListBox *box);
@@ -407,7 +405,6 @@ gtk_list_box_class_init (GtkListBoxClass *klass)
object_class->set_property = gtk_list_box_set_property;
object_class->finalize = gtk_list_box_finalize;
widget_class->show = gtk_list_box_show;
- widget_class->focus = gtk_list_box_focus;
widget_class->compute_expand = gtk_list_box_compute_expand;
widget_class->get_request_mode = gtk_list_box_get_request_mode;
widget_class->measure = gtk_list_box_measure;
@@ -1870,129 +1867,6 @@ gtk_list_box_show (GtkWidget *widget)
GTK_WIDGET_CLASS (gtk_list_box_parent_class)->show (widget);
}
-static gboolean
-gtk_list_box_focus (GtkWidget *widget,
- GtkDirectionType direction)
-{
- GtkListBox *box = GTK_LIST_BOX (widget);
- GtkListBoxPrivate *priv = BOX_PRIV (box);
- GtkWidget *focus_child;
- GtkListBoxRow *next_focus_row;
- GtkWidget *row;
- GtkWidget *header;
-
- focus_child = gtk_widget_get_focus_child (widget);
-
- next_focus_row = NULL;
- if (focus_child != NULL)
- {
- GSequenceIter *i;
-
- if (gtk_widget_child_focus (focus_child, direction))
- return TRUE;
-
- if (direction == GTK_DIR_UP || direction == GTK_DIR_TAB_BACKWARD)
- {
- if (GTK_IS_LIST_BOX_ROW (focus_child))
- {
- header = ROW_PRIV (GTK_LIST_BOX_ROW (focus_child))->header;
- if (header && gtk_widget_child_focus (header, direction))
- return TRUE;
- }
-
- if (GTK_IS_LIST_BOX_ROW (focus_child))
- row = focus_child;
- else
- row = g_hash_table_lookup (priv->header_hash, focus_child);
-
- if (GTK_IS_LIST_BOX_ROW (row))
- i = gtk_list_box_get_previous_visible (box, ROW_PRIV (GTK_LIST_BOX_ROW (row))->iter);
- else
- i = NULL;
-
- while (i != NULL)
- {
- if (gtk_widget_get_sensitive (g_sequence_get (i)))
- {
- next_focus_row = g_sequence_get (i);
- break;
- }
-
- i = gtk_list_box_get_previous_visible (box, i);
- }
- }
- else if (direction == GTK_DIR_DOWN || direction == GTK_DIR_TAB_FORWARD)
- {
- if (GTK_IS_LIST_BOX_ROW (focus_child))
- i = gtk_list_box_get_next_visible (box, ROW_PRIV (GTK_LIST_BOX_ROW (focus_child))->iter);
- else
- {
- row = g_hash_table_lookup (priv->header_hash, focus_child);
- if (GTK_IS_LIST_BOX_ROW (row))
- i = ROW_PRIV (GTK_LIST_BOX_ROW (row))->iter;
- else
- i = NULL;
- }
-
- while (!g_sequence_iter_is_end (i))
- {
- if (gtk_widget_get_sensitive (g_sequence_get (i)))
- {
- next_focus_row = g_sequence_get (i);
- break;
- }
-
- i = gtk_list_box_get_next_visible (box, i);
- }
- }
- }
- else
- {
- /* No current focus row */
- switch (direction)
- {
- case GTK_DIR_UP:
- case GTK_DIR_TAB_BACKWARD:
- next_focus_row = priv->selected_row;
- if (next_focus_row == NULL)
- next_focus_row = gtk_list_box_get_last_focusable (box);
- break;
- case GTK_DIR_DOWN:
- case GTK_DIR_TAB_FORWARD:
- case GTK_DIR_LEFT:
- case GTK_DIR_RIGHT:
- default:
- next_focus_row = priv->selected_row;
- if (next_focus_row == NULL)
- next_focus_row = gtk_list_box_get_first_focusable (box);
- break;
- }
- }
-
- if (next_focus_row == NULL)
- {
- if (direction == GTK_DIR_UP || direction == GTK_DIR_DOWN)
- {
- if (gtk_widget_keynav_failed (GTK_WIDGET (box), direction))
- return TRUE;
- }
-
- return FALSE;
- }
-
- if (direction == GTK_DIR_DOWN || direction == GTK_DIR_TAB_FORWARD)
- {
- header = ROW_PRIV (next_focus_row)->header;
- if (header && gtk_widget_child_focus (header, direction))
- return TRUE;
- }
-
- if (gtk_widget_child_focus (GTK_WIDGET (next_focus_row), direction))
- return TRUE;
-
- return FALSE;
-}
-
static void
list_box_add_visible_rows (GtkListBox *box,
gint n)
@@ -2882,77 +2756,6 @@ gtk_list_box_row_new (void)
return g_object_new (GTK_TYPE_LIST_BOX_ROW, NULL);
}
-static void
-gtk_list_box_row_set_focus (GtkListBoxRow *row)
-{
- GtkListBox *box = gtk_list_box_row_get_box (row);
- gboolean modify;
- gboolean extend;
-
- if (!box)
- return;
-
- get_current_selection_modifiers (GTK_WIDGET (row), &modify, &extend);
-
- if (modify)
- gtk_list_box_update_cursor (box, row, TRUE);
- else
- gtk_list_box_update_selection (box, row, FALSE, FALSE);
-}
-
-static gboolean
-gtk_list_box_row_focus (GtkWidget *widget,
- GtkDirectionType direction)
-{
- GtkListBoxRow *row = GTK_LIST_BOX_ROW (widget);
- gboolean had_focus = FALSE;
- GtkWidget *child;
-
- child = gtk_bin_get_child (GTK_BIN (widget));
-
- g_object_get (widget, "has-focus", &had_focus, NULL);
- if (had_focus)
- {
- /* If on row, going right, enter into possible container */
- if (child &&
- (direction == GTK_DIR_RIGHT || direction == GTK_DIR_TAB_FORWARD))
- {
- if (gtk_widget_child_focus (GTK_WIDGET (child), direction))
- return TRUE;
- }
-
- return FALSE;
- }
- else if (gtk_widget_get_focus_child (widget) != NULL)
- {
- /* Child has focus, always navigate inside it first */
- if (gtk_widget_child_focus (gtk_widget_get_focus_child (widget), direction))
- return TRUE;
-
- /* If exiting child container to the left, select row */
- if (direction == GTK_DIR_LEFT || direction == GTK_DIR_TAB_BACKWARD)
- {
- gtk_list_box_row_set_focus (row);
- return TRUE;
- }
-
- return FALSE;
- }
- else
- {
- /* If coming from the left, enter into possible container */
- if (child &&
- (direction == GTK_DIR_LEFT || direction == GTK_DIR_TAB_BACKWARD))
- {
- if (gtk_widget_child_focus (child, direction))
- return TRUE;
- }
-
- gtk_list_box_row_set_focus (row);
- return TRUE;
- }
-}
-
static void
gtk_list_box_row_activate (GtkListBoxRow *row)
{
@@ -3384,7 +3187,6 @@ gtk_list_box_row_class_init (GtkListBoxRowClass *klass)
widget_class->show = gtk_list_box_row_show;
widget_class->hide = gtk_list_box_row_hide;
- widget_class->focus = gtk_list_box_row_focus;
widget_class->grab_focus = gtk_list_box_row_grab_focus;
klass->activate = gtk_list_box_row_activate;
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index 247dd4f12e..a3a22cbcb5 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -251,8 +251,9 @@ static void gtk_menu_handle_scrolling (GtkMenu *menu,
gint event_y,
gboolean enter,
gboolean motion);
-static gboolean gtk_menu_focus (GtkWidget *widget,
- GtkDirectionType direction);
+static GtkWidget *gtk_menu_next_focus_child (GtkWidget *widget,
+ GtkWidget *child,
+ GtkDirectionType direction);
static gint gtk_menu_get_popup_delay (GtkMenuShell *menu_shell);
static void gtk_menu_move_current (GtkMenuShell *menu_shell,
GtkMenuDirectionType direction);
@@ -492,7 +493,7 @@ gtk_menu_class_init (GtkMenuClass *class)
widget_class->size_allocate = gtk_menu_size_allocate;
widget_class->show = gtk_menu_show;
widget_class->snapshot = gtk_menu_snapshot;
- widget_class->focus = gtk_menu_focus;
+ widget_class->next_focus_child = gtk_menu_next_focus_child;
widget_class->can_activate_accel = gtk_menu_real_can_activate_accel;
widget_class->grab_notify = gtk_menu_grab_notify;
widget_class->measure = gtk_menu_measure;
@@ -2254,12 +2255,13 @@ gtk_menu_realize (GtkWidget *widget)
GTK_MENU_SHELL (widget)->priv->active_menu_item);
}
-static gboolean
-gtk_menu_focus (GtkWidget *widget,
- GtkDirectionType direction)
+static GtkWidget *
+gtk_menu_next_focus_child (GtkWidget *widget,
+ GtkWidget *child,
+ GtkDirectionType direction)
{
/* A menu or its menu items cannot have focus */
- return FALSE;
+ return NULL;
}
static GdkSurface *
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index ad0ee966a5..91c3398acf 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -643,8 +643,6 @@ static void gtk_notebook_grab_notify (GtkWidget *widget,
gboolean was_grabbed);
static void gtk_notebook_state_flags_changed (GtkWidget *widget,
GtkStateFlags previous_state);
-static gboolean gtk_notebook_focus (GtkWidget *widget,
- GtkDirectionType direction);
/*** Drag and drop Methods ***/
static void gtk_notebook_drag_begin (GtkWidget *widget,
@@ -919,7 +917,6 @@ gtk_notebook_class_init (GtkNotebookClass *class)
widget_class->popup_menu = gtk_notebook_popup_menu;
widget_class->grab_notify = gtk_notebook_grab_notify;
widget_class->state_flags_changed = gtk_notebook_state_flags_changed;
- widget_class->focus = gtk_notebook_focus;
widget_class->drag_begin = gtk_notebook_drag_begin;
widget_class->drag_end = gtk_notebook_drag_end;
widget_class->drag_motion = gtk_notebook_drag_motion;
@@ -3468,7 +3465,6 @@ gtk_notebook_drag_data_received (GtkWidget *widget,
*
* gtk_notebook_add
* gtk_notebook_remove
- * gtk_notebook_focus
* gtk_notebook_child_type
* gtk_notebook_forall
*/
@@ -3543,30 +3539,6 @@ focus_tabs_in (GtkNotebook *notebook)
return FALSE;
}
-static gboolean
-focus_tabs_move (GtkNotebook *notebook,
- GtkDirectionType direction,
- gint search_direction)
-{
- GtkNotebookPrivate *priv = notebook->priv;
- GList *new_page;
-
- new_page = gtk_notebook_search_page (notebook, priv->focus_tab,
- search_direction, TRUE);
- if (!new_page)
- {
- new_page = gtk_notebook_search_page (notebook, NULL,
- search_direction, TRUE);
- }
-
- if (new_page)
- gtk_notebook_switch_focus_tab (notebook, new_page);
- else
- gtk_widget_error_bell (GTK_WIDGET (notebook));
-
- return TRUE;
-}
-
static gboolean
focus_child_in (GtkNotebook *notebook,
GtkDirectionType direction)
@@ -3579,202 +3551,6 @@ focus_child_in (GtkNotebook *notebook,
return FALSE;
}
-static gboolean
-focus_action_in (GtkNotebook *notebook,
- gint action,
- GtkDirectionType direction)
-{
- GtkNotebookPrivate *priv = notebook->priv;
-
- if (priv->action_widget[action] &&
- gtk_widget_get_visible (priv->action_widget[action]))
- return gtk_widget_child_focus (priv->action_widget[action], direction);
- else
- return FALSE;
-}
-
-/* Focus in the notebook can either be on the pages, or on
- * the tabs or on the action_widgets.
- */
-static gboolean
-gtk_notebook_focus (GtkWidget *widget,
- GtkDirectionType direction)
-{
- GtkNotebook *notebook = GTK_NOTEBOOK (widget);
- GtkNotebookPrivate *priv = notebook->priv;
- GtkWidget *old_focus_child;
- GtkDirectionType effective_direction;
- gint first_action;
- gint last_action;
-
- gboolean widget_is_focus;
-
- if (priv->tab_pos == GTK_POS_TOP ||
- priv->tab_pos == GTK_POS_LEFT)
- {
- first_action = ACTION_WIDGET_START;
- last_action = ACTION_WIDGET_END;
- }
- else
- {
- first_action = ACTION_WIDGET_END;
- last_action = ACTION_WIDGET_START;
- }
-
- if (priv->focus_out)
- {
- priv->focus_out = FALSE; /* Clear this to catch the wrap-around case */
- return FALSE;
- }
-
- widget_is_focus = gtk_widget_is_focus (widget);
- old_focus_child = gtk_widget_get_focus_child (widget);
-
- effective_direction = get_effective_direction (notebook, direction);
-
- if (old_focus_child) /* Focus on page child or action widget */
- {
- if (gtk_widget_child_focus (old_focus_child, direction))
- return TRUE;
-
- if (old_focus_child == priv->action_widget[ACTION_WIDGET_START])
- {
- switch ((guint) effective_direction)
- {
- case GTK_DIR_DOWN:
- return focus_child_in (notebook, GTK_DIR_TAB_FORWARD);
- case GTK_DIR_RIGHT:
- return focus_tabs_in (notebook);
- case GTK_DIR_LEFT:
- return FALSE;
- case GTK_DIR_UP:
- return FALSE;
- default:
- switch ((guint) direction)
- {
- case GTK_DIR_TAB_FORWARD:
- if ((priv->tab_pos == GTK_POS_RIGHT || priv->tab_pos == GTK_POS_BOTTOM) &&
- focus_child_in (notebook, direction))
- return TRUE;
- return focus_tabs_in (notebook);
- case GTK_DIR_TAB_BACKWARD:
- return FALSE;
- default:
- g_assert_not_reached ();
- break;
- }
- }
- }
- else if (old_focus_child == priv->action_widget[ACTION_WIDGET_END])
- {
- switch ((guint) effective_direction)
- {
- case GTK_DIR_DOWN:
- return focus_child_in (notebook, GTK_DIR_TAB_FORWARD);
- case GTK_DIR_RIGHT:
- return FALSE;
- case GTK_DIR_LEFT:
- return focus_tabs_in (notebook);
- case GTK_DIR_UP:
- return FALSE;
- default:
- switch ((guint) direction)
- {
- case GTK_DIR_TAB_FORWARD:
- return FALSE;
- case GTK_DIR_TAB_BACKWARD:
- if ((priv->tab_pos == GTK_POS_TOP || priv->tab_pos == GTK_POS_LEFT) &&
- focus_child_in (notebook, direction))
- return TRUE;
- return focus_tabs_in (notebook);
- default:
- g_assert_not_reached ();
- break;
- }
- }
- }
- else
- {
- switch ((guint) effective_direction)
- {
- case GTK_DIR_TAB_BACKWARD:
- case GTK_DIR_UP:
- /* Focus onto the tabs */
- return focus_tabs_in (notebook);
- case GTK_DIR_DOWN:
- case GTK_DIR_LEFT:
- case GTK_DIR_RIGHT:
- return FALSE;
- case GTK_DIR_TAB_FORWARD:
- return focus_action_in (notebook, last_action, direction);
- default:
- break;
- }
- }
- }
- else if (widget_is_focus) /* Focus was on tabs */
- {
- switch ((guint) effective_direction)
- {
- case GTK_DIR_TAB_BACKWARD:
- return focus_action_in (notebook, first_action, direction);
- case GTK_DIR_UP:
- return FALSE;
- case GTK_DIR_TAB_FORWARD:
- if (focus_child_in (notebook, GTK_DIR_TAB_FORWARD))
- return TRUE;
- return focus_action_in (notebook, last_action, direction);
- case GTK_DIR_DOWN:
- /* We use TAB_FORWARD rather than direction so that we focus a more
- * predictable widget for the user; users may be using arrow focusing
- * in this situation even if they don't usually use arrow focusing.
- */
- return focus_child_in (notebook, GTK_DIR_TAB_FORWARD);
- case GTK_DIR_LEFT:
- return focus_tabs_move (notebook, direction, STEP_PREV);
- case GTK_DIR_RIGHT:
- return focus_tabs_move (notebook, direction, STEP_NEXT);
- default:
- break;
- }
- }
- else /* Focus was not on widget */
- {
- switch ((guint) effective_direction)
- {
- case GTK_DIR_TAB_FORWARD:
- case GTK_DIR_DOWN:
- if (focus_action_in (notebook, first_action, direction))
- return TRUE;
- if (focus_tabs_in (notebook))
- return TRUE;
- if (focus_action_in (notebook, last_action, direction))
- return TRUE;
- if (focus_child_in (notebook, direction))
- return TRUE;
- return FALSE;
- case GTK_DIR_TAB_BACKWARD:
- if (focus_action_in (notebook, last_action, direction))
- return TRUE;
- if (focus_child_in (notebook, direction))
- return TRUE;
- if (focus_tabs_in (notebook))
- return TRUE;
- if (focus_action_in (notebook, first_action, direction))
- return TRUE;
- case GTK_DIR_UP:
- case GTK_DIR_LEFT:
- case GTK_DIR_RIGHT:
- return focus_child_in (notebook, direction);
- default:
- break;
- }
- }
-
- g_assert_not_reached ();
- return FALSE;
-}
-
static void
gtk_notebook_forall (GtkContainer *container,
GtkCallback callback,
diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c
index abaa822d6b..24508b2c7e 100644
--- a/gtk/gtkpaned.c
+++ b/gtk/gtkpaned.c
@@ -216,8 +216,6 @@ static void gtk_paned_size_allocate (GtkWidget *widget,
int height,
int baseline);
static void gtk_paned_unrealize (GtkWidget *widget);
-static gboolean gtk_paned_focus (GtkWidget *widget,
- GtkDirectionType direction);
static void gtk_paned_add (GtkContainer *container,
GtkWidget *widget);
static void gtk_paned_remove (GtkContainer *container,
@@ -357,7 +355,6 @@ gtk_paned_class_init (GtkPanedClass *class)
widget_class->measure = gtk_paned_measure;
widget_class->size_allocate = gtk_paned_size_allocate;
widget_class->unrealize = gtk_paned_unrealize;
- widget_class->focus = gtk_paned_focus;
widget_class->pick = gtk_paned_pick;
container_class->add = gtk_paned_add;
@@ -1485,24 +1482,6 @@ update_drag (GtkPaned *paned,
gtk_paned_set_position (paned, size);
}
-static gboolean
-gtk_paned_focus (GtkWidget *widget,
- GtkDirectionType direction)
-
-{
- gboolean retval;
-
- /* This is a hack, but how can this be done without
- * excessive cut-and-paste from gtkcontainer.c?
- */
-
- gtk_widget_set_can_focus (widget, FALSE);
- retval = GTK_WIDGET_CLASS (gtk_paned_parent_class)->focus (widget, direction);
- gtk_widget_set_can_focus (widget, TRUE);
-
- return retval;
-}
-
/**
* gtk_paned_new:
* @orientation: the paned’s orientation.
diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c
index cfd697a234..6f305ed0aa 100644
--- a/gtk/gtkpopover.c
+++ b/gtk/gtkpopover.c
@@ -1455,39 +1455,6 @@ gtk_popover_grab_focus (GtkWidget *widget)
gtk_widget_child_focus (child, GTK_DIR_TAB_FORWARD);
}
-static gboolean
-gtk_popover_focus (GtkWidget *widget,
- GtkDirectionType direction)
-{
- GtkPopover *popover = GTK_POPOVER (widget);
- GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover);
-
- if (!priv->visible)
- return FALSE;
-
- if (!GTK_WIDGET_CLASS (gtk_popover_parent_class)->focus (widget, direction))
- {
- GtkWidget *focus;
-
- focus = gtk_window_get_focus (priv->window);
- focus = gtk_widget_get_parent (focus);
-
- /* Unset focus child through children, so it is next stepped from
- * scratch.
- */
- while (focus && focus != widget)
- {
- gtk_widget_set_focus_child (focus, NULL);
- focus = gtk_widget_get_parent (focus);
- }
-
- return gtk_widget_child_focus (gtk_bin_get_child (GTK_BIN (widget)),
- direction);
- }
-
- return TRUE;
-}
-
static void
gtk_popover_show (GtkWidget *widget)
{
@@ -1582,7 +1549,6 @@ gtk_popover_class_init (GtkPopoverClass *klass)
widget_class->size_allocate = gtk_popover_size_allocate;
widget_class->snapshot = gtk_popover_snapshot;
widget_class->grab_focus = gtk_popover_grab_focus;
- widget_class->focus = gtk_popover_focus;
widget_class->show = gtk_popover_show;
widget_class->hide = gtk_popover_hide;
widget_class->state_flags_changed = gtk_popover_state_flags_changed;
diff --git a/gtk/gtkradiobutton.c b/gtk/gtkradiobutton.c
index e87c0d7d49..64bda0def9 100644
--- a/gtk/gtkradiobutton.c
+++ b/gtk/gtkradiobutton.c
@@ -149,8 +149,6 @@ static GParamSpec *radio_button_props[LAST_PROP] = { NULL, };
static guint signals[N_SIGNALS] = { 0 };
static void gtk_radio_button_destroy (GtkWidget *widget);
-static gboolean gtk_radio_button_focus (GtkWidget *widget,
- GtkDirectionType direction);
static void gtk_radio_button_clicked (GtkButton *button);
static void gtk_radio_button_set_property (GObject *object,
guint prop_id,
@@ -192,7 +190,6 @@ gtk_radio_button_class_init (GtkRadioButtonClass *class)
g_object_class_install_properties (gobject_class, LAST_PROP, radio_button_props);
widget_class->destroy = gtk_radio_button_destroy;
- widget_class->focus = gtk_radio_button_focus;
button_class->clicked = gtk_radio_button_clicked;
@@ -615,99 +612,6 @@ gtk_radio_button_destroy (GtkWidget *widget)
GTK_WIDGET_CLASS (gtk_radio_button_parent_class)->destroy (widget);
}
-static gboolean
-gtk_radio_button_focus (GtkWidget *widget,
- GtkDirectionType direction)
-{
- GtkRadioButton *radio_button = GTK_RADIO_BUTTON (widget);
- GtkRadioButtonPrivate *priv = gtk_radio_button_get_instance_private (radio_button);
- GSList *tmp_slist;
-
- /* Radio buttons with draw_indicator unset focus "normally", since
- * they look like buttons to the user.
- */
- if (!gtk_check_button_get_draw_indicator (GTK_CHECK_BUTTON (widget)))
- return GTK_WIDGET_CLASS (gtk_radio_button_parent_class)->focus (widget, direction);
-
- if (gtk_widget_is_focus (widget))
- {
- GPtrArray *child_array;
- GtkWidget *new_focus = NULL;
- GSList *l;
- guint index;
- gboolean found;
- guint i;
-
- if (direction == GTK_DIR_TAB_FORWARD ||
- direction == GTK_DIR_TAB_BACKWARD)
- return FALSE;
-
- child_array = g_ptr_array_sized_new (g_slist_length (priv->group));
- for (l = priv->group; l; l = l->next)
- g_ptr_array_add (child_array, l->data);
-
- gtk_widget_focus_sort (widget, direction, child_array);
- found = g_ptr_array_find (child_array, widget, &index);
-
- if (found)
- {
- /* Start at the *next* widget in the list */
- if (index < child_array->len - 1)
- index ++;
- }
- else
- {
- /* Search from the start of the list */
- index = 0;
- }
-
- for (i = index; i < child_array->len; i ++)
- {
- GtkWidget *child = g_ptr_array_index (child_array, i);
-
- if (gtk_widget_get_mapped (child) && gtk_widget_is_sensitive (child))
- {
- new_focus = child;
- break;
- }
- }
-
-
- if (new_focus)
- {
- gtk_widget_grab_focus (new_focus);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (new_focus), TRUE);
- }
-
- g_ptr_array_free (child_array, TRUE);
-
- return TRUE;
- }
- else
- {
- GtkRadioButton *selected_button = NULL;
-
- /* We accept the focus if, we don't have the focus and
- * - we are the currently active button in the group
- * - there is no currently active radio button.
- */
- tmp_slist = priv->group;
- while (tmp_slist)
- {
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tmp_slist->data)) &&
- gtk_widget_get_visible (tmp_slist->data))
- selected_button = tmp_slist->data;
- tmp_slist = tmp_slist->next;
- }
-
- if (selected_button && selected_button != radio_button)
- return FALSE;
-
- gtk_widget_grab_focus (widget);
- return TRUE;
- }
-}
-
static void
gtk_radio_button_clicked (GtkButton *button)
{
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index ea1b402c4b..b6cc8c3179 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -322,8 +322,6 @@ static void gtk_scrolled_window_size_allocate (GtkWidget *widge
int width,
int height,
int baseline);
-static gboolean gtk_scrolled_window_focus (GtkWidget *widget,
- GtkDirectionType direction);
static void gtk_scrolled_window_add (GtkContainer *container,
GtkWidget *widget);
static void gtk_scrolled_window_remove (GtkContainer *container,
@@ -507,7 +505,6 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class)
widget_class->destroy = gtk_scrolled_window_destroy;
widget_class->snapshot = gtk_scrolled_window_snapshot;
widget_class->size_allocate = gtk_scrolled_window_size_allocate;
- widget_class->focus = gtk_scrolled_window_focus;
widget_class->measure = gtk_scrolled_window_measure;
widget_class->map = gtk_scrolled_window_map;
widget_class->unmap = gtk_scrolled_window_unmap;
@@ -3330,45 +3327,6 @@ gtk_scrolled_window_start_deceleration (GtkScrolledWindow *scrolled_window)
(GDestroyNotify) kinetic_scroll_data_free);
}
-static gboolean
-gtk_scrolled_window_focus (GtkWidget *widget,
- GtkDirectionType direction)
-{
- GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (widget);
- GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
- GtkWidget *child;
- gboolean had_focus_child;
-
- had_focus_child = gtk_widget_get_focus_child (widget) != NULL;
-
- if (priv->focus_out)
- {
- priv->focus_out = FALSE; /* Clear this to catch the wrap-around case */
- return FALSE;
- }
-
- if (gtk_widget_is_focus (widget))
- return FALSE;
-
- /* We only put the scrolled window itself in the focus chain if it
- * isn't possible to focus any children.
- */
- child = gtk_bin_get_child (GTK_BIN (widget));
- if (child)
- {
- if (gtk_widget_child_focus (child, direction))
- return TRUE;
- }
-
- if (!had_focus_child && gtk_widget_get_can_focus (widget))
- {
- gtk_widget_grab_focus (widget);
- return TRUE;
- }
- else
- return FALSE;
-}
-
static void
gtk_scrolled_window_adjustment_changed (GtkAdjustment *adjustment,
gpointer data)
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 6da0b597e9..040e122f57 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -407,8 +407,6 @@ static void gtk_text_view_motion (GtkEventController *controller,
gpointer user_data);
static void gtk_text_view_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot);
-static gboolean gtk_text_view_focus (GtkWidget *widget,
- GtkDirectionType direction);
static void gtk_text_view_select_all (GtkWidget *widget,
gboolean select);
static gboolean get_middle_click_paste (GtkTextView *text_view);
@@ -694,7 +692,6 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
widget_class->measure = gtk_text_view_measure;
widget_class->size_allocate = gtk_text_view_size_allocate;
widget_class->snapshot = gtk_text_view_snapshot;
- widget_class->focus = gtk_text_view_focus;
widget_class->drag_begin = gtk_text_view_drag_begin;
widget_class->drag_end = gtk_text_view_drag_end;
widget_class->drag_data_get = gtk_text_view_drag_data_get;
@@ -5447,39 +5444,6 @@ gtk_text_view_snapshot (GtkWidget *widget,
}
}
-static gboolean
-gtk_text_view_focus (GtkWidget *widget,
- GtkDirectionType direction)
-{
- gboolean result;
-
- if (!gtk_widget_is_focus (widget) &&
- gtk_widget_get_focus_child (widget) == NULL)
- {
- if (gtk_widget_get_can_focus (widget))
- {
- gtk_widget_grab_focus (widget);
- return TRUE;
- }
-
- return FALSE;
- }
- else
- {
- gboolean can_focus;
- /*
- * Unset CAN_FOCUS flag so that gtk_container_focus() allows
- * children to get the focus
- */
- can_focus = gtk_widget_get_can_focus (widget);
- gtk_widget_set_can_focus (widget, FALSE);
- result = GTK_WIDGET_CLASS (gtk_text_view_parent_class)->focus (widget, direction);
- gtk_widget_set_can_focus (widget, can_focus);
-
- return result;
- }
-}
-
/*
* Container
*/
diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c
index 6c455cb3d4..f7c41b8703 100644
--- a/gtk/gtktoolbar.c
+++ b/gtk/gtktoolbar.c
@@ -189,8 +189,6 @@ static void gtk_toolbar_size_allocate (GtkWidget *widget,
int height,
int baseline);
static void gtk_toolbar_style_updated (GtkWidget *widget);
-static gboolean gtk_toolbar_focus (GtkWidget *widget,
- GtkDirectionType dir);
static void gtk_toolbar_move_focus (GtkWidget *widget,
GtkDirectionType dir);
static void gtk_toolbar_display_changed (GtkWidget *widget,
@@ -368,7 +366,6 @@ gtk_toolbar_class_init (GtkToolbarClass *klass)
widget_class->measure = gtk_toolbar_measure;
widget_class->size_allocate = gtk_toolbar_size_allocate;
widget_class->style_updated = gtk_toolbar_style_updated;
- widget_class->focus = gtk_toolbar_focus;
gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_TOOL_BAR);
@@ -1611,43 +1608,6 @@ gtk_toolbar_move_focus (GtkWidget *widget,
g_list_free (children);
}
-/* The focus handler for the toolbar. It called when the user presses
- * TAB or otherwise tries to focus the toolbar.
- */
-static gboolean
-gtk_toolbar_focus (GtkWidget *widget,
- GtkDirectionType dir)
-{
- GtkToolbar *toolbar = GTK_TOOLBAR (widget);
- GList *children, *list;
- gboolean result = FALSE;
-
- /* if focus is already somewhere inside the toolbar then return FALSE.
- * The only way focus can stay inside the toolbar is when the user presses
- * arrow keys or Ctrl TAB (both of which are handled by the
- * gtk_toolbar_move_focus() keybinding function.
- */
- if (gtk_widget_get_focus_child (widget))
- return FALSE;
-
- children = gtk_toolbar_list_children_in_focus_order (toolbar, dir);
-
- for (list = children; list != NULL; list = list->next)
- {
- GtkWidget *child = list->data;
-
- if (gtk_widget_get_mapped (child) && gtk_widget_child_focus (child, dir))
- {
- result = TRUE;
- break;
- }
- }
-
- g_list_free (children);
-
- return result;
-}
-
static GtkSettings *
toolbar_get_settings (GtkToolbar *toolbar)
{
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index e8191a9fef..4b1bafbc50 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -616,8 +616,6 @@ static void gtk_tree_view_key_controller_key_released (GtkEventControllerKey
static void gtk_tree_view_key_controller_focus_out (GtkEventControllerKey *key,
GtkTreeView *tree_view);
-static gint gtk_tree_view_focus (GtkWidget *widget,
- GtkDirectionType direction);
static void gtk_tree_view_grab_focus (GtkWidget *widget);
static void gtk_tree_view_style_updated (GtkWidget *widget);
@@ -985,7 +983,6 @@ gtk_tree_view_class_init (GtkTreeViewClass *class)
widget_class->drag_motion = gtk_tree_view_drag_motion;
widget_class->drag_drop = gtk_tree_view_drag_drop;
widget_class->drag_data_received = gtk_tree_view_drag_data_received;
- widget_class->focus = gtk_tree_view_focus;
widget_class->grab_focus = gtk_tree_view_grab_focus;
widget_class->style_updated = gtk_tree_view_style_updated;
@@ -7707,170 +7704,6 @@ gtk_tree_view_get_fixed_height_mode (GtkTreeView *tree_view)
return tree_view->priv->fixed_height_mode;
}
-/* Returns TRUE if the focus is within the headers, after the focus operation is
- * done
- */
-static gboolean
-gtk_tree_view_header_focus (GtkTreeView *tree_view,
- GtkDirectionType dir,
- gboolean clamp_column_visible)
-{
- GtkTreeViewColumn *column;
- GtkWidget *button;
- GtkWidget *focus_child;
- GList *last_column, *first_column;
- GList *tmp_list;
- gboolean rtl;
-
- if (! tree_view->priv->headers_visible)
- return FALSE;
-
- focus_child = gtk_widget_get_focus_child (GTK_WIDGET (tree_view));
-
- first_column = tree_view->priv->columns;
- while (first_column)
- {
- column = GTK_TREE_VIEW_COLUMN (first_column->data);
- button = gtk_tree_view_column_get_button (column);
-
- if (gtk_widget_get_can_focus (button) &&
- gtk_tree_view_column_get_visible (column) &&
- (gtk_tree_view_column_get_clickable (column) ||
- gtk_tree_view_column_get_reorderable (column)))
- break;
- first_column = first_column->next;
- }
-
- /* No headers are visible, or are focusable. We can't focus in or out.
- */
- if (first_column == NULL)
- return FALSE;
-
- last_column = g_list_last (tree_view->priv->columns);
- while (last_column)
- {
- column = GTK_TREE_VIEW_COLUMN (last_column->data);
- button = gtk_tree_view_column_get_button (column);
-
- if (gtk_widget_get_can_focus (button) &&
- gtk_tree_view_column_get_visible (column) &&
- (gtk_tree_view_column_get_clickable (column) ||
- gtk_tree_view_column_get_reorderable (column)))
- break;
- last_column = last_column->prev;
- }
-
-
- rtl = (gtk_widget_get_direction (GTK_WIDGET (tree_view)) == GTK_TEXT_DIR_RTL);
-
- switch (dir)
- {
- case GTK_DIR_TAB_BACKWARD:
- case GTK_DIR_TAB_FORWARD:
- case GTK_DIR_UP:
- case GTK_DIR_DOWN:
- if (focus_child == NULL)
- {
- if (tree_view->priv->focus_column != NULL)
- button = gtk_tree_view_column_get_button (tree_view->priv->focus_column);
- else
- button = NULL;
-
- if (button && gtk_widget_get_can_focus (button))
- focus_child = button;
- else
- focus_child = gtk_tree_view_column_get_button (GTK_TREE_VIEW_COLUMN (first_column->data));
-
- gtk_widget_grab_focus (focus_child);
- break;
- }
- return FALSE;
-
- case GTK_DIR_LEFT:
- case GTK_DIR_RIGHT:
- if (focus_child == NULL)
- {
- if (tree_view->priv->focus_column != NULL)
- focus_child = gtk_tree_view_column_get_button (tree_view->priv->focus_column);
- else if (dir == GTK_DIR_LEFT)
- focus_child = gtk_tree_view_column_get_button (GTK_TREE_VIEW_COLUMN (last_column->data));
- else
- focus_child = gtk_tree_view_column_get_button (GTK_TREE_VIEW_COLUMN (first_column->data));
-
- gtk_widget_grab_focus (focus_child);
- break;
- }
-
- if (gtk_widget_child_focus (focus_child, dir))
- {
- /* The focus moves inside the button. */
- /* This is probably a great example of bad UI */
- break;
- }
-
- /* We need to move the focus among the row of buttons. */
- for (tmp_list = tree_view->priv->columns; tmp_list; tmp_list = tmp_list->next)
- if (gtk_tree_view_column_get_button (GTK_TREE_VIEW_COLUMN (tmp_list->data)) == focus_child)
- break;
-
- if ((tmp_list == first_column && dir == (rtl ? GTK_DIR_RIGHT : GTK_DIR_LEFT))
- || (tmp_list == last_column && dir == (rtl ? GTK_DIR_LEFT : GTK_DIR_RIGHT)))
- {
- gtk_widget_error_bell (GTK_WIDGET (tree_view));
- break;
- }
-
- while (tmp_list)
- {
- if (dir == (rtl ? GTK_DIR_LEFT : GTK_DIR_RIGHT))
- tmp_list = tmp_list->next;
- else
- tmp_list = tmp_list->prev;
-
- if (tmp_list == NULL)
- {
- g_warning ("Internal button not found");
- break;
- }
- column = tmp_list->data;
- button = gtk_tree_view_column_get_button (column);
- if (button &&
- gtk_tree_view_column_get_visible (column) &&
- gtk_widget_get_can_focus (button))
- {
- focus_child = button;
- gtk_widget_grab_focus (button);
- break;
- }
- }
- break;
- default:
- g_assert_not_reached ();
- break;
- }
-
- /* if focus child is non-null, we assume it's been set to the current focus child
- */
- if (focus_child)
- {
- for (tmp_list = tree_view->priv->columns; tmp_list; tmp_list = tmp_list->next)
- if (gtk_tree_view_column_get_button (GTK_TREE_VIEW_COLUMN (tmp_list->data)) == focus_child)
- {
- _gtk_tree_view_set_focus_column (tree_view, GTK_TREE_VIEW_COLUMN (tmp_list->data));
- break;
- }
-
- if (clamp_column_visible)
- {
- gtk_tree_view_clamp_column_visible (tree_view,
- tree_view->priv->focus_column,
- FALSE);
- }
- }
-
- return (focus_child != NULL);
-}
-
/* This function returns in 'path' the first focusable path, if the given path
* is already focusable, it’s the returned one.
*/
@@ -7917,59 +7750,6 @@ search_first_focusable_path (GtkTreeView *tree_view,
return (*path != NULL);
}
-static gint
-gtk_tree_view_focus (GtkWidget *widget,
- GtkDirectionType direction)
-{
- GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
- GtkWidget *focus_child;
-
- if (!gtk_widget_is_sensitive (widget) || !gtk_widget_get_can_focus (widget))
- return FALSE;
-
- focus_child = gtk_widget_get_focus_child (widget);
-
- gtk_tree_view_stop_editing (GTK_TREE_VIEW (widget), FALSE);
- /* Case 1. Headers currently have focus. */
- if (focus_child)
- {
- switch (direction)
- {
- case GTK_DIR_LEFT:
- case GTK_DIR_RIGHT:
- gtk_tree_view_header_focus (tree_view, direction, TRUE);
- return TRUE;
- case GTK_DIR_TAB_BACKWARD:
- case GTK_DIR_UP:
- return FALSE;
- case GTK_DIR_TAB_FORWARD:
- case GTK_DIR_DOWN:
- gtk_widget_grab_focus (widget);
- return TRUE;
- default:
- g_assert_not_reached ();
- return FALSE;
- }
- }
-
- /* Case 2. We don't have focus at all. */
- if (!gtk_widget_has_focus (widget))
- {
- gtk_widget_grab_focus (widget);
- return TRUE;
- }
-
- /* Case 3. We have focus already. */
- if (direction == GTK_DIR_TAB_BACKWARD)
- return (gtk_tree_view_header_focus (tree_view, direction, FALSE));
- else if (direction == GTK_DIR_TAB_FORWARD)
- return FALSE;
-
- /* Other directions caught by the keybindings */
- gtk_widget_grab_focus (widget);
- return TRUE;
-}
-
static void
gtk_tree_view_grab_focus (GtkWidget *widget)
{
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 62df5b5017..bb255b00dd 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -599,8 +599,6 @@ static void gtk_widget_real_style_updated (GtkWidget *widget);
static void gtk_widget_dispatch_child_properties_changed (GtkWidget *object,
guint n_pspecs,
GParamSpec **pspecs);
-static gboolean gtk_widget_real_focus (GtkWidget *widget,
- GtkDirectionType direction);
static void gtk_widget_real_move_focus (GtkWidget *widget,
GtkDirectionType direction);
static gboolean gtk_widget_real_keynav_failed (GtkWidget *widget,
@@ -930,7 +928,6 @@ gtk_widget_class_init (GtkWidgetClass *klass)
klass->snapshot = gtk_widget_real_snapshot;
klass->mnemonic_activate = gtk_widget_real_mnemonic_activate;
klass->grab_focus = gtk_widget_real_grab_focus;
- klass->focus = gtk_widget_real_focus;
klass->next_focus_child = gtk_widget_next_focus_child;
klass->move_focus = gtk_widget_real_move_focus;
klass->keynav_failed = gtk_widget_real_keynav_failed;
@@ -5411,48 +5408,11 @@ gtk_widget_real_style_updated (GtkWidget *widget)
}
}
-static gboolean
-gtk_widget_real_focus (GtkWidget *widget,
- GtkDirectionType direction)
-{
- if (gtk_widget_get_can_focus (widget))
- {
- if (!gtk_widget_is_focus (widget))
- {
- gtk_widget_grab_focus (widget);
- return TRUE;
- }
- }
- else if (_gtk_widget_get_first_child (widget) == NULL)
- {
- /* No children, no possibility to focus anything */
- return FALSE;
- }
- else
- {
- /* Try focusing any of the child widgets, depending on the given direction */
- GtkWidget *focus_child = gtk_widget_get_focus_child (widget);
- GtkWidget *next_focus;
-
- if (focus_child)
- next_focus = gtk_widget_get_next_focus (focus_child, direction);
- else
- next_focus = gtk_widget_get_next_focus (widget, direction);
-
- if (next_focus && gtk_widget_is_ancestor (next_focus, widget))
- {
- gtk_widget_grab_focus (next_focus);
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
static void
gtk_widget_real_move_focus (GtkWidget *widget,
GtkDirectionType direction)
{
+ GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GtkWidget *focus_child;
GtkWidget *next_focus;
@@ -5463,7 +5423,7 @@ gtk_widget_real_move_focus (GtkWidget *widget,
next_focus = gtk_widget_get_next_focus (widget, direction);
if (next_focus)
- gtk_widget_grab_focus (next_focus);
+ gtk_root_set_focus (priv->root, next_focus);
}
static gboolean
@@ -7478,6 +7438,7 @@ gboolean
gtk_widget_child_focus (GtkWidget *widget,
GtkDirectionType direction)
{
+ GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GtkWidget *focus_child;
GtkWidget *next_focus;
@@ -7490,7 +7451,7 @@ gtk_widget_child_focus (GtkWidget *widget,
next_focus = gtk_widget_get_next_focus (widget, direction);
if (next_focus && gtk_widget_is_ancestor (next_focus, widget))
{
- gtk_widget_grab_focus (next_focus);
+ gtk_root_set_focus (priv->root, next_focus);
return TRUE;
}
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index bf319603ae..38d33893cd 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -185,7 +185,7 @@ struct _GtkWidget
* %FALSE, and just grabs the focus if @group_cycling is %TRUE.
* @grab_focus: Causes @widget to have the keyboard focus for the
* #GtkWindow it’s inside.
- * @focus:
+ * @next_focus_child: Returns the next child that is a candidate for receiving focus
* @move_focus: Signal emitted when a change of focus is requested
* @keynav_failed: Signal emitted if keyboard navigation fails.
* @drag_begin: Signal emitted on the drag source when a drag is
@@ -278,8 +278,6 @@ struct _GtkWidgetClass
/* explicit focus */
void (* grab_focus) (GtkWidget *widget);
- gboolean (* focus) (GtkWidget *widget,
- GtkDirectionType direction);
GtkWidget * (* next_focus_child) (GtkWidget *widget,
GtkWidget *child,
GtkDirectionType direction);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]