WebDAVNotes: Let the user choose which extension is used for new notes

Rather than forcing .txt or .md extension in the code, let the user choose
which one is preferred. Still default to the .md extension.

Related to https://gitlab.gnome.org/GNOME/evolution-data-server/-/issues/360
This commit is contained in:
Milan Crha
2021-12-01 18:03:33 +01:00
parent d07c024ba2
commit b5e6e16477

View File

@ -274,8 +274,9 @@ cal_config_webdav_notes_insert_widgets (ESourceConfigBackend *backend,
ESourceConfig *config; ESourceConfig *config;
ESource *collection_source; ESource *collection_source;
ESourceExtension *extension; ESourceExtension *extension;
ESourceWebDAVNotes *notes_extension;
ECalClientSourceType source_type; ECalClientSourceType source_type;
GtkWidget *widget; GtkWidget *widget, *container;
Context *context; Context *context;
const gchar *extension_name; const gchar *extension_name;
const gchar *label; const gchar *label;
@ -347,6 +348,39 @@ cal_config_webdav_notes_insert_widgets (ESourceConfigBackend *backend,
e_source_config_add_refresh_interval (config, scratch_source); e_source_config_add_refresh_interval (config, scratch_source);
notes_extension = e_source_get_extension (scratch_source, E_SOURCE_EXTENSION_WEBDAV_NOTES);
widget = gtk_alignment_new (0.0, 0.5, 0.0, 0.0);
e_source_config_insert_widget (config, scratch_source, NULL, widget);
gtk_widget_show (widget);
container = widget;
widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_container_add (GTK_CONTAINER (container), widget);
gtk_widget_show (widget);
container = widget;
widget = gtk_label_new (_("File extension for new notes:"));
gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
gtk_widget_show (widget);
widget = gtk_combo_box_text_new ();
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (widget), ".md", ".md");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (widget), ".txt", ".txt");
gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
gtk_widget_show (widget);
e_binding_bind_property (
notes_extension, "default-ext",
widget, "active-id",
G_BINDING_BIDIRECTIONAL |
G_BINDING_SYNC_CREATE);
if (gtk_combo_box_get_active (GTK_COMBO_BOX (widget)) == -1)
gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
extension_name = E_SOURCE_EXTENSION_WEBDAV_BACKEND; extension_name = E_SOURCE_EXTENSION_WEBDAV_BACKEND;
extension = e_source_get_extension (scratch_source, extension_name); extension = e_source_get_extension (scratch_source, extension_name);