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:
@@ -55,10 +55,7 @@ struct _GcalCalendarManagementDialog
|
||||
{
|
||||
AdwWindow parent;
|
||||
|
||||
GtkHeaderBar *headerbar;
|
||||
GtkWidget *notebook;
|
||||
GtkWidget *stack;
|
||||
AdwWindowTitle *window_title;
|
||||
AdwNavigationView *navigation_view;
|
||||
|
||||
/* flags */
|
||||
ESource *source;
|
||||
@@ -97,29 +94,21 @@ set_page (GcalCalendarManagementDialog *self,
|
||||
const gchar *page_name,
|
||||
GcalCalendar *calendar)
|
||||
{
|
||||
GcalCalendarManagementPage *current_page;
|
||||
guint i;
|
||||
GcalCalendarManagementPage *next_page;
|
||||
AdwNavigationPage *page;
|
||||
|
||||
GCAL_TRACE_MSG ("Switching to page '%s'", page_name);
|
||||
|
||||
current_page = (GcalCalendarManagementPage*) gtk_stack_get_visible_child (GTK_STACK (self->stack));
|
||||
page = adw_navigation_view_find_page (self->navigation_view, page_name);
|
||||
g_assert (page != NULL);
|
||||
next_page = GCAL_CALENDAR_MANAGEMENT_PAGE (adw_navigation_page_get_child (page));
|
||||
|
||||
for (i = 0; i < N_PAGES; i++)
|
||||
{
|
||||
GcalCalendarManagementPage *page = self->pages[i];
|
||||
gcal_calendar_management_page_activate (next_page, calendar);
|
||||
|
||||
if (g_strcmp0 (page_name, gcal_calendar_management_page_get_name (page)) != 0)
|
||||
continue;
|
||||
adw_navigation_view_pop (self->navigation_view);
|
||||
|
||||
gtk_stack_set_visible_child (GTK_STACK (self->stack), GTK_WIDGET (page));
|
||||
gcal_calendar_management_page_activate (page, calendar);
|
||||
|
||||
adw_window_title_set_title (self->window_title,
|
||||
gcal_calendar_management_page_get_title (page));
|
||||
break;
|
||||
}
|
||||
|
||||
gcal_calendar_management_page_deactivate (current_page);
|
||||
if (page != adw_navigation_view_get_visible_page (self->navigation_view))
|
||||
adw_navigation_view_push (self->navigation_view, page);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -140,16 +129,16 @@ setup_context (GcalCalendarManagementDialog *self)
|
||||
for (i = 0; i < N_PAGES; i++)
|
||||
{
|
||||
GcalCalendarManagementPage *page;
|
||||
AdwNavigationPage *navigation_page;
|
||||
|
||||
page = g_object_new (pages[i].gtype,
|
||||
"context", self->context,
|
||||
NULL);
|
||||
gtk_widget_set_visible (GTK_WIDGET (page), TRUE);
|
||||
|
||||
gtk_stack_add_titled (GTK_STACK (self->stack),
|
||||
GTK_WIDGET (page),
|
||||
gcal_calendar_management_page_get_name (page),
|
||||
gcal_calendar_management_page_get_title (page));
|
||||
navigation_page = adw_navigation_page_new (GTK_WIDGET (page),
|
||||
gcal_calendar_management_page_get_title (page));
|
||||
adw_navigation_page_set_tag (navigation_page, gcal_calendar_management_page_get_name (page));
|
||||
adw_navigation_view_add (self->navigation_view, navigation_page);
|
||||
|
||||
g_signal_connect_object (page,
|
||||
"switch-page",
|
||||
@@ -170,6 +159,19 @@ setup_context (GcalCalendarManagementDialog *self)
|
||||
* Callbacks
|
||||
*/
|
||||
|
||||
static void
|
||||
on_navigation_view_popped_cb (AdwNavigationView *navigation_view,
|
||||
AdwNavigationPage *popped_page,
|
||||
GcalCalendarManagementDialog *self)
|
||||
{
|
||||
GcalCalendarManagementPage *page;
|
||||
|
||||
page = GCAL_CALENDAR_MANAGEMENT_PAGE (adw_navigation_page_get_child (popped_page));
|
||||
g_assert (page != NULL);
|
||||
|
||||
gcal_calendar_management_page_deactivate (page);
|
||||
}
|
||||
|
||||
static void
|
||||
on_page_switched_cb (GcalCalendarManagementPage *page,
|
||||
const gchar *next_page,
|
||||
@@ -266,9 +268,9 @@ gcal_calendar_management_dialog_class_init (GcalCalendarManagementDialogClass *k
|
||||
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/ui/gui/calendar-management/gcal-calendar-management-dialog.ui");
|
||||
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalCalendarManagementDialog, headerbar);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalCalendarManagementDialog, stack);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalCalendarManagementDialog, window_title);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalCalendarManagementDialog, navigation_view);
|
||||
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_navigation_view_popped_cb);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -276,11 +278,3 @@ gcal_calendar_management_dialog_init (GcalCalendarManagementDialog *self)
|
||||
{
|
||||
gtk_widget_init_template (GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
GtkHeaderBar*
|
||||
gcal_calendar_management_dialog_get_titlebar (GcalCalendarManagementDialog *self)
|
||||
{
|
||||
g_return_val_if_fail (GCAL_IS_CALENDAR_MANAGEMENT_DIALOG (self), NULL);
|
||||
|
||||
return self->headerbar;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,4 @@ G_DECLARE_FINAL_TYPE (GcalCalendarManagementDialog,
|
||||
GCAL, CALENDAR_MANAGEMENT_DIALOG,
|
||||
AdwWindow)
|
||||
|
||||
GtkHeaderBar* gcal_calendar_management_dialog_get_titlebar (GcalCalendarManagementDialog *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
@@ -9,32 +9,8 @@
|
||||
<property name="destroy_with_parent">True</property>
|
||||
<property name="hide-on-close">True</property>
|
||||
<child>
|
||||
<object class="AdwLeaflet">
|
||||
<property name="can-unfold">False</property>
|
||||
<child>
|
||||
<object class="AdwToolbarView" id="vbox">
|
||||
<child type="top">
|
||||
<object class="GtkHeaderBar" id="headerbar">
|
||||
<property name="show-title-buttons">True</property>
|
||||
<property name="title-widget">
|
||||
<object class="AdwWindowTitle" id="window_title" />
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<property name="content">
|
||||
<object class="GtkOverlay" id="overlay">
|
||||
<child>
|
||||
<object class="GtkStack" id="stack">
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vhomogeneous">False</property>
|
||||
<property name="transition_type">crossfade</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<object class="AdwNavigationView" id="navigation_view">
|
||||
<signal name="popped" handler="on_navigation_view_popped_cb" object="GcalCalendarManagementDialog" swapped="no" />
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
|
||||
@@ -107,14 +107,3 @@ gcal_calendar_management_page_switch_page (GcalCalendarManagementPage *self,
|
||||
|
||||
g_signal_emit (self, signals[SWITCH_PAGE], 0, page_name, calendar);
|
||||
}
|
||||
|
||||
GtkHeaderBar*
|
||||
gcal_calendar_management_page_get_titlebar (GcalCalendarManagementPage *self)
|
||||
{
|
||||
GtkNative *native;
|
||||
|
||||
native = gtk_widget_get_native (GTK_WIDGET (self));
|
||||
g_assert (native != NULL);
|
||||
|
||||
return gcal_calendar_management_dialog_get_titlebar (GCAL_CALENDAR_MANAGEMENT_DIALOG (native));
|
||||
}
|
||||
|
||||
@@ -61,6 +61,4 @@ void gcal_calendar_management_page_switch_page (GcalCalendarMa
|
||||
const gchar *page_name,
|
||||
GcalCalendar *calendar);
|
||||
|
||||
GtkHeaderBar* gcal_calendar_management_page_get_titlebar (GcalCalendarManagementPage *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
@@ -46,46 +46,64 @@
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="hscrollbar_policy">never</property>
|
||||
<property name="max_content_height">600</property>
|
||||
<property name="propagate_natural_height">True</property>
|
||||
<object class="AdwToolbarView">
|
||||
|
||||
<child>
|
||||
<object class="GtkListBox" id="listbox">
|
||||
<property name="margin-top">24</property>
|
||||
<property name="margin-bottom">24</property>
|
||||
<property name="margin-start">24</property>
|
||||
<property name="margin-end">24</property>
|
||||
<property name="valign">start</property>
|
||||
<property name="selection-mode">none</property>
|
||||
<signal name="row-activated" handler="on_listbox_row_activated_cb" object="GcalCalendarsPage" swapped="no" />
|
||||
<style>
|
||||
<class name="calendars-list"/>
|
||||
<class name="content"/>
|
||||
</style>
|
||||
<child type="top">
|
||||
<object class="GtkHeaderBar">
|
||||
<property name="show-title-buttons">True</property>
|
||||
<property name="title-widget">
|
||||
<object class="AdwWindowTitle">
|
||||
<property name="title" translatable="yes">Calendars</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<property name="content">
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="hscrollbar_policy">never</property>
|
||||
<property name="max_content_height">600</property>
|
||||
<property name="propagate_natural_height">True</property>
|
||||
|
||||
<child>
|
||||
<object class="GtkListBoxRow" id="add_calendar_row">
|
||||
<object class="GtkListBox" id="listbox">
|
||||
<property name="margin-top">24</property>
|
||||
<property name="margin-bottom">24</property>
|
||||
<property name="margin-start">24</property>
|
||||
<property name="margin-end">24</property>
|
||||
<property name="valign">start</property>
|
||||
<property name="selection-mode">none</property>
|
||||
<signal name="row-activated" handler="on_listbox_row_activated_cb" object="GcalCalendarsPage" swapped="no" />
|
||||
<style>
|
||||
<class name="calendars-list"/>
|
||||
<class name="content"/>
|
||||
</style>
|
||||
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="label" translatable="yes">Add Calendar…</property>
|
||||
<object class="GtkListBoxRow" id="add_calendar_row">
|
||||
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="label" translatable="yes">Add Calendar…</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
</object>
|
||||
</child>
|
||||
</property>
|
||||
|
||||
</object>
|
||||
</child>
|
||||
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
|
||||
@@ -31,7 +31,6 @@ struct _GcalEditCalendarPage
|
||||
GtkBox parent;
|
||||
|
||||
AdwActionRow *account_row;
|
||||
GtkWidget *back_button;
|
||||
GtkColorDialogButton *calendar_color_button;
|
||||
AdwSwitchRow *calendar_visible_row;
|
||||
AdwActionRow *calendar_url_row;
|
||||
@@ -225,20 +224,6 @@ update_calendar (GcalEditCalendarPage *self)
|
||||
* Callbacks
|
||||
*/
|
||||
|
||||
static void
|
||||
on_back_button_clicked_cb (GtkButton *back_button,
|
||||
GcalEditCalendarPage *self)
|
||||
{
|
||||
GcalCalendarManagementPage *page;
|
||||
|
||||
GCAL_ENTRY;
|
||||
|
||||
page = GCAL_CALENDAR_MANAGEMENT_PAGE (self);
|
||||
gcal_calendar_management_page_switch_page (page, "calendars", NULL);
|
||||
|
||||
GCAL_EXIT;
|
||||
}
|
||||
|
||||
static void
|
||||
on_remove_button_clicked_cb (GtkButton *button,
|
||||
GcalEditCalendarPage *self)
|
||||
@@ -303,28 +288,22 @@ static void
|
||||
gcal_edit_calendar_page_activate (GcalCalendarManagementPage *page,
|
||||
GcalCalendar *calendar)
|
||||
{
|
||||
GcalEditCalendarPage *self;
|
||||
GtkHeaderBar *headerbar;
|
||||
GCAL_ENTRY;
|
||||
|
||||
self = GCAL_EDIT_CALENDAR_PAGE (page);
|
||||
headerbar = gcal_calendar_management_page_get_titlebar (page);
|
||||
gtk_header_bar_pack_start (headerbar, self->back_button);
|
||||
setup_calendar (GCAL_EDIT_CALENDAR_PAGE (page), calendar);
|
||||
|
||||
setup_calendar (self, calendar);
|
||||
GCAL_EXIT;
|
||||
}
|
||||
|
||||
static void
|
||||
gcal_edit_calendar_page_deactivate (GcalCalendarManagementPage *page)
|
||||
{
|
||||
GcalEditCalendarPage *self;
|
||||
GtkHeaderBar *headerbar;
|
||||
GcalManager *manager;
|
||||
|
||||
GCAL_ENTRY;
|
||||
|
||||
self = GCAL_EDIT_CALENDAR_PAGE (page);
|
||||
headerbar = gcal_calendar_management_page_get_titlebar (page);
|
||||
gtk_header_bar_remove (headerbar, self->back_button);
|
||||
|
||||
update_calendar (self);
|
||||
|
||||
@@ -415,7 +394,6 @@ gcal_edit_calendar_page_class_init (GcalEditCalendarPageClass *klass)
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/ui/gui/calendar-management/gcal-edit-calendar-page.ui");
|
||||
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalEditCalendarPage, account_row);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalEditCalendarPage, back_button);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalEditCalendarPage, calendar_color_button);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalEditCalendarPage, calendar_url_row);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalEditCalendarPage, calendar_visible_row);
|
||||
@@ -423,7 +401,6 @@ gcal_edit_calendar_page_class_init (GcalEditCalendarPageClass *klass)
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalEditCalendarPage, name_entry);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalEditCalendarPage, remove_button);
|
||||
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_back_button_clicked_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_remove_button_clicked_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_settings_button_clicked_cb);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -4,166 +4,197 @@
|
||||
<property name="orientation">vertical</property>
|
||||
|
||||
<child>
|
||||
<object class="AdwPreferencesPage">
|
||||
<object class="AdwToolbarView">
|
||||
|
||||
<!-- Local calendar -->
|
||||
<child>
|
||||
<object class="AdwPreferencesGroup">
|
||||
<child type="top">
|
||||
<object class="AdwHeaderBar">
|
||||
<property name="show-end-title-buttons">False</property>
|
||||
<property name="show-start-title-buttons">False</property>
|
||||
|
||||
<!-- Calendar name -->
|
||||
<child>
|
||||
<object class="AdwEntryRow" id="local_calendar_name_row">
|
||||
<property name="title" translatable="yes">Calendar Name</property>
|
||||
<signal name="notify::text" handler="on_local_calendar_name_row_text_changed_cb" object="GcalNewCalendarPage" swapped="no" />
|
||||
<property name="title-widget">
|
||||
<object class="AdwWindowTitle">
|
||||
<property name="title" translatable="yes">New Calendar</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- Color -->
|
||||
<child>
|
||||
<object class="AdwActionRow">
|
||||
<property name="title" translatable="yes">Color</property>
|
||||
<property name="activatable-widget">local_calendar_color_button</property>
|
||||
|
||||
<child>
|
||||
<object class="GtkColorDialogButton" id="local_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>
|
||||
<signal name="notify::rgba" handler="on_local_calendar_color_button_rgba_changed_cb" object="GcalNewCalendarPage" swapped="no" />
|
||||
</object>
|
||||
</child>
|
||||
</property>
|
||||
|
||||
<child type="end">
|
||||
<object class="GtkButton" id="add_button">
|
||||
<property name="label" translatable="yes">Add</property>
|
||||
<property name="sensitive">False</property>
|
||||
<signal name="clicked" handler="on_add_button_clicked_cb" object="GcalNewCalendarPage" swapped="no" />
|
||||
<style>
|
||||
<class name="suggested-action"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="AdwPreferencesGroup">
|
||||
<property name="content">
|
||||
<object class="AdwPreferencesPage">
|
||||
|
||||
<!-- Local calendar -->
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="hexpand">True</property>
|
||||
<property name="label" translatable="yes">Import a Calendar</property>
|
||||
<property name="xalign">0.0</property>
|
||||
<attributes>
|
||||
<attribute name="scale" value="1.3" />
|
||||
<attribute name="weight" value="bold" />
|
||||
</attributes>
|
||||
<object class="AdwPreferencesGroup">
|
||||
|
||||
<!-- Calendar name -->
|
||||
<child>
|
||||
<object class="AdwEntryRow" id="local_calendar_name_row">
|
||||
<property name="title" translatable="yes">Calendar Name</property>
|
||||
<signal name="notify::text" handler="on_local_calendar_name_row_text_changed_cb" object="GcalNewCalendarPage" swapped="no" />
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- Color -->
|
||||
<child>
|
||||
<object class="AdwActionRow">
|
||||
<property name="title" translatable="yes">Color</property>
|
||||
<property name="activatable-widget">local_calendar_color_button</property>
|
||||
|
||||
<child>
|
||||
<object class="GtkColorDialogButton" id="local_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>
|
||||
<signal name="notify::rgba" handler="on_local_calendar_color_button_rgba_changed_cb" object="GcalNewCalendarPage" swapped="no" />
|
||||
</object>
|
||||
</child>
|
||||
|
||||
</object>
|
||||
</child>
|
||||
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="row_spacing">12</property>
|
||||
<property name="column_spacing">12</property>
|
||||
<object class="AdwPreferencesGroup">
|
||||
|
||||
<!-- Online Accounts reference label-->
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label" translatable="yes">Alternatively, enter the web address of an online calendar you want to import, or open a supported calendar file.</property>
|
||||
<property name="wrap">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">0</property>
|
||||
<property name="column-span">2</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- URL entry -->
|
||||
<child>
|
||||
<object class="GtkEntry" id="calendar_address_entry">
|
||||
<property name="hexpand">True</property>
|
||||
<property name="placeholder-text">https://example.com/calendar.ics</property>
|
||||
<signal name="notify::text" handler="on_url_entry_text_changed_cb" object="GcalNewCalendarPage" swapped="no" />
|
||||
<signal name="activate" handler="on_calendar_address_activated_cb" object="GcalNewCalendarPage" swapped="no" />
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">1</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- File Chooser button -->
|
||||
<child>
|
||||
<object class="GcalFileChooserButton" id="calendar_file_chooser_button">
|
||||
<property name="title" translatable="yes">Open a File</property>
|
||||
<property name="filter">
|
||||
<object class="GtkFileFilter">
|
||||
<property name="name" translatable="yes">Calendar files</property>
|
||||
<patterns>
|
||||
<pattern>*.ical</pattern>
|
||||
<pattern>*.icalendar</pattern>
|
||||
<pattern>*.ics</pattern>
|
||||
<pattern>*.ifb</pattern>
|
||||
<pattern>*.vcs</pattern>
|
||||
</patterns>
|
||||
</object>
|
||||
</property>
|
||||
<signal name="notify::file" handler="on_file_chooser_button_file_changed_cb" object="GcalNewCalendarPage" swapped="no" />
|
||||
<layout>
|
||||
<property name="column">1</property>
|
||||
<property name="row">1</property>
|
||||
</layout>
|
||||
<property name="label" translatable="yes">Import a Calendar</property>
|
||||
<property name="xalign">0.0</property>
|
||||
<attributes>
|
||||
<attribute name="scale" value="1.3" />
|
||||
<attribute name="weight" value="bold" />
|
||||
</attributes>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkRevealer" id="web_sources_revealer">
|
||||
<property name="transition_type">slide-down</property>
|
||||
<property name="transition_duration">200</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">2</property>
|
||||
<property name="column-span">2</property>
|
||||
</layout>
|
||||
<object class="GtkGrid">
|
||||
<property name="row_spacing">12</property>
|
||||
<property name="column_spacing">12</property>
|
||||
|
||||
<!-- Online Accounts reference label-->
|
||||
<child>
|
||||
<object class="GtkBox" id="web_sources_listbox_box">
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="web_sources_calendar_label">
|
||||
<property name="label" translatable="yes">Calendars</property>
|
||||
<property name="xalign">0</property>
|
||||
<attributes>
|
||||
<attribute name="weight" value="bold" />
|
||||
</attributes>
|
||||
<object class="GtkLabel">
|
||||
<property name="label" translatable="yes">Alternatively, enter the web address of an online calendar you want to import, or open a supported calendar file.</property>
|
||||
<property name="wrap">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">0</property>
|
||||
<property name="column-span">2</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- URL entry -->
|
||||
<child>
|
||||
<object class="GtkEntry" id="calendar_address_entry">
|
||||
<property name="hexpand">True</property>
|
||||
<property name="placeholder-text">https://example.com/calendar.ics</property>
|
||||
<signal name="notify::text" handler="on_url_entry_text_changed_cb" object="GcalNewCalendarPage" swapped="no" />
|
||||
<signal name="activate" handler="on_calendar_address_activated_cb" object="GcalNewCalendarPage" swapped="no" />
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">1</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- File Chooser button -->
|
||||
<child>
|
||||
<object class="GcalFileChooserButton" id="calendar_file_chooser_button">
|
||||
<property name="title" translatable="yes">Open a File</property>
|
||||
<property name="filter">
|
||||
<object class="GtkFileFilter">
|
||||
<property name="name" translatable="yes">Calendar files</property>
|
||||
<patterns>
|
||||
<pattern>*.ical</pattern>
|
||||
<pattern>*.icalendar</pattern>
|
||||
<pattern>*.ics</pattern>
|
||||
<pattern>*.ifb</pattern>
|
||||
<pattern>*.vcs</pattern>
|
||||
</patterns>
|
||||
</object>
|
||||
</child>
|
||||
</property>
|
||||
<signal name="notify::file" handler="on_file_chooser_button_file_changed_cb" object="GcalNewCalendarPage" swapped="no" />
|
||||
<layout>
|
||||
<property name="column">1</property>
|
||||
<property name="row">1</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkRevealer" id="web_sources_revealer">
|
||||
<property name="transition_type">slide-down</property>
|
||||
<property name="transition_duration">200</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">2</property>
|
||||
<property name="column-span">2</property>
|
||||
</layout>
|
||||
<child>
|
||||
<object class="GtkListBox" id="web_sources_listbox">
|
||||
<property name="activate_on_single_click">False</property>
|
||||
<property name="selection_mode">none</property>
|
||||
<style>
|
||||
<class name="calendar-list" />
|
||||
</style>
|
||||
<object class="GtkBox" id="web_sources_listbox_box">
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="web_sources_calendar_label">
|
||||
<property name="label" translatable="yes">Calendars</property>
|
||||
<property name="xalign">0</property>
|
||||
<attributes>
|
||||
<attribute name="weight" value="bold" />
|
||||
</attributes>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkListBox" id="web_sources_listbox">
|
||||
<property name="activate_on_single_click">False</property>
|
||||
<property name="selection_mode">none</property>
|
||||
<style>
|
||||
<class name="calendar-list" />
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- Online Accounts reference label-->
|
||||
<child>
|
||||
<object class="GtkLabel" id="web_description_label">
|
||||
<property name="label" translatable="yes">If the calendar belongs to one of your online accounts, you can add it through the <a href="GOA">online account settings</a>.</property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="wrap">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<signal name="activate-link" handler="on_web_description_label_link_activated_cb" object="GcalNewCalendarPage" swapped="no" />
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">3</property>
|
||||
<property name="column-span">2</property>
|
||||
</layout>
|
||||
<!-- Online Accounts reference label-->
|
||||
<child>
|
||||
<object class="GtkLabel" id="web_description_label">
|
||||
<property name="label" translatable="yes">If the calendar belongs to one of your online accounts, you can add it through the <a href="GOA">online account settings</a>.</property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="wrap">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<signal name="activate-link" handler="on_web_description_label_link_activated_cb" object="GcalNewCalendarPage" swapped="no" />
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">3</property>
|
||||
<property name="column-span">2</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
</object>
|
||||
</child>
|
||||
|
||||
@@ -171,8 +202,7 @@
|
||||
</child>
|
||||
|
||||
</object>
|
||||
</child>
|
||||
|
||||
</property>
|
||||
|
||||
</object>
|
||||
</child>
|
||||
@@ -286,17 +316,4 @@
|
||||
</property>
|
||||
</object>
|
||||
|
||||
<!-- Headerbar buttons -->
|
||||
<object class="GtkButton" id="cancel_button">
|
||||
<property name="label" translatable="yes">Cancel</property>
|
||||
<signal name="clicked" handler="on_cancel_button_clicked_cb" object="GcalNewCalendarPage" swapped="no" />
|
||||
</object>
|
||||
<object class="GtkButton" id="add_button">
|
||||
<property name="label" translatable="yes">Add</property>
|
||||
<property name="sensitive">False</property>
|
||||
<signal name="clicked" handler="on_add_button_clicked_cb" object="GcalNewCalendarPage" swapped="no" />
|
||||
<style>
|
||||
<class name="suggested-action"/>
|
||||
</style>
|
||||
</object>
|
||||
</interface>
|
||||
|
||||
Reference in New Issue
Block a user