views/month-cell: Add activate signal
This will be needed for keyboard navigation. Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/564>
This commit is contained in:
@@ -9,6 +9,7 @@ template $GcalMonthCell: Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
accessible-role: grid_cell;
|
accessible-role: grid_cell;
|
||||||
|
receives-default: true;
|
||||||
focusable: true;
|
focusable: true;
|
||||||
|
|
||||||
Adw.BreakpointBin breakpoint_bin {
|
Adw.BreakpointBin breakpoint_bin {
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ G_DEFINE_TYPE (GcalMonthCell, gcal_month_cell, GTK_TYPE_WIDGET)
|
|||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
SHOW_OVERFLOW,
|
SHOW_OVERFLOW,
|
||||||
|
ACTIVATE,
|
||||||
N_SIGNALS
|
N_SIGNALS
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -441,6 +442,40 @@ gcal_month_cell_class_init (GcalMonthCellClass *klass)
|
|||||||
1,
|
1,
|
||||||
GTK_TYPE_WIDGET);
|
GTK_TYPE_WIDGET);
|
||||||
|
|
||||||
|
signals[ACTIVATE] = g_signal_new ("activate",
|
||||||
|
GCAL_TYPE_MONTH_CELL,
|
||||||
|
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
|
||||||
|
0,
|
||||||
|
NULL, NULL,
|
||||||
|
g_cclosure_marshal_VOID__VOID,
|
||||||
|
G_TYPE_NONE,
|
||||||
|
0);
|
||||||
|
|
||||||
|
gtk_widget_class_set_activate_signal (widget_class, signals[ACTIVATE]);
|
||||||
|
|
||||||
|
{
|
||||||
|
g_autoptr (GtkShortcutAction) activate_action = NULL;
|
||||||
|
const guint activate_keyvals[] = {
|
||||||
|
GDK_KEY_space,
|
||||||
|
GDK_KEY_KP_Space,
|
||||||
|
GDK_KEY_Return,
|
||||||
|
GDK_KEY_ISO_Enter,
|
||||||
|
GDK_KEY_KP_Enter,
|
||||||
|
};
|
||||||
|
|
||||||
|
activate_action = gtk_signal_action_new ("activate");
|
||||||
|
|
||||||
|
for (size_t i = 0; i < G_N_ELEMENTS (activate_keyvals); i++)
|
||||||
|
{
|
||||||
|
g_autoptr (GtkShortcut) activate_shortcut = NULL;
|
||||||
|
|
||||||
|
activate_shortcut = gtk_shortcut_new (gtk_keyval_trigger_new (activate_keyvals[i], 0),
|
||||||
|
g_object_ref (activate_action));
|
||||||
|
|
||||||
|
gtk_widget_class_add_shortcut (widget_class, activate_shortcut);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
properties[PROP_CONTEXT] = g_param_spec_object ("context",
|
properties[PROP_CONTEXT] = g_param_spec_object ("context",
|
||||||
"Context",
|
"Context",
|
||||||
"The GcalContext of the application",
|
"The GcalContext of the application",
|
||||||
|
|||||||
Reference in New Issue
Block a user