malcontent-control: Focus controls rather than user selector

When showing the controls, focus them first rather than the user
selector. The correct user is probably already selected.

This has the added benefit of not drawing attention to the ugly focus
rectangle on the user selector.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
Philip Withnall 2021-10-07 16:18:00 +01:00
parent 33b0692896
commit 98ebfaa20e
1 changed files with 7 additions and 2 deletions

View File

@ -414,7 +414,7 @@ update_main_stack (MctApplication *self)
mct_user_controls_set_user (self->user_controls, selected_user); mct_user_controls_set_user (self->user_controls, selected_user);
new_page_name = "controls"; new_page_name = "controls";
new_focus_widget = GTK_WIDGET (self->user_selector); new_focus_widget = GTK_WIDGET (self->user_controls);
} }
else else
{ {
@ -426,7 +426,12 @@ update_main_stack (MctApplication *self)
gtk_stack_set_visible_child_name (self->main_stack, new_page_name); gtk_stack_set_visible_child_name (self->main_stack, new_page_name);
if (new_focus_widget != NULL && !g_str_equal (old_page_name, new_page_name)) if (new_focus_widget != NULL && !g_str_equal (old_page_name, new_page_name))
{
if (gtk_widget_get_can_focus (new_focus_widget))
gtk_widget_grab_focus (new_focus_widget); gtk_widget_grab_focus (new_focus_widget);
else
gtk_widget_child_focus (new_focus_widget, GTK_DIR_TAB_FORWARD);
}
} }
static void static void