Commit ef833811 authored by Milan Crha's avatar Milan Crha

Add a WebDAV browser into the Account Editor

Users can create, edit or delete books, calendars or collections
on servers which support it.
parent 12647d21
......@@ -285,6 +285,7 @@ src/e-util/e-tree.c
src/e-util/e-tree-selection-model.c
src/e-util/e-url-entry.c
src/e-util/evolution-source-viewer.c
src/e-util/e-webdav-browser.c
src/e-util/e-web-view.c
src/e-util/e-widget-undo.c
src/e-util/filter.error.xml
......@@ -383,6 +384,7 @@ src/mail/message-list.etspec
src/mail/searchtypes.xml.in
src/mail/vfoldertypes.xml.in
src/modules/accounts-window/e-accounts-window-editors.c
src/modules/accounts-window/e-webdav-browser-page.c
src/modules/addressbook/autocompletion-config.c
src/modules/addressbook/eab-composer-util.c
src/modules/addressbook/e-book-shell-backend.c
......
......@@ -263,6 +263,7 @@ set(SOURCES
e-unicode.c
e-url-entry.c
e-util-private.h
e-webdav-browser.c
e-web-view-preview.c
e-web-view.c
e-widget-undo.c
......@@ -529,6 +530,7 @@ set(HEADERS
e-unicode.h
e-url-entry.h
e-util-enums.h
e-webdav-browser.h
e-web-view-preview.h
e-web-view.h
e-widget-undo.h
......
<?xml version="1.0"?>
<error-list domain="system">
<error type="error" id="generic-error">
<primary>{0}</primary>
<secondary>{1}</secondary>
</error>
<error id="simple-info" type="info">
<secondary>{0}</secondary>
......@@ -89,4 +93,12 @@
<_primary>Something has gone wrong</_primary>
<_secondary>A WebKitWebProcess crashed when displaying the content. You can try again by reopening the window. If the issue persists, please file a bug report in the GNOME bugzilla.</_secondary>
</error>
<error id="prompt-delete-remote-collection" type="question" default="GTK_RESPONSE_CANCEL">
<_primary>Are you sure you want to delete remote collection “{0}”?</_primary>
<_secondary>This will permanently remove the collection “{0}” from the server. Are you sure you want to proceed?</_secondary>
<button _label="Do _Not Delete" response="GTK_RESPONSE_CANCEL"/>
<button _label="_Delete From Server" response="GTK_RESPONSE_YES"/>
</error>
</error-list>
......@@ -258,6 +258,7 @@
#include <e-util/e-url-entry.h>
#include <e-util/e-util-enums.h>
#include <e-util/e-util-enumtypes.h>
#include <e-util/e-webdav-browser.h>
#ifndef E_UTIL_INCLUDE_WITHOUT_WEBKIT
#include <e-util/e-web-view-preview.h>
#include <e-util/e-web-view.h>
......
This diff is collapsed.
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2017 Red Hat, Inc. (www.redhat.com)
*
* This library is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation.
*
* This library 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 Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined (__E_UTIL_H_INSIDE__) && !defined (LIBEUTIL_COMPILATION)
#error "Only <e-util/e-util.h> should be included directly."
#endif
#ifndef E_WEBDAV_BROWSER_H
#define E_WEBDAV_BROWSER_H
#include <gtk/gtk.h>
#include <libedataserverui/libedataserverui.h>
/* Standard GObject macros */
#define E_TYPE_WEBDAV_BROWSER \
(e_webdav_browser_get_type ())
#define E_WEBDAV_BROWSER(obj) \
(G_TYPE_CHECK_INSTANCE_CAST \
((obj), E_TYPE_WEBDAV_BROWSER, EWebDAVBrowser))
#define E_WEBDAV_BROWSER_CLASS(cls) \
(G_TYPE_CHECK_CLASS_CAST \
((cls), E_TYPE_WEBDAV_BROWSER, EWebDAVBrowserClass))
#define E_IS_WEBDAV_BROWSER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE \
((obj), E_TYPE_WEBDAV_BROWSER))
#define E_IS_WEBDAV_BROWSER_CLASS(cls) \
(G_TYPE_CHECK_CLASS_TYPE \
((cls), E_TYPE_WEBDAV_BROWSER))
#define E_WEBDAV_BROWSER_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS \
((obj), E_TYPE_WEBDAV_BROWSER, EWebDAVBrowserClass))
G_BEGIN_DECLS
typedef struct _EWebDAVBrowser EWebDAVBrowser;
typedef struct _EWebDAVBrowserClass EWebDAVBrowserClass;
typedef struct _EWebDAVBrowserPrivate EWebDAVBrowserPrivate;
/**
* EWebDAVBrowser:
*
* Contains only private data that should be read and manipulated using
* the functions below.
*
* Since: 3.26
**/
struct _EWebDAVBrowser {
GtkGrid parent;
EWebDAVBrowserPrivate *priv;
};
struct _EWebDAVBrowserClass {
GtkGridClass parent_class;
};
GType e_webdav_browser_get_type (void) G_GNUC_CONST;
GtkWidget * e_webdav_browser_new (ECredentialsPrompter *credentials_prompter);
ECredentialsPrompter *
e_webdav_browser_get_credentials_prompter
(EWebDAVBrowser *webdav_browser);
void e_webdav_browser_set_source (EWebDAVBrowser *webdav_browser,
ESource *source);
ESource * e_webdav_browser_ref_source (EWebDAVBrowser *webdav_browser);
void e_webdav_browser_abort (EWebDAVBrowser *webdav_browser);
void e_webdav_browser_refresh (EWebDAVBrowser *webdav_browser);
G_END_DECLS
#endif /* E_WEBDAV_BROWSER_H */
......@@ -6,6 +6,8 @@ set(sources
accounts-window.c
e-accounts-window-editors.c
e-accounts-window-editors.h
e-webdav-browser-page.c
e-webdav-browser-page.h
)
set(extra_defines)
set(extra_cflags)
......
......@@ -21,6 +21,7 @@
#include <glib-object.h>
#include "e-accounts-window-editors.h"
#include "e-webdav-browser-page.h"
/* Module Entry Points */
void e_module_load (GTypeModule *type_module);
......@@ -30,6 +31,7 @@ G_MODULE_EXPORT void
e_module_load (GTypeModule *type_module)
{
e_accounts_window_editors_type_register (type_module);
e_webdav_browser_page_type_register (type_module);
}
G_MODULE_EXPORT void
......
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2017 Red Hat, Inc. (www.redhat.com)
*
* This library is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation.
*
* This library 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 Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "evolution-config.h"
#include <glib/gi18n-lib.h>
#include "e-util/e-util.h"
#include "shell/e-shell.h"
#include "e-webdav-browser-page.h"
/* Standard GObject macros */
#define E_TYPE_WEBDAV_BROWSER_PAGE \
(e_webdav_browser_page_get_type ())
#define E_WEBDAV_BROWSER_PAGE(obj) \
(G_TYPE_CHECK_INSTANCE_CAST \
((obj), E_TYPE_WEBDAV_BROWSER_PAGE, EWebDAVBrowserPage))
#define E_WEBDAV_BROWSER_PAGE_CLASS(cls) \
(G_TYPE_CHECK_CLASS_CAST \
((cls), E_TYPE_WEBDAV_BROWSER_PAGE, EWebDAVBrowserPageClass))
#define E_IS_WEBDAV_BROWSER_PAGE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE \
((obj), E_TYPE_WEBDAV_BROWSER_PAGE))
#define E_IS_WEBDAV_BROWSER_PAGE_CLASS(cls) \
(G_TYPE_CHECK_CLASS_TYPE \
((cls), E_TYPE_WEBDAV_BROWSER_PAGE))
#define E_WEBDAV_BROWSER_PAGE_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS \
((obj), E_TYPE_WEBDAV_BROWSER_PAGE, EWebDAVBrowserPageClass))
typedef struct _EWebDAVBrowserPage EWebDAVBrowserPage;
typedef struct _EWebDAVBrowserPageClass EWebDAVBrowserPageClass;
struct _EWebDAVBrowserPage {
EExtension parent;
GtkWidget *browse_button;
EWebDAVBrowser *webdav_browser;
gint page_index;
};
struct _EWebDAVBrowserPageClass {
EExtensionClass parent_class;
};
GType e_webdav_browser_page_get_type (void) G_GNUC_CONST;
G_DEFINE_DYNAMIC_TYPE (EWebDAVBrowserPage, e_webdav_browser_page, E_TYPE_EXTENSION)
static void
webdav_browser_page_selection_changed_cb (EAccountsWindow *accounts_window,
ESource *source,
gpointer user_data)
{
EWebDAVBrowserPage *page = user_data;
gboolean has_path = FALSE;
g_return_if_fail (E_IS_ACCOUNTS_WINDOW (accounts_window));
g_return_if_fail (E_IS_WEBDAV_BROWSER_PAGE (page));
if (source && e_source_has_extension (source, E_SOURCE_EXTENSION_WEBDAV_BACKEND)) {
gchar *path;
path = e_source_webdav_dup_resource_path (e_source_get_extension (source, E_SOURCE_EXTENSION_WEBDAV_BACKEND));
has_path = path && *path;
g_free (path);
}
gtk_widget_set_sensitive (page->browse_button, has_path);
}
static void
webdav_browser_page_browse_button_clicked_cb (GtkButton *button,
gpointer user_data)
{
EWebDAVBrowserPage *page = user_data;
EAccountsWindow *accounts_window;
ESource *source;
g_return_if_fail (E_IS_WEBDAV_BROWSER_PAGE (page));
accounts_window = E_ACCOUNTS_WINDOW (e_extension_get_extensible (E_EXTENSION (page)));
g_return_if_fail (E_IS_ACCOUNTS_WINDOW (accounts_window));
source = e_accounts_window_ref_selected_source (accounts_window);
g_return_if_fail (E_IS_SOURCE (source));
e_accounts_window_activate_page (accounts_window, page->page_index);
e_webdav_browser_set_source (page->webdav_browser, source);
g_object_unref (source);
}
static void
webdav_browser_back_button_clicked_cb (GtkButton *button,
gpointer user_data)
{
EWebDAVBrowserPage *page = user_data;
EAccountsWindow *accounts_window;
g_return_if_fail (E_IS_WEBDAV_BROWSER_PAGE (page));
accounts_window = E_ACCOUNTS_WINDOW (e_extension_get_extensible (E_EXTENSION (page)));
g_return_if_fail (E_IS_ACCOUNTS_WINDOW (accounts_window));
e_webdav_browser_abort (page->webdav_browser);
e_webdav_browser_set_source (page->webdav_browser, NULL);
e_accounts_window_activate_page (accounts_window, -1);
}
static void
webdav_browser_page_constructed (GObject *object)
{
EAccountsWindow *accounts_window;
ECredentialsPrompter *credentials_prompter;
EWebDAVBrowserPage *page;
EShell *shell;
GtkButtonBox *button_box;
GtkWidget *widget;
GtkWidget *vbox;
/* Chain up to parent's method. */
G_OBJECT_CLASS (e_webdav_browser_page_parent_class)->constructed (object);
page = E_WEBDAV_BROWSER_PAGE (object);
accounts_window = E_ACCOUNTS_WINDOW (e_extension_get_extensible (E_EXTENSION (page)));
g_signal_connect (accounts_window, "selection-changed",
G_CALLBACK (webdav_browser_page_selection_changed_cb), object);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_show (vbox);
shell = e_shell_get_default ();
/* Can be NULL in test-accounts-window */
if (shell) {
credentials_prompter = e_shell_get_credentials_prompter (shell);
g_object_ref (credentials_prompter);
} else {
credentials_prompter = e_credentials_prompter_new (e_accounts_window_get_registry (accounts_window));
}
widget = e_webdav_browser_new (credentials_prompter);
g_object_set (G_OBJECT (widget),
"hexpand", TRUE,
"halign", GTK_ALIGN_FILL,
"vexpand", TRUE,
"valign", GTK_ALIGN_FILL,
NULL);
gtk_widget_show (widget);
gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 0);
page->webdav_browser = E_WEBDAV_BROWSER (widget);
g_object_unref (credentials_prompter);
widget = e_dialog_button_new_with_icon ("go-previous", _("_Back"));
g_object_set (G_OBJECT (widget),
"hexpand", TRUE,
"halign", GTK_ALIGN_END,
"vexpand", FALSE,
"valign", GTK_ALIGN_START,
NULL);
gtk_widget_show (widget);
gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
g_signal_connect (widget, "clicked",
G_CALLBACK (webdav_browser_back_button_clicked_cb), page);
page->page_index = e_accounts_window_add_page (accounts_window, vbox);
button_box = e_accounts_window_get_button_box (accounts_window);
widget = gtk_label_new ("");
gtk_widget_show (widget);
gtk_box_pack_start (GTK_BOX (button_box), widget, FALSE, FALSE, 0);
widget = gtk_button_new_with_mnemonic (_("_Browse"));
gtk_widget_set_sensitive (widget, FALSE);
gtk_widget_set_tooltip_text (widget, _("Browse a WebDAV (CalDAV or CardDAV) server and create, edit or delete address books, calendars, memo lists or task lists there"));
gtk_widget_show (widget);
gtk_box_pack_start (GTK_BOX (button_box), widget, FALSE, FALSE, 0);
page->browse_button = widget;
g_signal_connect (widget, "clicked",
G_CALLBACK (webdav_browser_page_browse_button_clicked_cb), page);
}
static void
e_webdav_browser_page_class_init (EWebDAVBrowserPageClass *class)
{
GObjectClass *object_class;
EExtensionClass *extension_class;
object_class = G_OBJECT_CLASS (class);
object_class->constructed = webdav_browser_page_constructed;
extension_class = E_EXTENSION_CLASS (class);
extension_class->extensible_type = E_TYPE_ACCOUNTS_WINDOW;
}
static void
e_webdav_browser_page_class_finalize (EWebDAVBrowserPageClass *class)
{
}
static void
e_webdav_browser_page_init (EWebDAVBrowserPage *extension)
{
}
void
e_webdav_browser_page_type_register (GTypeModule *type_module)
{
/* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration
* function, so we have to wrap it with a public function in
* order to register types from a separate compilation unit. */
e_webdav_browser_page_register_type (type_module);
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2017 Red Hat, Inc. (www.redhat.com)
*
* This library is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation.
*
* This library 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 Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef E_WEBDAV_BROWSER_PAGE_H
#define E_WEBDAV_BROWSER_PAGE_H
#include <glib-object.h>
G_BEGIN_DECLS
void e_webdav_browser_page_type_register (GTypeModule *type_module);
G_END_DECLS
#endif /* E_WEBDAV_BROWSER_PAGE_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment