Merge branch 'focusable-property' into 'master'

Focusable property

See merge request GNOME/gtk!1834
This commit is contained in:
Matthias Clasen 2020-05-11 11:23:15 +00:00
commit bb8fa045c2
60 changed files with 162 additions and 158 deletions

View File

@ -4050,6 +4050,8 @@ GtkPickFlags
gtk_widget_pick
gtk_widget_get_can_focus
gtk_widget_set_can_focus
gtk_widget_get_focusable
gtk_widget_set_focusable
gtk_widget_get_focus_on_click
gtk_widget_set_focus_on_click
gtk_widget_set_focus_child

View File

@ -128,9 +128,6 @@ gtk_accel_label_class_init (GtkAccelLabelClass *class)
gobject_class->set_property = gtk_accel_label_set_property;
gobject_class->get_property = gtk_accel_label_get_property;
widget_class->focus = gtk_widget_focus_none;
widget_class->grab_focus = gtk_widget_grab_focus_none;
gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_ACCEL_LABEL);
props[PROP_LABEL] =

View File

@ -894,8 +894,6 @@ gtk_app_chooser_widget_class_init (GtkAppChooserWidgetClass *klass)
widget_class->measure = gtk_app_chooser_widget_measure;
widget_class->size_allocate = gtk_app_chooser_widget_size_allocate;
widget_class->snapshot = gtk_app_chooser_widget_snapshot;
widget_class->grab_focus = gtk_widget_grab_focus_child;
widget_class->focus = gtk_widget_focus_child;
g_object_class_override_property (gobject_class, PROP_CONTENT_TYPE, "content-type");

View File

@ -130,8 +130,6 @@ gtk_aspect_frame_class_init (GtkAspectFrameClass *class)
widget_class->size_allocate = gtk_aspect_frame_size_allocate;
widget_class->compute_expand = gtk_aspect_frame_compute_expand;
widget_class->get_request_mode = gtk_aspect_frame_get_request_mode;
widget_class->grab_focus = gtk_widget_grab_focus_none;
widget_class->focus = gtk_widget_focus_child;
g_object_class_install_property (gobject_class,
PROP_XALIGN,

View File

@ -95,8 +95,6 @@ gtk_builtin_icon_class_init (GtkBuiltinIconClass *klass)
wclass->snapshot = gtk_builtin_icon_snapshot;
wclass->measure = gtk_builtin_icon_measure;
wclass->css_changed = gtk_builtin_icon_css_changed;
wclass->grab_focus = gtk_widget_grab_focus_none;
wclass->focus = gtk_widget_focus_none;
}
static void

View File

@ -214,8 +214,6 @@ gtk_button_class_init (GtkButtonClass *klass)
widget_class->state_flags_changed = gtk_button_state_flags_changed;
widget_class->grab_notify = gtk_button_grab_notify;
widget_class->unmap = gtk_button_unmap;
widget_class->grab_focus = gtk_widget_grab_focus_self;
widget_class->focus = gtk_widget_focus_self;
widget_class->compute_expand = gtk_button_compute_expand;
widget_class->get_request_mode = gtk_button_get_request_mode;
@ -421,6 +419,7 @@ gtk_button_init (GtkButton *button)
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
GtkEventController *key_controller;
gtk_widget_set_focusable (GTK_WIDGET (button), TRUE);
gtk_widget_set_receives_default (GTK_WIDGET (button), TRUE);
priv->in_button = FALSE;

View File

