From 61a3b9f869b84f4ecef51d672e06d160126c9762 Mon Sep 17 00:00:00 2001 From: Hari Rana Date: Sun, 31 May 2026 12:53:18 -0400 Subject: [PATCH] event-editor/attendees-section: Subclass GcalEventEditorSection Part-of: --- .../event-editor/gcal-attendees-section.blp | 3 +- src/gui/event-editor/gcal-attendees-section.c | 53 +++++++------------ src/gui/event-editor/gcal-attendees-section.h | 4 +- 3 files changed, 22 insertions(+), 38 deletions(-) diff --git a/src/gui/event-editor/gcal-attendees-section.blp b/src/gui/event-editor/gcal-attendees-section.blp index 1b448987..8066b286 100644 --- a/src/gui/event-editor/gcal-attendees-section.blp +++ b/src/gui/event-editor/gcal-attendees-section.blp @@ -1,7 +1,6 @@ using Gtk 4.0; -using Adw 1; -template $GcalAttendeesSection: Adw.PreferencesGroup { +template $GcalAttendeesSection: $GcalEventEditorSection { $GcalOrganizerRow organizer_row { organizer: bind template.organizer; } diff --git a/src/gui/event-editor/gcal-attendees-section.c b/src/gui/event-editor/gcal-attendees-section.c index 611348c9..3b36685c 100644 --- a/src/gui/event-editor/gcal-attendees-section.c +++ b/src/gui/event-editor/gcal-attendees-section.c @@ -24,8 +24,6 @@ #include "gcal-attendee-summary-row.h" #include "gcal-event-attendee.h" -#include "gcal-event-editor-dialog.h" -#include "gcal-event-editor-section.h" #include "gcal-event-organizer.h" #include "gcal-event.h" #include "gcal-organizer-row.h" @@ -33,7 +31,7 @@ struct _GcalAttendeesSection { - AdwPreferencesGroup parent_instance; + GcalEventEditorSection parent_instance; GcalEventOrganizer *organizer; @@ -42,7 +40,7 @@ struct _GcalAttendeesSection GListModel *attendees; }; -G_DEFINE_FINAL_TYPE (GcalAttendeesSection, gcal_attendees_section, ADW_TYPE_PREFERENCES_GROUP) +G_DEFINE_FINAL_TYPE (GcalAttendeesSection, gcal_attendees_section, GCAL_TYPE_EVENT_EDITOR_SECTION) enum { @@ -56,43 +54,28 @@ static GParamSpec *properties[N_PROPS] = { NULL, }; /* - * GtkWidget overrides + * GcalEventEditorSection overrides */ static void -gcal_attendees_section_map (GtkWidget *widget) +gcal_attendees_section_event_set_cb (GcalEventEditorSection *section, + GcalEvent *event) { - GcalAttendeesSection *self = GCAL_ATTENDEES_SECTION (widget); - GtkWidget *dialog; - GcalEvent *event; + GcalAttendeesSection *self = GCAL_ATTENDEES_SECTION (section); - dialog = gtk_widget_get_ancestor (widget, GCAL_TYPE_EVENT_EDITOR_DIALOG); - - g_assert (GCAL_IS_EVENT_EDITOR_DIALOG (dialog)); - - event = gcal_event_editor_dialog_get_event (GCAL_EVENT_EDITOR_DIALOG (dialog)); - - self->organizer = gcal_event_get_organizer (event); - self->attendees = gcal_event_get_attendees (event); + if (event) + { + self->organizer = gcal_event_get_organizer (event); + self->attendees = gcal_event_get_attendees (event); + } + else + { + self->organizer = NULL; + self->attendees = NULL; + } g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ATTENDEES]); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ORGANIZER]); - - GTK_WIDGET_CLASS (gcal_attendees_section_parent_class)->map (widget); -} - -static void -gcal_attendees_section_unmap (GtkWidget *widget) -{ - GcalAttendeesSection *self = GCAL_ATTENDEES_SECTION (widget); - - self->organizer = NULL; - self->attendees = NULL; - - g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ATTENDEES]); - g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ORGANIZER]); - - GTK_WIDGET_CLASS (gcal_attendees_section_parent_class)->unmap (widget); } @@ -163,6 +146,7 @@ gcal_attendees_section_class_init (GcalAttendeesSectionClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + GcalEventEditorSectionClass *section_class = GCAL_EVENT_EDITOR_SECTION_CLASS (klass); g_type_ensure (GCAL_TYPE_ORGANIZER_ROW); g_type_ensure (GCAL_TYPE_ATTENDEE_SUMMARY_ROW); @@ -171,8 +155,7 @@ gcal_attendees_section_class_init (GcalAttendeesSectionClass *klass) object_class->get_property = gcal_attendees_section_get_property; object_class->set_property = gcal_attendees_section_set_property; - widget_class->map = gcal_attendees_section_map; - widget_class->unmap = gcal_attendees_section_unmap; + section_class->event_set_cb = gcal_attendees_section_event_set_cb; /** * GcalAttendeesSection:attendees: diff --git a/src/gui/event-editor/gcal-attendees-section.h b/src/gui/event-editor/gcal-attendees-section.h index a6840cb9..a882d5d0 100644 --- a/src/gui/event-editor/gcal-attendees-section.h +++ b/src/gui/event-editor/gcal-attendees-section.h @@ -20,9 +20,11 @@ #include +#include "gcal-event-editor-section.h" + G_BEGIN_DECLS #define GCAL_TYPE_ATTENDEES_SECTION (gcal_attendees_section_get_type ()) -G_DECLARE_FINAL_TYPE (GcalAttendeesSection, gcal_attendees_section, GCAL, ATTENDEES_SECTION, AdwPreferencesGroup) +G_DECLARE_FINAL_TYPE (GcalAttendeesSection, gcal_attendees_section, GCAL, ATTENDEES_SECTION, GcalEventEditorSection) G_END_DECLS