window: Create calendar-management-dialog on demand
When the user deletes a calendar in the calendar management dialog, a popover allows them to undo the deletion. The calendar is fully deleted only when the toast is dismissed or when the toast reaches its timeout. When the user closes the calendar management dialog without dismissing the toast and before the end of the timeout, the calendar can still be manipulated for a short period of time. To fix this, I removed the calendar-management-dialog from the UI of the window, and made the window create and destroy the dialog on demand. This forces the toast overlay to dismiss all toasts.
This commit is contained in:
committed by
Georges Basile Stavracas Neto
parent
e23ca8422c
commit
0e09efc43c
@@ -253,7 +253,7 @@ gcal_calendar_management_dialog_class_init (GcalCalendarManagementDialogClass *k
|
||||
"Context",
|
||||
"The context object of the application",
|
||||
GCAL_TYPE_CONTEXT,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||
|
||||
@@ -269,3 +269,13 @@ gcal_calendar_management_dialog_init (GcalCalendarManagementDialog *self)
|
||||
{
|
||||
gtk_widget_init_template (GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
/*
|
||||
* Public API
|
||||
*/
|
||||
|
||||
GcalCalendarManagementDialog*
|
||||
gcal_calendar_management_dialog_new (GcalContext *context)
|
||||
{
|
||||
return g_object_new (GCAL_TYPE_CALENDAR_MANAGEMENT_DIALOG, "context", context, NULL);
|
||||
}
|
||||
|
||||
@@ -36,4 +36,7 @@ G_DECLARE_FINAL_TYPE (GcalCalendarManagementDialog,
|
||||
GCAL, CALENDAR_MANAGEMENT_DIALOG,
|
||||
AdwDialog)
|
||||
|
||||
GcalCalendarManagementDialog* gcal_calendar_management_dialog_new (GcalContext *context);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
@@ -146,9 +146,6 @@ struct _GcalWindow
|
||||
|
||||
AdwToast *delete_event_toast;
|
||||
|
||||
/* calendar management */
|
||||
GtkWidget *calendar_management_dialog;
|
||||
|
||||
gint open_edit_dialog_timeout_id;
|
||||
|
||||
/* weather management */
|
||||
@@ -442,8 +439,9 @@ on_show_calendars_action_activated (GSimpleAction *action,
|
||||
gpointer user_data)
|
||||
{
|
||||
GcalWindow *self = GCAL_WINDOW (user_data);
|
||||
GcalCalendarManagementDialog *dialog = gcal_calendar_management_dialog_new (self->context);
|
||||
|
||||
adw_dialog_present (ADW_DIALOG (self->calendar_management_dialog), GTK_WIDGET (self));
|
||||
adw_dialog_present (ADW_DIALOG (dialog), GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1062,7 +1060,6 @@ gcal_window_constructed (GObject *object)
|
||||
*/
|
||||
g_object_bind_property (self, "context", self->calendars_button, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
|
||||
g_object_bind_property (self, "context", self->weather_settings, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
|
||||
g_object_bind_property (self, "context", self->calendar_management_dialog, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
|
||||
g_object_bind_property (self, "context", self->week_view, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
|
||||
g_object_bind_property (self, "context", self->month_view, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
|
||||
g_object_bind_property (self, "context", self->agenda_view, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
|
||||
@@ -1197,7 +1194,6 @@ gcal_window_class_init (GcalWindowClass *klass)
|
||||
GtkWidgetClass *widget_class;
|
||||
|
||||
g_type_ensure (GCAL_TYPE_AGENDA_VIEW);
|
||||
g_type_ensure (GCAL_TYPE_CALENDAR_MANAGEMENT_DIALOG);
|
||||
g_type_ensure (GCAL_TYPE_CALENDAR_BUTTON);
|
||||
g_type_ensure (GCAL_TYPE_DATE_CHOOSER);
|
||||
g_type_ensure (GCAL_TYPE_EVENT_EDITOR_DIALOG);
|
||||
@@ -1261,7 +1257,6 @@ gcal_window_class_init (GcalWindowClass *klass)
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, month_view);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, action_bar);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, quick_add_popover);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, calendar_management_dialog);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, overlay);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, sidebar_toolbar_end);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, split_view);
|
||||
|
||||
@@ -337,8 +337,6 @@
|
||||
<signal name="closed" handler="close_new_event_widget" object="GcalWindow" swapped="no"/>
|
||||
</object>
|
||||
|
||||
<object class="GcalCalendarManagementDialog" id="calendar_management_dialog" />
|
||||
|
||||
<object class="GcalEventEditorDialog" id="event_editor">
|
||||
<signal name="remove-event" handler="on_event_editor_dialog_remove_event_cb" object="GcalWindow" swapped="no"/>
|
||||
</object>
|
||||
|
||||
Reference in New Issue
Block a user