@ -361,9 +361,6 @@ gtk_calendar_class_init (GtkCalendarClass *class)
gobject_class->set_property = gtk_calendar_set_property;
gobject_class->get_property = gtk_calendar_get_property;
widget_class->focus = gtk_widget_focus_all;
widget_class->grab_focus = gtk_widget_grab_focus_self;
/**
* GtkCalendar:year:
*
@ -574,7 +571,7 @@ gtk_calendar_init (GtkCalendar *calendar)
int min_year_width;
GDateTime *now;
gtk_widget_set_can_focus (widget, TRUE);
gtk_widget_set_focusable (widget, TRUE);
gtk_widget_add_css_class (GTK_WIDGET (calendar), GTK_STYLE_CLASS_VIEW);

View File

@ -697,7 +697,7 @@ gtk_cell_editable_widget_init (GtkCellEditableWidget *box)
GtkWidget *widget = GTK_WIDGET (box);
GtkEventController *controller;
gtk_widget_set_can_focus (widget, TRUE);
gtk_widget_set_focusable (widget, TRUE);
controller = gtk_event_controller_key_new ();
g_signal_connect (controller, "key-pressed",

View File

@ -199,9 +199,6 @@ gtk_center_box_class_init (GtkCenterBoxClass *klass)
object_class->get_property = gtk_center_box_get_property;
object_class->dispose = gtk_center_box_dispose;
widget_class->grab_focus = gtk_widget_grab_focus_child;
widget_class->focus = gtk_widget_focus_child;
g_object_class_override_property (object_class, PROP_ORIENTATION, "orientation");
g_object_class_install_property (object_class, PROP_BASELINE_POSITION,

View File

@ -407,6 +407,8 @@ gtk_color_plane_init (GtkColorPlane *plane)
plane->priv = gtk_color_plane_get_instance_private (plane);
gtk_widget_set_focusable (GTK_WIDGET (plane), TRUE);
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (plane));
if (GTK_IS_ACCESSIBLE (atk_obj))
{

View File

@ -478,8 +478,6 @@ gtk_color_swatch_class_init (GtkColorSwatchClass *class)
widget_class->snapshot = swatch_snapshot;
widget_class->size_allocate = swatch_size_allocate;
widget_class->state_flags_changed = swatch_state_flags_changed;
widget_class->grab_focus = gtk_widget_grab_focus_self;
widget_class->focus = gtk_widget_focus_self;
g_object_class_install_property (object_class, PROP_RGBA,
g_param_spec_boxed ("rgba", P_("RGBA Color"), P_("Color as RGBA"),
@ -528,7 +526,7 @@ gtk_color_swatch_init (GtkColorSwatch *swatch)
swatch->color.blue = 0.25;
swatch->color.alpha = 1.0;
gtk_widget_set_can_focus (GTK_WIDGET (swatch), TRUE);
gtk_widget_set_focusable (GTK_WIDGET (swatch), TRUE);
gtk_widget_set_overflow (GTK_WIDGET (swatch), GTK_OVERFLOW_HIDDEN);
gesture = gtk_gesture_long_press_new ();

View File

@ -123,8 +123,6 @@ gtk_container_class_init (GtkContainerClass *class)
widget_class->compute_expand = gtk_container_compute_expand;
widget_class->get_request_mode = gtk_container_get_request_mode;
widget_class->grab_focus = gtk_widget_grab_focus_none;
widget_class->focus = gtk_widget_focus_child;
class->add = gtk_container_add_unimplemented;
class->remove = gtk_container_remove_unimplemented;

View File

@ -361,8 +361,6 @@ gtk_drag_icon_class_init (GtkDragIconClass *klass)
widget_class->size_allocate = gtk_drag_icon_size_allocate;
widget_class->show = gtk_drag_icon_show;
widget_class->hide = gtk_drag_icon_hide;
widget_class->focus = gtk_widget_focus_none;
widget_class->grab_focus = gtk_widget_grab_focus_none;
/**
* GtkDragIcon:child:

View File

@ -278,10 +278,8 @@ gtk_drawing_area_class_init (GtkDrawingAreaClass *class)
gobject_class->dispose = gtk_drawing_area_dispose;
widget_class->measure = gtk_drawing_area_measure;
widget_class->snapshot = gtk_drawing_area_snapshot;
widget_class->focus = gtk_widget_focus_none;
widget_class->grab_focus = gtk_widget_grab_focus_none;
widget_class->size_allocate = gtk_drawing_area_size_allocate;
widget_class->snapshot = gtk_drawing_area_snapshot;
/**
* GtkDrawingArea:content-width
@ -338,6 +336,7 @@ gtk_drawing_area_class_init (GtkDrawingAreaClass *class)
static void
gtk_drawing_area_init (GtkDrawingArea *darea)
{
gtk_widget_set_focusable (GTK_WIDGET (darea), FALSE);
}
/**

View File

@ -439,7 +439,7 @@ gtk_entry_class_init (GtkEntryClass *class)
widget_class->grab_focus = gtk_entry_grab_focus;
widget_class->focus = gtk_widget_focus_child;
widget_class->mnemonic_activate = gtk_entry_mnemonic_activate;
quark_entry_completion = g_quark_from_static_string ("gtk-entry-completion-key");
entry_props[PROP_BUFFER] =

View File

@ -383,6 +383,8 @@ gtk_expander_init (GtkExpander *expander)
expander->expand_timer = 0;
expander->resize_toplevel = 0;
gtk_widget_set_focusable (GTK_WIDGET (expander), TRUE);
expander->box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_set_parent (expander->box, GTK_WIDGET (expander));

View File

@ -504,7 +504,6 @@ gtk_flow_box_child_class_init (GtkFlowBoxChildClass *class)
widget_class->get_request_mode = gtk_flow_box_child_get_request_mode;
widget_class->compute_expand = gtk_flow_box_child_compute_expand;
widget_class->focus = gtk_flow_box_child_focus;
widget_class->grab_focus = gtk_widget_grab_focus_none;
class->activate = gtk_flow_box_child_activate;

View File

@ -720,8 +720,6 @@ gtk_font_chooser_widget_class_init (GtkFontChooserWidgetClass *klass)
widget_class->unroot = gtk_font_chooser_widget_unroot;
widget_class->map = gtk_font_chooser_widget_map;
widget_class->unmap = gtk_font_chooser_widget_unmap;
widget_class->focus = gtk_widget_focus_child;
widget_class->grab_focus = gtk_widget_grab_focus_child;
gobject_class->finalize = gtk_font_chooser_widget_finalize;
gobject_class->dispose = gtk_font_chooser_widget_dispose;

View File

@ -160,8 +160,6 @@ gtk_frame_class_init (GtkFrameClass *class)
widget_class->measure = gtk_frame_measure;
widget_class->compute_expand = gtk_frame_compute_expand;
widget_class->get_request_mode = gtk_frame_get_request_mode;
widget_class->grab_focus = gtk_widget_grab_focus_none;
widget_class->focus = gtk_widget_focus_child;
class->compute_child_allocation = gtk_frame_real_compute_child_allocation;

View File

@ -783,8 +783,6 @@ gtk_gl_area_class_init (GtkGLAreaClass *klass)
widget_class->unrealize = gtk_gl_area_unrealize;
widget_class->size_allocate = gtk_gl_area_size_allocate;
widget_class->snapshot = gtk_gl_area_snapshot;
widget_class->focus = gtk_widget_focus_none;
widget_class->grab_focus = gtk_widget_grab_focus_none;
gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_DRAWING_AREA);

View File

@ -950,6 +950,7 @@ gtk_icon_view_init (GtkIconView *icon_view)
icon_view->priv->mouse_y = -1;
gtk_widget_set_overflow (GTK_WIDGET (icon_view), GTK_OVERFLOW_HIDDEN);
gtk_widget_set_focusable (GTK_WIDGET (icon_view), TRUE);
icon_view->priv->item_orientation = GTK_ORIENTATION_VERTICAL;

View File

@ -160,8 +160,6 @@ gtk_image_class_init (GtkImageClass *class)
widget_class->unrealize = gtk_image_unrealize;
widget_class->css_changed = gtk_image_css_changed;
widget_class->system_setting_changed = gtk_image_system_setting_changed;
widget_class->grab_focus = gtk_widget_grab_focus_none;
widget_class->focus = gtk_widget_focus_none;
image_props[PROP_PAINTABLE] =
g_param_spec_object ("paintable",

View File

@ -4417,7 +4417,7 @@ gtk_label_ensure_select_info (GtkLabel *self)
{
self->select_info = g_new0 (GtkLabelSelectionInfo, 1);
gtk_widget_set_can_focus (GTK_WIDGET (self), TRUE);
gtk_widget_set_focusable (GTK_WIDGET (self), TRUE);
self->select_info->drag_gesture = gtk_gesture_drag_new ();
g_signal_connect (self->select_info->drag_gesture, "drag-begin",
@ -4469,7 +4469,7 @@ gtk_label_clear_select_info (GtkLabel *self)
gtk_widget_set_cursor (GTK_WIDGET (self), NULL);
gtk_widget_set_can_focus (GTK_WIDGET (self), FALSE);
gtk_widget_set_focusable (GTK_WIDGET (self), FALSE);
}
}

View File

@ -901,8 +901,6 @@ gtk_level_bar_class_init (GtkLevelBarClass *klass)
oclass->finalize = gtk_level_bar_finalize;
wclass->direction_changed = gtk_level_bar_direction_changed;
wclass->grab_focus = gtk_widget_grab_focus_none;
wclass->focus = gtk_widget_focus_none;
g_object_class_override_property (oclass, PROP_ORIENTATION, "orientation");

View File

@ -689,6 +689,8 @@ gtk_list_box_init (GtkListBox *box)
GtkWidget *widget = GTK_WIDGET (box);
GtkGesture *gesture;
gtk_widget_set_focusable (GTK_WIDGET (box), TRUE);
box->selection_mode = GTK_SELECTION_SINGLE;
box->activate_single_click = TRUE;
@ -3482,6 +3484,7 @@ gtk_list_box_row_init (GtkListBoxRow *row)
ROW_PRIV (row)->activatable = TRUE;
ROW_PRIV (row)->selectable = TRUE;
gtk_widget_set_focusable (GTK_WIDGET (row), TRUE);
gtk_widget_add_css_class (GTK_WIDGET (row), "activatable");
}

View File

@ -260,8 +260,6 @@ gtk_media_controls_class_init (GtkMediaControlsClass *klass)
widget_class->measure = gtk_media_controls_measure;
widget_class->size_allocate = gtk_media_controls_size_allocate;
widget_class->grab_focus = gtk_widget_grab_focus_none;
widget_class->focus = gtk_widget_focus_child;
gobject_class->dispose = gtk_media_controls_dispose;
gobject_class->get_property = gtk_media_controls_get_property;

View File

@ -1380,7 +1380,7 @@ gtk_model_button_init (GtkModelButton *self)
GtkEventController *controller;
GtkGesture *gesture;
gtk_widget_set_can_focus (GTK_WIDGET (self), TRUE);
gtk_widget_set_focusable (GTK_WIDGET (self), TRUE);
self->role = GTK_BUTTON_ROLE_NORMAL;
self->label = gtk_label_new ("");

View File

@ -1414,6 +1414,8 @@ gtk_notebook_init (GtkNotebook *notebook)
notebook->detached_tab = NULL;
notebook->has_scrolled = FALSE;
gtk_widget_set_focusable (GTK_WIDGET (notebook), TRUE);
notebook->header_widget = g_object_new (GTK_TYPE_BOX,
"css-name", "header",
NULL);

View File

@ -310,8 +310,6 @@ gtk_overlay_class_init (GtkOverlayClass *klass)
widget_class->snapshot = gtk_overlay_snapshot;
widget_class->compute_expand = gtk_overlay_compute_expand;
widget_class->grab_focus = gtk_widget_grab_focus_none;
widget_class->focus = gtk_widget_focus_child;
klass->get_child_position = gtk_overlay_get_child_position;

View File

@ -1347,7 +1347,7 @@ gtk_paned_init (GtkPaned *paned)
GtkPanedPrivate *priv = gtk_paned_get_instance_private (paned);
GtkGesture *gesture;
gtk_widget_set_can_focus (GTK_WIDGET (paned), TRUE);
gtk_widget_set_focusable (GTK_WIDGET (paned), TRUE);
gtk_widget_set_overflow (GTK_WIDGET (paned), GTK_OVERFLOW_HIDDEN);
priv->orientation = GTK_ORIENTATION_HORIZONTAL;

View File

@ -375,9 +375,8 @@ gtk_password_entry_class_init (GtkPasswordEntryClass *klass)
widget_class->measure = gtk_password_entry_measure;
widget_class->size_allocate = gtk_password_entry_size_allocate;
widget_class->get_accessible = gtk_password_entry_get_accessible;
widget_class->grab_focus = gtk_widget_grab_focus_child;
widget_class->focus = gtk_widget_focus_child;
widget_class->mnemonic_activate = gtk_password_entry_mnemonic_activate;
widget_class->grab_focus = gtk_widget_grab_focus_child;
props[PROP_PLACEHOLDER_TEXT] =
g_param_spec_string ("placeholder-text",

View File

@ -301,8 +301,6 @@ gtk_picture_class_init (GtkPictureClass *class)
widget_class->snapshot = gtk_picture_snapshot;
widget_class->get_request_mode = gtk_picture_get_request_mode;
widget_class->measure = gtk_picture_measure;
widget_class->grab_focus = gtk_widget_grab_focus_none;
widget_class->focus = gtk_widget_focus_none;
/**
* GtkPicture:paintable:

View File

@ -1680,8 +1680,6 @@ gtk_popover_class_init (GtkPopoverClass *klass)
widget_class->snapshot = gtk_popover_snapshot;
widget_class->compute_expand = gtk_popover_compute_expand;
widget_class->get_request_mode = gtk_popover_get_request_mode;
widget_class->grab_focus = gtk_widget_grab_focus_none;
widget_class->focus = gtk_widget_focus_child;
klass->activate_default = gtk_popover_activate_default;

View File

@ -244,7 +244,7 @@ gtk_popover_menu_bar_item_init (GtkPopoverMenuBarItem *item)
{
GtkEventController *controller;
gtk_widget_set_can_focus (GTK_WIDGET (item), TRUE);
gtk_widget_set_focusable (GTK_WIDGET (item), TRUE);
item->label = g_object_new (GTK_TYPE_LABEL,
"use-underline", TRUE,

View File

@ -176,8 +176,6 @@ gtk_progress_bar_class_init (GtkProgressBarClass *class)
gobject_class->finalize = gtk_progress_bar_finalize;
widget_class->direction_changed = gtk_progress_bar_direction_changed;
widget_class->grab_focus = gtk_widget_grab_focus_none;
widget_class->focus = gtk_widget_focus_none;
g_object_class_override_property (gobject_class, PROP_ORIENTATION, "orientation");

View File

@ -319,8 +319,6 @@ gtk_revealer_class_init (GtkRevealerClass *klass)
widget_class->measure = gtk_revealer_measure;
widget_class->compute_expand = gtk_revealer_compute_expand;
widget_class->get_request_mode = gtk_revealer_get_request_mode;
widget_class->grab_focus = gtk_widget_grab_focus_none;
widget_class->focus = gtk_widget_focus_child;
props[PROP_TRANSITION_TYPE] =
g_param_spec_enum ("transition-type",

View File

@ -806,8 +806,7 @@ gtk_scale_class_init (GtkScaleClass *class)
add_slider_binding (binding_set, GDK_KEY_KP_Subtract, GDK_CONTROL_MASK,
GTK_SCROLL_PAGE_BACKWARD);
add_slider_binding (binding_set, GDK_KEY_Home, 0,
GTK_SCROLL_START);
@ -830,11 +829,11 @@ gtk_scale_init (GtkScale *scale)
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
GtkRange *range = GTK_RANGE (scale);
gtk_widget_set_focusable (GTK_WIDGET (scale), TRUE);
priv->value_pos = GTK_POS_TOP;
priv->digits = 1;
gtk_widget_set_can_focus (GTK_WIDGET (scale), TRUE);
gtk_range_set_slider_size_fixed (range, TRUE);
_gtk_range_set_has_origin (range, TRUE);

View File

@ -196,9 +196,6 @@ gtk_scrollbar_class_init (GtkScrollbarClass *class)
object_class->set_property = gtk_scrollbar_set_property;
object_class->dispose = gtk_scrollbar_dispose;
widget_class->focus = gtk_widget_focus_none;
widget_class->grab_focus = gtk_widget_grab_focus_none;
props[PROP_ADJUSTMENT] =
g_param_spec_object ("adjustment",
P_("Adjustment"),

View File

@ -585,9 +585,8 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class)
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->grab_focus = gtk_widget_grab_focus_self;
widget_class->measure = gtk_scrolled_window_measure;
widget_class->focus = gtk_scrolled_window_focus;
widget_class->map = gtk_scrolled_window_map;
widget_class->unmap = gtk_scrolled_window_unmap;
widget_class->realize = gtk_scrolled_window_realize;
@ -1963,7 +1962,7 @@ gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window)
};
gint i;
gtk_widget_set_can_focus (widget, TRUE);
gtk_widget_set_focusable (widget, TRUE);
/* Instantiated by gtk_scrolled_window_set_[hv]adjustment
* which are both construct properties

View File

@ -287,8 +287,6 @@ gtk_search_bar_class_init (GtkSearchBarClass *klass)
object_class->get_property = gtk_search_bar_get_property;
widget_class->compute_expand = gtk_search_bar_compute_expand;
widget_class->grab_focus = gtk_widget_grab_focus_none;
widget_class->focus = gtk_widget_focus_child;
/**
* GtkSearchBar:search-mode-enabled:

View File

@ -132,9 +132,6 @@ gtk_separator_class_init (GtkSeparatorClass *class)
object_class->set_property = gtk_separator_set_property;
object_class->get_property = gtk_separator_get_property;
widget_class->grab_focus = gtk_widget_grab_focus_none;
widget_class->focus = gtk_widget_focus_none;
g_object_class_override_property (object_class, PROP_ORIENTATION, "orientation");
gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_SEPARATOR);

View File

@ -475,9 +475,6 @@ gtk_shortcut_label_class_init (GtkShortcutLabelClass *klass)
object_class->get_property = gtk_shortcut_label_get_property;
object_class->set_property = gtk_shortcut_label_set_property;
widget_class->grab_focus = gtk_widget_grab_focus_none;
widget_class->focus = gtk_widget_focus_none;
/**
* GtkShortcutLabel:accelerator:
*

View File

@ -548,8 +548,6 @@ gtk_shortcuts_shortcut_class_init (GtkShortcutsShortcutClass *klass)
widget_class->measure = gtk_shortcuts_shortcut_measure;
widget_class->snapshot = gtk_shortcuts_shortcut_snapshot;
widget_class->size_allocate = gtk_shortcuts_shortcut_size_allocate;
widget_class->grab_focus = gtk_widget_grab_focus_none;
widget_class->focus = gtk_widget_focus_none;
/**
* GtkShortcutsShortcut:accelerator:

View File

@ -348,9 +348,9 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class)
widget_class->realize = gtk_spin_button_realize;
widget_class->grab_notify = gtk_spin_button_grab_notify;
widget_class->state_flags_changed = gtk_spin_button_state_flags_changed;
widget_class->mnemonic_activate = gtk_spin_button_mnemonic_activate;
widget_class->grab_focus = gtk_spin_button_grab_focus;
widget_class->focus = gtk_widget_focus_child;
widget_class->mnemonic_activate = gtk_spin_button_mnemonic_activate;
class->input = NULL;
class->output = NULL;

View File

@ -229,8 +229,6 @@ gtk_spinner_class_init (GtkSpinnerClass *klass)
widget_class->snapshot = gtk_spinner_snapshot;
widget_class->measure = gtk_spinner_measure;
widget_class->css_changed = gtk_spinner_css_changed;
widget_class->grab_focus = gtk_widget_grab_focus_none;
widget_class->focus = gtk_widget_focus_none;
/* GtkSpinner:spinning:
*

View File

@ -390,9 +390,6 @@ gtk_stack_sidebar_class_init (GtkStackSidebarClass *klass)
object_class->set_property = gtk_stack_sidebar_set_property;
object_class->get_property = gtk_stack_sidebar_get_property;
widget_class->grab_focus = gtk_widget_grab_focus_none;
widget_class->focus = gtk_widget_focus_child;
obj_properties[PROP_STACK] =
g_param_spec_object (I_("stack"), P_("Stack"),
P_("Associated stack for this GtkStackSidebar"),

View File

@ -491,9 +491,6 @@ gtk_stack_switcher_class_init (GtkStackSwitcherClass *class)
object_class->dispose = gtk_stack_switcher_dispose;
object_class->finalize = gtk_stack_switcher_finalize;
widget_class->grab_focus = gtk_widget_grab_focus_none;
widget_class->focus = gtk_widget_focus_child;
g_object_class_install_property (object_class,
PROP_STACK,
g_param_spec_object ("stack",

View File

@ -156,9 +156,6 @@ gtk_statusbar_class_init (GtkStatusbarClass *class)
object_class->dispose = gtk_statusbar_dispose;
widget_class->grab_focus = gtk_widget_grab_focus_none;
widget_class->focus = gtk_widget_focus_child;
class->text_pushed = gtk_statusbar_update;
class->text_popped = gtk_statusbar_update;

View File

@ -548,9 +548,6 @@ gtk_switch_class_init (GtkSwitchClass *klass)
g_object_class_install_properties (gobject_class, LAST_PROP, switch_props);
widget_class->grab_focus = gtk_widget_grab_focus_self;
widget_class->focus = gtk_widget_focus_self;
klass->activate = gtk_switch_activate;
klass->state_set = state_set;
@ -622,7 +619,7 @@ gtk_switch_init (GtkSwitch *self)
GtkLayoutManager *layout;
GtkGesture *gesture;
gtk_widget_set_can_focus (GTK_WIDGET (self), TRUE);
gtk_widget_set_focusable (GTK_WIDGET (self), TRUE);
gesture = gtk_gesture_click_new ();
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture), FALSE);

View File

@ -1822,7 +1822,7 @@ gtk_text_init (GtkText *self)
int i;
GtkDropTarget *target;
gtk_widget_set_can_focus (GTK_WIDGET (self), TRUE);
gtk_widget_set_focusable (GTK_WIDGET (self), TRUE);
gtk_widget_set_overflow (GTK_WIDGET (self), GTK_OVERFLOW_HIDDEN);
priv->editable = TRUE;

View File

@ -821,8 +821,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->grab_focus = gtk_widget_grab_focus_self;
widget_class->focus = gtk_widget_focus_all;
container_class->add = gtk_text_view_add;
container_class->remove = gtk_text_view_remove;
@ -1858,7 +1856,7 @@ gtk_text_view_init (GtkTextView *text_view)
text_view->priv = gtk_text_view_get_instance_private (text_view);
priv = text_view->priv;
gtk_widget_set_can_focus (widget, TRUE);
gtk_widget_set_focusable (widget, TRUE);
gtk_widget_set_overflow (widget, GTK_OVERFLOW_HIDDEN);
gtk_widget_add_css_class (widget, GTK_STYLE_CLASS_VIEW);

View File

@ -1683,6 +1683,7 @@ gtk_tree_view_init (GtkTreeView *tree_view)
guint n_controllers, i;
gtk_widget_set_overflow (GTK_WIDGET (tree_view), GTK_OVERFLOW_HIDDEN);
gtk_widget_set_focusable (GTK_WIDGET (tree_view), TRUE);
tree_view->show_expanders = TRUE;
tree_view->draw_keyfocus = TRUE;
@ -2688,7 +2689,7 @@ grab_focus_and_unset_draw_keyfocus (GtkTreeView *tree_view)
{
GtkWidget *widget = GTK_WIDGET (tree_view);
if (gtk_widget_get_can_focus (widget) &&
if (gtk_widget_get_focusable (widget) &&
!gtk_widget_has_focus (widget) &&
!_gtk_widget_get_shadowed (widget))
gtk_widget_grab_focus (widget);
@ -7628,7 +7629,7 @@ gtk_tree_view_header_focus (GtkTreeView *tree_view,
column = GTK_TREE_VIEW_COLUMN (first_column->data);
button = gtk_tree_view_column_get_button (column);
if (gtk_widget_get_can_focus (button) &&
if (gtk_widget_get_focusable (button) &&
gtk_tree_view_column_get_visible (column) &&
(gtk_tree_view_column_get_clickable (column) ||
gtk_tree_view_column_get_reorderable (column)))
@ -7647,7 +7648,7 @@ gtk_tree_view_header_focus (GtkTreeView *tree_view,
column = GTK_TREE_VIEW_COLUMN (last_column->data);
button = gtk_tree_view_column_get_button (column);
if (gtk_widget_get_can_focus (button) &&
if (gtk_widget_get_focusable (button) &&
gtk_tree_view_column_get_visible (column) &&
(gtk_tree_view_column_get_clickable (column) ||
gtk_tree_view_column_get_reorderable (column)))
@ -7671,7 +7672,7 @@ gtk_tree_view_header_focus (GtkTreeView *tree_view,
else
button = NULL;
if (button && gtk_widget_get_can_focus (button))
if (button && gtk_widget_get_focusable (button))
focus_child = button;
else
focus_child = gtk_tree_view_column_get_button (GTK_TREE_VIEW_COLUMN (first_column->data));
@ -7731,7 +7732,7 @@ gtk_tree_view_header_focus (GtkTreeView *tree_view,
button = gtk_tree_view_column_get_button (column);
if (button &&
gtk_tree_view_column_get_visible (column) &&
gtk_widget_get_can_focus (button))
gtk_widget_get_focusable (button))
{
focus_child = button;
gtk_widget_grab_focus (button);

View File

@ -1019,11 +1019,11 @@ gtk_tree_view_column_update_button (GtkTreeViewColumn *tree_column)
if (priv->reorderable || priv->clickable)
{
gtk_widget_set_can_focus (priv->button, TRUE);
gtk_widget_set_focusable (priv->button, TRUE);
}
else
{
gtk_widget_set_can_focus (priv->button, FALSE);
gtk_widget_set_focusable (priv->button, FALSE);
if (gtk_widget_has_focus (priv->button))
{
GtkRoot *root = gtk_widget_get_root (priv->tree_view);

View File

@ -268,8 +268,6 @@ gtk_video_class_init (GtkVideoClass *klass)
widget_class->unrealize = gtk_video_unrealize;
widget_class->map = gtk_video_map;
widget_class->unmap = gtk_video_unmap;
widget_class->grab_focus = gtk_widget_grab_focus_none;
widget_class->focus = gtk_widget_focus_child;
widget_class->grab_notify = gtk_video_grab_notify;
gobject_class->dispose = gtk_video_dispose;
@ -342,7 +340,6 @@ static void
gtk_video_init (GtkVideo *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
}
/**

View File

@ -366,9 +366,6 @@ gtk_viewport_class_init (GtkViewportClass *class)
widget_class->unroot = gtk_viewport_unroot;
widget_class->compute_expand = gtk_viewport_compute_expand;
widget_class->get_request_mode = gtk_viewport_get_request_mode;
widget_class->grab_focus = gtk_widget_grab_focus_none;
widget_class->focus = gtk_widget_focus_child;
gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_VIEWPORT);

View File

@ -518,6 +518,7 @@ enum {
PROP_HAS_FOCUS,
PROP_CAN_TARGET,
PROP_FOCUS_ON_CLICK,
PROP_FOCUSABLE,
PROP_HAS_DEFAULT,
PROP_RECEIVES_DEFAULT,
PROP_CURSOR,
@ -572,6 +573,8 @@ static void gtk_widget_get_property (GObject *object,
static void gtk_widget_dispose (GObject *object);
static void gtk_widget_finalize (GObject *object);
static void gtk_widget_real_destroy (GtkWidget *object);
static gboolean gtk_widget_real_focus (GtkWidget *widget,
GtkDirectionType direction);
static void gtk_widget_real_show (GtkWidget *widget);
static void gtk_widget_real_hide (GtkWidget *widget);
static void gtk_widget_real_map (GtkWidget *widget);
@ -933,7 +936,7 @@ 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_grab_focus_self;
klass->focus = gtk_widget_focus_all;
klass->focus = gtk_widget_real_focus;
klass->set_focus_child = gtk_widget_real_set_focus_child;
klass->move_focus = gtk_widget_real_move_focus;
klass->keynav_failed = gtk_widget_real_keynav_failed;
@ -1018,6 +1021,18 @@ gtk_widget_class_init (GtkWidgetClass *klass)
TRUE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkWidget:focusable:
*
* Whether this widget itself will accept the input focus.
*/
widget_props[PROP_FOCUSABLE] =
g_param_spec_boolean ("focusable",
P_("Focusable"),
P_("Whether the widget can accept the input focus"),
FALSE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
widget_props[PROP_HAS_FOCUS] =
g_param_spec_boolean ("has-focus",
P_("Has focus"),
@ -1696,6 +1711,9 @@ gtk_widget_set_property (GObject *object,
case PROP_CAN_FOCUS:
gtk_widget_set_can_focus (widget, g_value_get_boolean (value));
break;
case PROP_FOCUSABLE:
gtk_widget_set_focusable (widget, g_value_get_boolean (value));
break;
case PROP_CAN_TARGET:
gtk_widget_set_can_target (widget, g_value_get_boolean (value));
break;
@ -1846,6 +1864,9 @@ gtk_widget_get_property (GObject *object,
case PROP_CAN_FOCUS:
g_value_set_boolean (value, gtk_widget_get_can_focus (widget));
break;
case PROP_FOCUSABLE:
g_value_set_boolean (value, gtk_widget_get_focusable (widget));
break;
case PROP_HAS_FOCUS:
g_value_set_boolean (value, gtk_widget_has_focus (widget));
break;
@ -2316,6 +2337,7 @@ gtk_widget_init (GTypeInstance *instance, gpointer g_class)
priv->highlight_resize = FALSE;
#endif
priv->can_focus = TRUE;
priv->focusable = FALSE;
priv->can_target = TRUE;
switch (_gtk_widget_get_direction (widget))
@ -4757,18 +4779,16 @@ gtk_widget_grab_focus (GtkWidget *widget)
return GTK_WIDGET_GET_CLASS (widget)->grab_focus (widget);
}
gboolean
gtk_widget_grab_focus_none (GtkWidget *widget)
{
return FALSE;
}
gboolean
gtk_widget_grab_focus_self (GtkWidget *widget)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
if (!priv->focusable)
return FALSE;
gtk_root_set_focus (priv->root, widget);
return TRUE;
}
@ -4919,9 +4939,9 @@ direction_is_forward (GtkDirectionType direction)
}
}
gboolean
gtk_widget_focus_all (GtkWidget *widget,
GtkDirectionType direction)
static gboolean
gtk_widget_real_focus (GtkWidget *widget,
GtkDirectionType direction)
{
GtkWidget *focus;
@ -4951,20 +4971,23 @@ gtk_widget_focus_all (GtkWidget *widget,
if (direction_is_forward (direction))
return FALSE;
else
{
gtk_widget_grab_focus (widget);
return TRUE;
}
return gtk_widget_grab_focus (widget);
}
if (!direction_is_forward (direction))
{
if (gtk_widget_focus_move (widget, direction))
return TRUE;
}
gtk_widget_grab_focus (widget);
return TRUE;
return gtk_widget_grab_focus (widget);
}
else
{
if (gtk_widget_grab_focus (widget))
return TRUE;
return gtk_widget_focus_move (widget, direction);
}
}
gboolean
@ -4986,13 +5009,6 @@ gtk_widget_focus_child (GtkWidget *widget,
return gtk_widget_focus_move (widget, direction);
}
gboolean
gtk_widget_focus_none (GtkWidget *widget,
GtkDirectionType direction)
{
return FALSE;
}
static void
gtk_widget_real_move_focus (GtkWidget *widget,
GtkDirectionType direction)
@ -5030,14 +5046,20 @@ gtk_widget_real_keynav_failed (GtkWidget *widget,
/**
* gtk_widget_set_can_focus:
* @widget: a #GtkWidget
* @can_focus: whether or not @widget can own the input focus.
* @can_focus: whether or not the input focus can enter
* the widget or any of its children
*
* Specifies whether the input focus can enter the widget
* or any of its children.
*
* Applications should set @can_focus to %FALSE to mark a
* widget as for pointer/touch use only.
*
* Specifies whether @widget can own the input focus.
*
* Note that having @can_focus be %TRUE is only one of the
* necessary conditions for being focusable. A widget must
* also be sensitive and not have an ancestor that is marked
* as not child-focusable in order to receive input focus.
* also be sensitive and focusable and not have an ancestor
* that is marked as not can-focus in order to receive input
* focus.
*
* See gtk_widget_grab_focus() for actually setting the input
* focus on a widget.
@ -5063,21 +5085,78 @@ gtk_widget_set_can_focus (GtkWidget *widget,
* gtk_widget_get_can_focus:
* @widget: a #GtkWidget
*
* Determines whether @widget can own the input focus. See
* gtk_widget_set_can_focus().
* Determines whether the input focus can enter @widget or any
* of its children.
*
* Returns: %TRUE if @widget can own the input focus, %FALSE otherwise
* See gtk_widget_set_focusable().
*
* Returns: %TRUE if the input focus can enter @widget, %FALSE otherwise
**/
gboolean
gtk_widget_get_can_focus (GtkWidget *widget)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
g_return_val_if_fail (GTK_IS_WIDGET (widget), TRUE);
return priv->can_focus;
}
/**
* gtk_widget_set_focusable:
* @widget: a #GtkWidget
* @focusable: whether or not @widget can own the input focus
*
* Specifies whether @widget can own the input focus.
*
* Widget implementations should set @focusable to %TRUE in
* their init() function if they want to receive keyboard input.
*
* Note that having @focusable be %TRUE is only one of the
* necessary conditions for being focusable. A widget must
* also be sensitive and can-focus and not have an ancestor
* that is marked as not can-focus in order to receive input
* focus.
*
* See gtk_widget_grab_focus() for actually setting the input
* focus on a widget.
**/
void
gtk_widget_set_focusable (GtkWidget *widget,
gboolean focusable)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
g_return_if_fail (GTK_IS_WIDGET (widget));
if (priv->focusable == focusable)
return;
priv->focusable = focusable;
gtk_widget_queue_resize (widget);
g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_FOCUSABLE]);
}
/**
* gtk_widget_get_focusable:
* @widget: a #GtkWidget
*
* Determines whether @widget can own the input focus.
* See gtk_widget_set_focusable().
*
* Returns: %TRUE if @widget can own the input focus, %FALSE otherwise
**/
gboolean
gtk_widget_get_focusable (GtkWidget *widget)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
return priv->focusable;
}
/**
* gtk_widget_has_focus:
* @widget: a #GtkWidget
@ -6662,7 +6741,7 @@ gtk_widget_get_display (GtkWidget *widget)
* writing an app, youd use gtk_widget_grab_focus() to move the focus
* to a particular widget.
*
* gtk_widget_child_focus() is called by containers as the user moves
* gtk_widget_child_focus() is called by widgets as the user moves
* around the window using keyboard shortcuts. @direction indicates
* what kind of motion is taking place (up, down, left, right, tab
* forward, tab backward). gtk_widget_child_focus() emits the
@ -6689,7 +6768,7 @@ gtk_widget_child_focus (GtkWidget *widget,
!gtk_widget_get_can_focus (widget))
return FALSE;
/* Emit ::focus in any case, even if can-focus is FALSE,
/* Emit ::focus in any case, even if focusable is FALSE,
* since any widget might have child widgets that will take
* focus
*/

