views/month-cell: Override focus() virtual function

Without this patch, focus immediately goes to the "Previous Month"
button at startup, for some unknown reason.
So, as a workaround, skip focus if the root cannot retrieve the
current focused widget.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/564>
This commit is contained in:
Hari Rana
2026-03-03 18:35:17 -05:00
parent 80adbd0d23
commit e88f77802b
+19
View File
@@ -344,6 +344,23 @@ on_breakpoint_changed_cb (GcalMonthCell *self)
}
/*
* GtkWidget overrides
*/
static gboolean
gcal_month_cell_focus (GtkWidget *widget,
GtkDirectionType direction)
{
GtkRoot *root = gtk_widget_get_root (widget);
if (gtk_root_get_focus (root) == NULL)
return FALSE;
return GTK_WIDGET_CLASS (gcal_month_cell_parent_class)->focus (widget, direction);
}
/*
* GObject overrides
*/
@@ -414,6 +431,8 @@ gcal_month_cell_class_init (GcalMonthCellClass *klass)
object_class->set_property = gcal_month_cell_set_property;
object_class->get_property = gcal_month_cell_get_property;
widget_class->focus = gcal_month_cell_focus;
signals[SHOW_OVERFLOW] = g_signal_new ("show-overflow",
GCAL_TYPE_MONTH_CELL,
G_SIGNAL_RUN_LAST,