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
@@ -4,124 +4,135 @@
<property name="orientation">vertical</property>
<child>
<object class="AdwPreferencesPage">
<child>
<object class="AdwPreferencesGroup">
<object class="AdwToolbarView">
<!-- Online Accounts -->
<child type="top">
<object class="AdwHeaderBar">
<property name="show-end-title-buttons">False</property>
<property name="show-start-title-buttons">False</property>
<property name="title-widget">
<object class="AdwWindowTitle" />
</property>
</object>
</child>
<property name="content">
<object class="AdwPreferencesPage">
<child>
<object class="AdwActionRow" id="account_row">
<property name="title" translatable="yes">Account</property>
<property name="activatable-widget">settings_button</property>
<style>
<class name="property"/>
</style>
<object class="AdwPreferencesGroup">
<!-- Online Accounts -->
<child>
<object class="GtkButton" id="settings_button">
<property name="tooltip-text" translatable="yes">Open in Settings</property>
<property name="valign">center</property>
<signal name="clicked" handler="on_settings_button_clicked_cb" object="GcalEditCalendarPage" swapped="no" />
<object class="AdwActionRow" id="account_row">
<property name="title" translatable="yes">Account</property>
<property name="activatable-widget">settings_button</property>
<style>
<class name="flat"/>
<class name="property"/>
</style>
<child>
<object class="GtkImage">
<property name="icon-name">settings-symbolic</property>
<object class="GtkButton" id="settings_button">
<property name="tooltip-text" translatable="yes">Open in Settings</property>
<property name="valign">center</property>
<signal name="clicked" handler="on_settings_button_clicked_cb" object="GcalEditCalendarPage" swapped="no" />
<style>
<class name="flat"/>
</style>
<child>
<object class="GtkImage">
<property name="icon-name">settings-symbolic</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<!-- Location (URL, file path) -->
<child>
<object class="AdwActionRow" id="calendar_url_row">
<property name="title" translatable="yes">Location</property>
<property name="subtitle-lines">1</property>
<property name="visible" bind-source="calendar_url_row" bind-property="visible" bind-flags="default" />
<style>
<class name="property"/>
</style>
</object>
</child>
<!-- Location (URL, file path) -->
<child>
<object class="AdwActionRow" id="calendar_url_row">
<property name="title" translatable="yes">Location</property>
<property name="subtitle-lines">1</property>
<property name="visible" bind-source="calendar_url_row" bind-property="visible" bind-flags="default" />
<style>
<class name="property"/>
</style>
</object>
</child>
<!-- Calendar name -->
<child>
<object class="AdwEntryRow" id="name_entry">
<property name="title" translatable="yes">Calendar Name</property>
</object>
</child>
<!-- Calendar name -->
<child>
<object class="AdwEntryRow" id="name_entry">
<property name="title" translatable="yes">Calendar Name</property>
</object>
</child>
<!-- Color -->
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Color</property>
<property name="activatable-widget">calendar_color_button</property>
<!-- Color -->
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Color</property>
<property name="activatable-widget">calendar_color_button</property>
<child>
<object class="GtkColorDialogButton" id="calendar_color_button">
<property name="valign">center</property>
<property name="dialog">
<object class="GtkColorDialog">
<property name="modal">True</property>
<property name="with-alpha">False</property>
</object>
</property>
</object>
</child>
</object>
</child>
<!-- Calendar visibility -->
<child>
<object class="AdwSwitchRow" id="calendar_visible_row">
<property name="title" translatable="yes">_Display Calendar</property>
<property name="use-underline">true</property>
</object>
</child>
<child>
<object class="GtkColorDialogButton" id="calendar_color_button">
<object class="AdwSwitchRow" id="default_row">
<property name="title" translatable="yes">Default _Calendar</property>
<property name="subtitle" translatable="yes">Add new events to this calendar by default.</property>
<property name="use-underline">true</property>
</object>
</child>
<!-- Remove button -->
<child>
<object class="GtkButton" id="remove_button">
<property name="label" translatable="yes">_Remove Calendar</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="dialog">
<object class="GtkColorDialog">
<property name="modal">True</property>
<property name="with-alpha">False</property>
</object>
</property>
<property name="margin-top">24</property>
<property name="use-underline">true</property>
<signal name="clicked" handler="on_remove_button_clicked_cb" object="GcalEditCalendarPage" swapped="no" />
<style>
<class name="destructive-action" />
<class name="pill"/>
</style>
</object>
</child>
</object>
</child>
<!-- Calendar visibility -->
<child>
<object class="AdwSwitchRow" id="calendar_visible_row">
<property name="title" translatable="yes">_Display Calendar</property>
<property name="use-underline">true</property>
</object>
</child>
<child>
<object class="AdwSwitchRow" id="default_row">
<property name="title" translatable="yes">Default _Calendar</property>
<property name="subtitle" translatable="yes">Add new events to this calendar by default.</property>
<property name="use-underline">true</property>
</object>
</child>
<!-- Remove button -->
<child>
<object class="GtkButton" id="remove_button">
<property name="label" translatable="yes">_Remove Calendar</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="margin-top">24</property>
<property name="use-underline">true</property>
<signal name="clicked" handler="on_remove_button_clicked_cb" object="GcalEditCalendarPage" swapped="no" />
<style>
<class name="destructive-action" />
<class name="pill"/>
</style>
</object>
</child>
</object>
</child>
</property>
</object>
</child>
</template>
<!-- Headerbar buttons -->
<object class="GtkButton" id="back_button">
<property name="icon-name">go-previous-symbolic</property>
<property name="tooltip-text" translatable="yes">Back</property>
<signal name="clicked" handler="on_back_button_clicked_cb" object="GcalEditCalendarPage" swapped="no" />
</object>
</interface>