calendar-management: Port to AdwNavigationView

The interfacing that GcalCalendarManagementDialog had is somewhat
similar to AdwNavigationView, with pages and signaling basically
matching the same semantics.

We can save some code by switching to AdwNavigationView then, as
the heavy-lifting of page management is done there now.

The headerbar of the dialog is no more; instead, each page has its
own headerbar that automatically gets a back button.

Page activation and deactivation works essentially the same, but
uses AdwNavigationView signals to manage that.
This commit is contained in:
Georges Basile Stavracas Neto
2023-06-22 00:20:21 +00:00
parent fd5aeac057
commit bdda09abb8
10 changed files with 341 additions and 398 deletions
@@ -48,10 +48,9 @@ struct _GcalNewCalendarPage
GtkEntry *calendar_address_entry;
EntryState calendar_address_entry_state;
GcalFileChooserButton *calendar_file_chooser_button;
GtkWidget *cancel_button;
GtkWidget *credentials_cancel_button;
GtkWidget *credentials_connect_button;
AdwWindow *credentials_dialog;
GtkWindow *credentials_dialog;
GtkEntry *credentials_password_entry;
GtkEntry *credentials_user_entry;
GtkColorDialogButton *local_calendar_color_button;
@@ -466,13 +465,6 @@ on_url_entry_text_changed_cb (GtkEntry *entry,
GCAL_EXIT;
}
static void
on_cancel_button_clicked_cb (GtkWidget *button,
GcalCalendarManagementPage *page)
{
gcal_calendar_management_page_switch_page (page, "calendars", NULL);
}
static void
on_local_calendar_name_row_text_changed_cb (AdwEntryRow *entry_row,
GParamSpec *pspec,
@@ -516,38 +508,14 @@ gcal_new_calendar_page_get_title (GcalCalendarManagementPage *page)
return _("New Calendar");
}
static void
gcal_new_calendar_page_activate (GcalCalendarManagementPage *page,
GcalCalendar *calendar)
{
GcalNewCalendarPage *self;
GtkHeaderBar *headerbar;
GCAL_ENTRY;
self = GCAL_NEW_CALENDAR_PAGE (page);
headerbar = gcal_calendar_management_page_get_titlebar (page);
gtk_header_bar_pack_start (headerbar, self->cancel_button);
gtk_header_bar_pack_end (headerbar, self->add_button);
gtk_header_bar_set_show_title_buttons (headerbar, FALSE);
GCAL_EXIT;
}
static void
gcal_new_calendar_page_deactivate (GcalCalendarManagementPage *page)
{
GcalNewCalendarPage *self;
GtkHeaderBar *headerbar;
GCAL_ENTRY;
self = GCAL_NEW_CALENDAR_PAGE (page);
headerbar = gcal_calendar_management_page_get_titlebar (page);
gtk_header_bar_remove (headerbar, self->cancel_button);
gtk_header_bar_remove (headerbar, self->add_button);
gtk_header_bar_set_show_title_buttons (headerbar, TRUE);
g_clear_object (&self->local_source);
g_clear_pointer (&self->remote_sources, g_ptr_array_unref);
@@ -566,7 +534,6 @@ gcal_calendar_management_page_iface_init (GcalCalendarManagementPageInterface *i
{
iface->get_name = gcal_new_calendar_page_get_name;
iface->get_title = gcal_new_calendar_page_get_title;
iface->activate = gcal_new_calendar_page_activate;
iface->deactivate = gcal_new_calendar_page_deactivate;
}
@@ -658,7 +625,6 @@ gcal_new_calendar_page_class_init (GcalNewCalendarPageClass *klass)
gtk_widget_class_bind_template_child (widget_class, GcalNewCalendarPage, add_button);
gtk_widget_class_bind_template_child (widget_class, GcalNewCalendarPage, calendar_address_entry);
gtk_widget_class_bind_template_child (widget_class, GcalNewCalendarPage, calendar_file_chooser_button);
gtk_widget_class_bind_template_child (widget_class, GcalNewCalendarPage, cancel_button);
gtk_widget_class_bind_template_child (widget_class, GcalNewCalendarPage, credentials_cancel_button);
gtk_widget_class_bind_template_child (widget_class, GcalNewCalendarPage, credentials_connect_button);
gtk_widget_class_bind_template_child (widget_class, GcalNewCalendarPage, credentials_dialog);
@@ -671,7 +637,6 @@ gcal_new_calendar_page_class_init (GcalNewCalendarPageClass *klass)
gtk_widget_class_bind_template_callback (widget_class, on_add_button_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, on_calendar_address_activated_cb);
gtk_widget_class_bind_template_callback (widget_class, on_cancel_button_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, on_credential_button_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, on_credential_entry_activate_cb);
gtk_widget_class_bind_template_callback (widget_class, on_file_chooser_button_file_changed_cb);