event-editor/event-editor-dialog: Install actions in widget class

This is a prerequisite in order to enable/disable actions using
`gtk_widget_action_set_enabled()`, is something we'll be making
use of in the future.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/779>
This commit is contained in:
Hari Rana
2026-06-23 12:55:12 -04:00
parent 3d768fa748
commit 701c6e3cb5
+12 -20
View File
@@ -81,7 +81,6 @@ struct _GcalEventEditorDialog
GListStore *read_only_calendar_model;
GListModel *attendees_model;
GSimpleActionGroup *action_group;
/* flags */
gboolean event_is_new;
@@ -314,21 +313,21 @@ out:
*/
static void
on_event_editor_save_action_activated_cb (GSimpleAction *action,
GVariant *param,
gpointer user_data)
on_event_editor_save_action_activated_cb (GtkWidget *widget,
const char *action_name,
GVariant *param)
{
GcalEventEditorDialog *self = GCAL_EVENT_EDITOR_DIALOG (user_data);
GcalEventEditorDialog *self = GCAL_EVENT_EDITOR_DIALOG (widget);
save_event_and_close_dialog (self);
}
static void
on_show_attendees_detail_page_action_activated_cb (GSimpleAction *action,
GVariant *param,
gpointer user_data)
on_show_attendees_detail_page_action_activated_cb (GtkWidget *widget,
const char *action_name,
GVariant *param)
{
GcalEventEditorDialog *self = GCAL_EVENT_EDITOR_DIALOG (user_data);
GcalEventEditorDialog *self = GCAL_EVENT_EDITOR_DIALOG (widget);
gcal_attendee_details_page_set_attendees (GCAL_ATTENDEE_DETAILS_PAGE (self->attendee_details_page),
self->attendees_model);
@@ -479,7 +478,6 @@ gcal_event_editor_dialog_finalize (GObject *object)
self = GCAL_EVENT_EDITOR_DIALOG (object);
g_clear_object (&self->read_only_calendar_model);
g_clear_object (&self->action_group);
g_clear_object (&self->event);
self->attendees_model = NULL; /* not owned */
@@ -601,23 +599,17 @@ gcal_event_editor_dialog_class_init (GcalEventEditorDialogClass *klass)
/* callbacks */
gtk_widget_class_bind_template_callback (widget_class, on_cancel_button_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, on_delete_row_activated_cb);
gtk_widget_class_install_action (widget_class, "event-editor.save", NULL, on_event_editor_save_action_activated_cb);
gtk_widget_class_install_action (widget_class, "event-editor.show-attendees-detail-page", "u",
on_show_attendees_detail_page_action_activated_cb);
}
static void
gcal_event_editor_dialog_init (GcalEventEditorDialog *self)
{
static const GActionEntry actions[] = {
{ "save", on_event_editor_save_action_activated_cb },
{ "show-attendees-detail-page", on_show_attendees_detail_page_action_activated_cb, "u" },
};
gint i = 0;
/* Setup actions */
self->action_group = g_simple_action_group_new ();
g_action_map_add_action_entries (G_ACTION_MAP (self->action_group), actions, G_N_ELEMENTS (actions), self);
gtk_widget_insert_action_group (GTK_WIDGET (self), "event-editor", G_ACTION_GROUP (self->action_group));
gtk_widget_init_template (GTK_WIDGET (self));
self->sections[i++] = self->notes_section;