View File

@ -406,6 +406,11 @@ void gtk_widget_set_can_focus (GtkWidget *widget,
GDK_AVAILABLE_IN_ALL
gboolean gtk_widget_get_can_focus (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
void gtk_widget_set_focusable (GtkWidget *widget,
gboolean focusable);
GDK_AVAILABLE_IN_ALL
gboolean gtk_widget_get_focusable (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
gboolean gtk_widget_has_focus (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
gboolean gtk_widget_is_focus (GtkWidget *widget);

View File

@ -77,6 +77,7 @@ struct _GtkWidgetPrivate
guint visible : 1;
guint sensitive : 1;
guint can_focus : 1;
guint focusable : 1;
guint has_focus : 1;
guint focus_on_click : 1;
guint has_default : 1;
@ -356,10 +357,6 @@ guint gtk_widget_add_surface_transform_changed_callback (GtkWidget
void gtk_widget_remove_surface_transform_changed_callback (GtkWidget *widget,
guint id);
/* focus vfuncs for non-focusable non-containers */
gboolean gtk_widget_grab_focus_none (GtkWidget *widget);
gboolean gtk_widget_focus_none (GtkWidget *widget,
GtkDirectionType direction);
/* focus vfuncs for non-focusable containers with focusable children */
gboolean gtk_widget_grab_focus_child (GtkWidget *widget);
gboolean gtk_widget_focus_child (GtkWidget *widget,
@ -368,9 +365,6 @@ gboolean gtk_widget_focus_child (GtkWidget *widget,
gboolean gtk_widget_grab_focus_self (GtkWidget *widget);
gboolean gtk_widget_focus_self (GtkWidget *widget,
GtkDirectionType direction);
/* focus vfuncs for focusable widgets with children that receive focus */
gboolean gtk_widget_focus_all (GtkWidget *widget,
GtkDirectionType direction);
/* inline getters */

View File

@ -757,7 +757,6 @@ gtk_window_class_init (GtkWindowClass *klass)
widget_class->compute_expand = gtk_window_compute_expand;
widget_class->get_request_mode = gtk_window_get_request_mode;
widget_class->focus = gtk_window_focus;
widget_class->grab_focus = gtk_widget_grab_focus_none;
widget_class->move_focus = gtk_window_move_focus;
widget_class->state_flags_changed = gtk_window_state_flags_changed;
widget_class->css_changed = gtk_window_css_changed;

View File

@ -572,8 +572,6 @@ gtk_window_handle_class_init (GtkWindowHandleClass *klass)
object_class->set_property = gtk_window_handle_set_property;
widget_class->unrealize = gtk_window_handle_unrealize;
widget_class->grab_focus = gtk_widget_grab_focus_none;
widget_class->focus = gtk_widget_focus_child;
props[PROP_CHILD] =
g_param_spec_object ("child",