From f827b8a1f2227f44cc357b0c65eea98675204e0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Fortin=20Tam?= Date: Sat, 24 Feb 2024 17:29:52 -0500 Subject: [PATCH 1/5] Remove .ics file importer button in "New Calendar" A file imported as a "new calendar" would make it dependent on the file. This feature was confusing everybody and is downright dangerous. This does not prevent anyone from creating normal calendars, and importing events from .ics files into them. Fixes https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/390 --- .../gcal-new-calendar-page.c | 49 ------------------- .../gcal-new-calendar-page.ui | 24 --------- 2 files changed, 73 deletions(-) diff --git a/src/gui/calendar-management/gcal-new-calendar-page.c b/src/gui/calendar-management/gcal-new-calendar-page.c index fcd0283be..de1521a2a 100644 --- a/src/gui/calendar-management/gcal-new-calendar-page.c +++ b/src/gui/calendar-management/gcal-new-calendar-page.c @@ -27,7 +27,6 @@ #include "gcal-context.h" #include "gcal-calendar-management-page.h" #include "gcal-debug.h" -#include "gcal-file-chooser-button.h" #include "gcal-new-calendar-page.h" #include "gcal-source-discoverer.h" #include "gcal-utils.h" @@ -49,7 +48,6 @@ struct _GcalNewCalendarPage GtkWidget *add_button; GtkEntry *calendar_address_entry; EntryState calendar_address_entry_state; - GcalFileChooserButton *calendar_file_chooser_button; AdwMessageDialog *credentials_dialog; GtkEntry *credentials_password_entry; GtkEntry *credentials_user_entry; @@ -294,49 +292,6 @@ discover_sources (GcalNewCalendarPage *self) * Callbacks */ -static void -on_file_chooser_button_file_changed_cb (GcalFileChooserButton *chooser, - GParamSpec *pspec, - GcalNewCalendarPage *self) -{ - g_autofree gchar *display_name = NULL; - g_autoptr (ESource) source = NULL; - g_autoptr (GFile) file = NULL; - ESourceExtension *ext; - - GCAL_ENTRY; - - file = gcal_file_chooser_button_get_file (chooser); - - if (!file) - GCAL_RETURN (); - - /* Create the new source and add the needed extensions */ - source = e_source_new (NULL, NULL, NULL); - e_source_set_parent (source, "local-stub"); - - ext = e_source_get_extension (source, E_SOURCE_EXTENSION_CALENDAR); - e_source_backend_set_backend_name (E_SOURCE_BACKEND (ext), "local"); - - ext = e_source_get_extension (source, E_SOURCE_EXTENSION_LOCAL_BACKEND); - e_source_local_set_custom_file (E_SOURCE_LOCAL (ext), file); - - /* update the source properties */ - display_name = calendar_path_to_name_suggestion (file); - e_source_set_display_name (source, display_name); - - /* TODO: report errors */ - gcal_manager_save_source (gcal_context_get_manager (self->context), source); - - gcal_calendar_management_page_switch_page (GCAL_CALENDAR_MANAGEMENT_PAGE (self), - "calendars", - NULL); - - gcal_file_chooser_button_set_file (self->calendar_file_chooser_button, NULL); - - GCAL_EXIT; -} - static gboolean pulse_web_entry (gpointer data) { @@ -667,13 +622,10 @@ gcal_new_calendar_page_class_init (GcalNewCalendarPageClass *klass) g_object_class_override_property (object_class, PROP_CONTEXT, "context"); - g_type_ensure (GCAL_TYPE_FILE_CHOOSER_BUTTON); - gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/ui/gui/calendar-management/gcal-new-calendar-page.ui"); 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, credentials_dialog); gtk_widget_class_bind_template_child (widget_class, GcalNewCalendarPage, credentials_password_entry); gtk_widget_class_bind_template_child (widget_class, GcalNewCalendarPage, credentials_user_entry); @@ -685,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_credentials_dialog_response_cb); - gtk_widget_class_bind_template_callback (widget_class, on_file_chooser_button_file_changed_cb); gtk_widget_class_bind_template_callback (widget_class, on_local_calendar_name_row_text_changed_cb); gtk_widget_class_bind_template_callback (widget_class, on_local_calendar_color_button_rgba_changed_cb); gtk_widget_class_bind_template_callback (widget_class, on_url_entry_text_changed_cb); diff --git a/src/gui/calendar-management/gcal-new-calendar-page.ui b/src/gui/calendar-management/gcal-new-calendar-page.ui index b951c4dfd..3233d8e04 100644 --- a/src/gui/calendar-management/gcal-new-calendar-page.ui +++ b/src/gui/calendar-management/gcal-new-calendar-page.ui @@ -103,30 +103,6 @@ - - - - Open a File - - - Calendar files - - *.ical - *.icalendar - *.ics - *.ifb - *.vcs - - - - - - 1 - 1 - - - - slide-down -- GitLab From a74ae36e6ce58d59e2d1939e9f0cb3be6d338005 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Fortin=20Tam?= Date: Fri, 16 Aug 2024 19:54:03 -0400 Subject: [PATCH 2/5] Remove gcal-file-chooser-button code As it is no longer used in the calendar management dialog, and it was not used anywhere else in the codebase, it can now be dropped entirely. --- po/POTFILES.in | 1 - .../gcal-file-chooser-button.c | 271 ------------------ .../gcal-file-chooser-button.h | 45 --- src/gui/calendar-management/meson.build | 1 - 4 files changed, 318 deletions(-) delete mode 100644 src/gui/calendar-management/gcal-file-chooser-button.c delete mode 100644 src/gui/calendar-management/gcal-file-chooser-button.h diff --git a/po/POTFILES.in b/po/POTFILES.in index 081a89216..6d7f2ef87 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -11,7 +11,6 @@ src/gui/calendar-management/gcal-calendars-page.c src/gui/calendar-management/gcal-calendars-page.ui src/gui/calendar-management/gcal-edit-calendar-page.c src/gui/calendar-management/gcal-edit-calendar-page.ui -src/gui/calendar-management/gcal-file-chooser-button.c src/gui/calendar-management/gcal-new-calendar-page.c src/gui/calendar-management/gcal-new-calendar-page.ui src/gui/event-editor/gcal-alarm-row.c diff --git a/src/gui/calendar-management/gcal-file-chooser-button.c b/src/gui/calendar-management/gcal-file-chooser-button.c deleted file mode 100644 index 9a3b15bfc..000000000 --- a/src/gui/calendar-management/gcal-file-chooser-button.c +++ /dev/null @@ -1,271 +0,0 @@ -/* gcal-file-chooser-button.c - * - * Copyright 2021 Georges Basile Stavracas Neto - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -#include "gcal-file-chooser-button.h" - -#include - -struct _GcalFileChooserButton -{ - GtkButton parent_instance; - - GCancellable *cancellable; - GtkFileFilter *filter; - GFile *file; - gchar *title; -}; - -G_DEFINE_FINAL_TYPE (GcalFileChooserButton, gcal_file_chooser_button, GTK_TYPE_BUTTON) - -enum -{ - PROP_0, - PROP_FILE, - PROP_FILTER, - PROP_TITLE, - N_PROPS -}; - -static GParamSpec *properties [N_PROPS] = { NULL, }; - -static const gchar * -get_title (GcalFileChooserButton *self) -{ - return self->title ? self->title : _("Select a file"); -} - -static void -update_label (GcalFileChooserButton *self) -{ - g_autofree gchar *label = NULL; - - if (self->file) - label = g_file_get_basename (self->file); - else - label = g_strdup (get_title (self)); - - gtk_button_set_label (GTK_BUTTON (self), label); -} - -static void -on_file_opened_cb (GObject *source, - GAsyncResult *result, - gpointer user_data) -{ - GcalFileChooserButton *self; - g_autoptr (GError) error = NULL; - g_autoptr (GFile) file = NULL; - - file = gtk_file_dialog_open_finish (GTK_FILE_DIALOG (source), result, &error); - - if (error) - { - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - return; - - g_warning ("Error opening file: %s", error->message); - } - - self = GCAL_FILE_CHOOSER_BUTTON (user_data); - gcal_file_chooser_button_set_file (self, file); -} - -static void -gcal_file_chooser_button_clicked (GtkButton *button) -{ - g_autoptr (GtkFileDialog) file_dialog = NULL; - GcalFileChooserButton *self; - GtkRoot *root; - - self = GCAL_FILE_CHOOSER_BUTTON (button); - root = gtk_widget_get_root (GTK_WIDGET (self)); - - file_dialog = gtk_file_dialog_new (); - gtk_file_dialog_set_initial_file (file_dialog, self->file); - gtk_file_dialog_set_default_filter (file_dialog, self->filter); - - gtk_file_dialog_open (file_dialog, - GTK_WINDOW (root), - self->cancellable, - on_file_opened_cb, - self); -} - -static void -gcal_file_chooser_button_finalize (GObject *object) -{ - GcalFileChooserButton *self = (GcalFileChooserButton *)object; - - g_cancellable_cancel (self->cancellable); - - g_clear_pointer (&self->title, g_free); - g_clear_object (&self->cancellable); - g_clear_object (&self->filter); - g_clear_object (&self->file); - - G_OBJECT_CLASS (gcal_file_chooser_button_parent_class)->finalize (object); -} - -static void -gcal_file_chooser_button_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GcalFileChooserButton *self = GCAL_FILE_CHOOSER_BUTTON (object); - - switch (prop_id) - { - case PROP_FILE: - g_value_set_object (value, self->file); - break; - - case PROP_FILTER: - g_value_set_object (value, self->filter); - break; - - case PROP_TITLE: - g_value_set_string (value, self->title); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - } -} - -static void -gcal_file_chooser_button_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GcalFileChooserButton *self = GCAL_FILE_CHOOSER_BUTTON (object); - - switch (prop_id) - { - case PROP_FILE: - gcal_file_chooser_button_set_file (self, g_value_get_object (value)); - break; - - case PROP_FILTER: - gcal_file_chooser_button_set_filter (self, g_value_get_object (value)); - break; - - case PROP_TITLE: - gcal_file_chooser_button_set_title (self, g_value_get_string (value)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - } -} - -static void -gcal_file_chooser_button_class_init (GcalFileChooserButtonClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkButtonClass *button_class = GTK_BUTTON_CLASS (klass); - - button_class->clicked = gcal_file_chooser_button_clicked; - - object_class->finalize = gcal_file_chooser_button_finalize; - object_class->get_property = gcal_file_chooser_button_get_property; - object_class->set_property = gcal_file_chooser_button_set_property; - - properties[PROP_FILE] = g_param_spec_object ("file", "", "", - G_TYPE_FILE, - G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS); - properties[PROP_FILTER] = g_param_spec_object ("filter", "", "", - GTK_TYPE_FILE_FILTER, - G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS); - properties[PROP_TITLE] = g_param_spec_string ("title", "", "", NULL, - G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS); - g_object_class_install_properties (object_class, N_PROPS, properties); -} - -static void -gcal_file_chooser_button_init (GcalFileChooserButton *self) -{ - self->cancellable = g_cancellable_new (); - - update_label (self); -} - -GtkWidget* -gcal_file_chooser_button_new (void) -{ - return g_object_new (GCAL_TYPE_FILE_CHOOSER_BUTTON, NULL); -} - -void -gcal_file_chooser_button_set_file (GcalFileChooserButton *self, - GFile *file) -{ - g_return_if_fail (GCAL_IS_FILE_CHOOSER_BUTTON (self)); - - if (g_set_object (&self->file, file)) - { - update_label (self); - g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FILE]); - } -} - -GFile * -gcal_file_chooser_button_get_file (GcalFileChooserButton *self) -{ - g_return_val_if_fail (GCAL_IS_FILE_CHOOSER_BUTTON (self), NULL); - - return self->file ? g_object_ref (self->file) : NULL; -} - -void -gcal_file_chooser_button_set_title (GcalFileChooserButton *self, - const gchar *title) -{ - g_autofree gchar *old_title = NULL; - - g_return_if_fail (GCAL_IS_FILE_CHOOSER_BUTTON (self)); - - old_title = g_steal_pointer (&self->title); - self->title = g_strdup (title); - - update_label (self); - - g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TITLE]); -} - -const gchar* -gcal_file_chooser_button_get_title (GcalFileChooserButton *self) -{ - g_return_val_if_fail (GCAL_IS_FILE_CHOOSER_BUTTON (self), NULL); - - return self->title; -} - -void -gcal_file_chooser_button_set_filter (GcalFileChooserButton *self, - GtkFileFilter *filter) -{ - g_return_if_fail (GCAL_IS_FILE_CHOOSER_BUTTON (self)); - g_return_if_fail (filter == NULL || GTK_IS_FILE_FILTER (filter)); - - if (g_set_object (&self->filter, filter)) - g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FILTER]); -} diff --git a/src/gui/calendar-management/gcal-file-chooser-button.h b/src/gui/calendar-management/gcal-file-chooser-button.h deleted file mode 100644 index 103dc3586..000000000 --- a/src/gui/calendar-management/gcal-file-chooser-button.h +++ /dev/null @@ -1,45 +0,0 @@ -/* gcal-file-chooser-button.h - * - * Copyright 2021 Georges Basile Stavracas Neto - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -#pragma once - -#include - -G_BEGIN_DECLS - -#define GCAL_TYPE_FILE_CHOOSER_BUTTON (gcal_file_chooser_button_get_type()) -G_DECLARE_FINAL_TYPE (GcalFileChooserButton, gcal_file_chooser_button, GCAL, FILE_CHOOSER_BUTTON, GtkButton) - -GtkWidget* gcal_file_chooser_button_new (void); - -void gcal_file_chooser_button_set_file (GcalFileChooserButton *self, - GFile *file); - -GFile* gcal_file_chooser_button_get_file (GcalFileChooserButton *self); - -void gcal_file_chooser_button_set_title (GcalFileChooserButton *self, - const char *title); - -const gchar* gcal_file_chooser_button_get_title (GcalFileChooserButton *self); - -void gcal_file_chooser_button_set_filter (GcalFileChooserButton *self, - GtkFileFilter *filter); - -G_END_DECLS diff --git a/src/gui/calendar-management/meson.build b/src/gui/calendar-management/meson.build index d4f928495..d8c51c400 100644 --- a/src/gui/calendar-management/meson.build +++ b/src/gui/calendar-management/meson.build @@ -11,6 +11,5 @@ sources += files( 'gcal-calendar-management-page.c', 'gcal-calendars-page.c', 'gcal-edit-calendar-page.c', - 'gcal-file-chooser-button.c', 'gcal-new-calendar-page.c', ) -- GitLab From 126929b8c504e7454187e5ad705b52ee84a79965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Fortin=20Tam?= Date: Sat, 24 Feb 2024 17:37:14 -0500 Subject: [PATCH 3/5] new-calendar: Clarify web calendar strings Now that the "Open" button has been removed, it is now a feature to "Connect" rather than "Import", so update the section title to reflect that. Also give a hint as to what protocols are supported. --- src/gui/calendar-management/gcal-new-calendar-page.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/calendar-management/gcal-new-calendar-page.ui b/src/gui/calendar-management/gcal-new-calendar-page.ui index 3233d8e04..910cbd8da 100644 --- a/src/gui/calendar-management/gcal-new-calendar-page.ui +++ b/src/gui/calendar-management/gcal-new-calendar-page.ui @@ -60,7 +60,7 @@ True - Import a Calendar + Connect to an Online Calendar 0.0 @@ -77,7 +77,7 @@ - Alternatively, enter the web address of an online calendar you want to import, or open a supported calendar file. + HTTPS, CalDAV, or Webcal URLs are supported. Online calendars that can only be updated by the provider will be added as read-only. True 0 -- GitLab From 29396acf467f7b25870626434dde0bc7d10fc560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Fortin=20Tam?= Date: Thu, 22 Feb 2024 09:58:07 -0500 Subject: [PATCH 4/5] new-calendar: Use "title" in AdwPreferencesGroup Replace the manually positioned & styled group label by a property This simplifies the XML code, makes the style match the rest of the UI, and prevents libadwaita from sometimes moving such labels to the bottom. --- .../calendar-management/gcal-new-calendar-page.ui | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/gui/calendar-management/gcal-new-calendar-page.ui b/src/gui/calendar-management/gcal-new-calendar-page.ui index 910cbd8da..c06992088 100644 --- a/src/gui/calendar-management/gcal-new-calendar-page.ui +++ b/src/gui/calendar-management/gcal-new-calendar-page.ui @@ -56,18 +56,7 @@ - - - - True - Connect to an Online Calendar - 0.0 - - - - - - + Connect to an Online Calendar -- GitLab From fb5b03b2dfc4ca33fb42c080f7252ebfc8c4c534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Fortin=20Tam?= Date: Thu, 22 Feb 2024 10:05:58 -0500 Subject: [PATCH 5/5] new-calendar: Title the local calendar group In practice, the name and color widgets are currently meant to be used when creating a local calendar, not when subscribing online, especially as a single online calendar link can bundle multiple calendars. This makes the scope of those widgets clearer, and also makes the dialog more balanced. Related: https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/566 --- src/gui/calendar-management/gcal-new-calendar-page.ui | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/calendar-management/gcal-new-calendar-page.ui b/src/gui/calendar-management/gcal-new-calendar-page.ui index c06992088..391655329 100644 --- a/src/gui/calendar-management/gcal-new-calendar-page.ui +++ b/src/gui/calendar-management/gcal-new-calendar-page.ui @@ -20,6 +20,7 @@ + Create a Local Calendar -- GitLab