Remove lots of focus vfuncs

In many cases, the default widget vfuncs work just fine,
combined with setting focusable.
This commit is contained in:
Matthias Clasen 2020-05-10 23:58:30 -04:00
parent 46bad5d513
commit b93631164f
43 changed files with 10 additions and 114 deletions

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;

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:
*

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

@ -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"),

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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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;

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;

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;

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

@ -573,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);
@ -934,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;
@ -4777,12 +4779,6 @@ 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)
{
@ -4943,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;
@ -5013,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)

View File

@ -357,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,
@ -369,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",