event-editor/attendees-section: Subclass GcalEventEditorSection
Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/711>
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
using Gtk 4.0;
|
using Gtk 4.0;
|
||||||
using Adw 1;
|
|
||||||
|
|
||||||
template $GcalAttendeesSection: Adw.PreferencesGroup {
|
template $GcalAttendeesSection: $GcalEventEditorSection {
|
||||||
$GcalOrganizerRow organizer_row {
|
$GcalOrganizerRow organizer_row {
|
||||||
organizer: bind template.organizer;
|
organizer: bind template.organizer;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,6 @@
|
|||||||
|
|
||||||
#include "gcal-attendee-summary-row.h"
|
#include "gcal-attendee-summary-row.h"
|
||||||
#include "gcal-event-attendee.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-organizer.h"
|
||||||
#include "gcal-event.h"
|
#include "gcal-event.h"
|
||||||
#include "gcal-organizer-row.h"
|
#include "gcal-organizer-row.h"
|
||||||
@@ -33,7 +31,7 @@
|
|||||||
|
|
||||||
struct _GcalAttendeesSection
|
struct _GcalAttendeesSection
|
||||||
{
|
{
|
||||||
AdwPreferencesGroup parent_instance;
|
GcalEventEditorSection parent_instance;
|
||||||
|
|
||||||
GcalEventOrganizer *organizer;
|
GcalEventOrganizer *organizer;
|
||||||
|
|
||||||
@@ -42,7 +40,7 @@ struct _GcalAttendeesSection
|
|||||||
GListModel *attendees;
|
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
|
enum
|
||||||
{
|
{
|
||||||
@@ -56,43 +54,28 @@ static GParamSpec *properties[N_PROPS] = { NULL, };
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GtkWidget overrides
|
* GcalEventEditorSection overrides
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gcal_attendees_section_map (GtkWidget *widget)
|
gcal_attendees_section_event_set_cb (GcalEventEditorSection *section,
|
||||||
|
GcalEvent *event)
|
||||||
{
|
{
|
||||||
GcalAttendeesSection *self = GCAL_ATTENDEES_SECTION (widget);
|
GcalAttendeesSection *self = GCAL_ATTENDEES_SECTION (section);
|
||||||
GtkWidget *dialog;
|
|
||||||
GcalEvent *event;
|
|
||||||
|
|
||||||
dialog = gtk_widget_get_ancestor (widget, GCAL_TYPE_EVENT_EDITOR_DIALOG);
|
if (event)
|
||||||
|
{
|
||||||
g_assert (GCAL_IS_EVENT_EDITOR_DIALOG (dialog));
|
self->organizer = gcal_event_get_organizer (event);
|
||||||
|
self->attendees = gcal_event_get_attendees (event);
|
||||||
event = gcal_event_editor_dialog_get_event (GCAL_EVENT_EDITOR_DIALOG (dialog));
|
}
|
||||||
|
else
|
||||||
self->organizer = gcal_event_get_organizer (event);
|
{
|
||||||
self->attendees = gcal_event_get_attendees (event);
|
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_ATTENDEES]);
|
||||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ORGANIZER]);
|
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);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
GtkWidgetClass *widget_class = GTK_WIDGET_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_ORGANIZER_ROW);
|
||||||
g_type_ensure (GCAL_TYPE_ATTENDEE_SUMMARY_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->get_property = gcal_attendees_section_get_property;
|
||||||
object_class->set_property = gcal_attendees_section_set_property;
|
object_class->set_property = gcal_attendees_section_set_property;
|
||||||
|
|
||||||
widget_class->map = gcal_attendees_section_map;
|
section_class->event_set_cb = gcal_attendees_section_event_set_cb;
|
||||||
widget_class->unmap = gcal_attendees_section_unmap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GcalAttendeesSection:attendees:
|
* GcalAttendeesSection:attendees:
|
||||||
|
|||||||
@@ -20,9 +20,11 @@
|
|||||||
|
|
||||||
#include <adwaita.h>
|
#include <adwaita.h>
|
||||||
|
|
||||||
|
#include "gcal-event-editor-section.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define GCAL_TYPE_ATTENDEES_SECTION (gcal_attendees_section_get_type ())
|
#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
|
G_END_DECLS
|
||||||
|
|||||||
Reference in New Issue
Block a user