[evolution/wip/webkit-composer: 26/262] Make the URL editor work



commit c412f162b0daf95717f3299d52e6668079a15ad6
Author: Dan Vrátil <dvratil redhat com>
Date:   Tue Aug 7 10:49:39 2012 +0200

    Make the URL editor work
    
    The URL dialog has been moved to EEditorURLPropertiesDialog class where
    all the functionality is implemented. The functionality was also extended
    by adding 'Remove link' button, which unlinks selected content.

 e-util/Makefile.am                      |    4 +
 e-util/e-editor-actions.c               |   42 +---
 e-util/e-editor-private.h               |    2 +
 e-util/e-editor-selection.c             |   42 ++--
 e-util/e-editor-selection.h             |    5 +
 e-util/e-editor-url-properties-dialog.c |  393 +++++++++++++++++++++++++++++++
 e-util/e-editor-url-properties-dialog.h |   70 ++++++
 e-util/e-editor-utils.c                 |   39 +++
 e-util/e-editor-utils.h                 |   32 +++
 e-util/e-util.h                         |    2 +
 10 files changed, 586 insertions(+), 45 deletions(-)
---
diff --git a/e-util/Makefile.am b/e-util/Makefile.am
index fc60456..dd8fa7e 100644
--- a/e-util/Makefile.am
+++ b/e-util/Makefile.am
@@ -181,6 +181,8 @@ evolution_util_include_HEADERS =  \
        e-editor-find-dialog.h \
        e-editor-replace-dialog.h \
        e-editor-selection.h \
+       e-editor-url-properties-dialog.h \
+       e-editor-utils.h \
        e-editor-widget.h \
        e-editor-widgets.h \
        e-editor.h \
@@ -442,6 +444,8 @@ libevolution_util_la_SOURCES = \
        e-editor-private.h \
        e-editor-replace-dialog.c \
        e-editor-selection.c \
+       e-editor-url-properties-dialog.c \
+       e-editor-utils.c \
        e-editor-widget.c \
        e-editor.c \
        e-emoticon-action.c \
diff --git a/e-util/e-editor-actions.c b/e-util/e-editor-actions.c
index f7737d4..b53db85 100644
--- a/e-util/e-editor-actions.c
+++ b/e-util/e-editor-actions.c
@@ -673,8 +673,12 @@ static void
 action_insert_link_cb (GtkAction *action,
                        EEditor *editor)
 {
-       /* FIXME WEBKIT */
-       gtk_window_present (GTK_WINDOW (WIDGET (LINK_PROPERTIES_WINDOW)));
+       if (editor->priv->url_properties_dialog == NULL) {
+               editor->priv->url_properties_dialog =
+                       e_editor_url_properties_dialog_new (editor);
+       }
+
+       gtk_window_present (GTK_WINDOW (editor->priv->url_properties_dialog));
 }
 
 static void
@@ -965,7 +969,12 @@ static void
 action_properties_link_cb (GtkAction *action,
                            EEditor *editor)
 {
-       gtk_window_present (GTK_WINDOW (WIDGET (LINK_PROPERTIES_WINDOW)));
+       if (editor->priv->url_properties_dialog == NULL) {
+               editor->priv->url_properties_dialog =
+                       e_editor_url_properties_dialog_new (editor);
+       }
+
+       gtk_window_present (GTK_WINDOW (editor->priv->url_properties_dialog));
 }
 
 static void
@@ -1078,26 +1087,6 @@ action_spell_check_cb (GtkAction *action,
 }
 
 static void
-action_test_url_cb (GtkAction *action,
-                    EEditor *editor)
-{
-       /* FIXME WEBKIT What does this do? */
-       /*
-       GtkEntry *entry;
-       GtkWindow *window;
-       const gchar *text;
-
-       entry = GTK_ENTRY (WIDGET (LINK_PROPERTIES_URL_ENTRY));
-       window = GTK_WINDOW (WIDGET (LINK_PROPERTIES_WINDOW));
-
-       text = gtk_entry_get_text (entry);
-
-       if (text != NULL && *text != '\0')
-               gtkhtml_editor_show_uri (window, text);
-       */
-}
-
-static void
 action_undo_cb (GtkAction *action,
                 EEditor *editor)
 {
@@ -1221,13 +1210,6 @@ static GtkActionEntry core_entries[] = {
          NULL,
          G_CALLBACK (action_spell_check_cb) },
 
-       { "test-url",
-         NULL,
-         N_("_Test URL..."),
-         NULL,
-         NULL,
-         G_CALLBACK (action_test_url_cb) },
-
        { "undo",
          GTK_STOCK_UNDO,
          N_("_Undo"),
diff --git a/e-util/e-editor-private.h b/e-util/e-editor-private.h
index c736add..25df5ef 100644
--- a/e-util/e-editor-private.h
+++ b/e-util/e-editor-private.h
@@ -26,6 +26,7 @@
 #include <e-editor-widget.h>
 #include <e-editor-find-dialog.h>
 #include <e-editor-replace-dialog.h>
+#include <e-editor-url-properties-dialog.h>
 
 #ifdef HAVE_XFREE
 #include <X11/XF86keysym.h>
@@ -56,6 +57,7 @@ struct _EEditorPrivate {
 
        GtkWidget *find_dialog;
        GtkWidget *replace_dialog;
+       GtkWidget *url_properties_dialog;
 
        GtkWidget *color_combo_box;
        GtkWidget *mode_combo_box;
diff --git a/e-util/e-editor-selection.c b/e-util/e-editor-selection.c
index 73f144d..a9ee54d 100644
--- a/e-util/e-editor-selection.c
+++ b/e-util/e-editor-selection.c
@@ -22,6 +22,7 @@
 
 #include "e-editor-selection.h"
 #include "e-editor.h"
+#include "e-editor-utils.h"
 
 #include <e-util/e-util.h>
 
@@ -73,20 +74,6 @@ enum {
 
 static const GdkRGBA black = { 0 };
 
-static WebKitDOMElement *
-find_parent_element_by_type (WebKitDOMNode *node, GType type)
-{
-       while (node) {
-
-               if (G_TYPE_CHECK_INSTANCE_TYPE (node, type))
-                       return (WebKitDOMElement *) node;
-
-               node = (WebKitDOMNode *) webkit_dom_node_get_parent_element (node);
-       }
-
-       return NULL;
-}
-
 static WebKitDOMRange *
 editor_selection_get_current_range (EEditorSelection *selection)
 {
@@ -164,7 +151,7 @@ get_font_property (EEditorSelection *selection,
        }
 
        node = webkit_dom_range_get_common_ancestor_container (range, NULL);
-       element = find_parent_element_by_type (
+       element = e_editor_dom_node_get_parent_element (
                        node, WEBKIT_TYPE_DOM_HTML_FONT_ELEMENT);
        if (!element) {
                return NULL;
@@ -1233,6 +1220,31 @@ e_editor_selection_set_underline (EEditorSelection *selection,
 }
 
 void
+e_editor_selection_unlink (EEditorSelection *selection)
+{
+       WebKitDOMDocument *document;
+
+       g_return_if_fail (E_IS_EDITOR_SELECTION (selection));
+
+       document = webkit_web_view_get_dom_document (selection->priv->webview);
+       webkit_dom_document_exec_command (document, "unlink", FALSE, "");
+}
+
+void
+e_editor_selection_create_link (EEditorSelection *selection,
+                               const gchar *uri)
+{
+       WebKitDOMDocument *document;
+
+       g_return_if_fail (E_IS_EDITOR_SELECTION (selection));
+       g_return_if_fail (uri && *uri);
+
+       document = webkit_web_view_get_dom_document (selection->priv->webview);
+       webkit_dom_document_exec_command (document, "createLink", FALSE, uri);
+}
+
+
+void
 e_editor_selection_insert_text (EEditorSelection *selection,
                                const gchar *plain_text)
 {
diff --git a/e-util/e-editor-selection.h b/e-util/e-editor-selection.h
index eab701e..a444f5f 100644
--- a/e-util/e-editor-selection.h
+++ b/e-util/e-editor-selection.h
@@ -180,6 +180,11 @@ void                       e_editor_selection_set_underline
 gboolean               e_editor_selection_get_underline
                                                        (EEditorSelection *selection);
 
+void                   e_editor_selection_unlink       (EEditorSelection *selection);
+
+void                   e_editor_selection_create_link  (EEditorSelection *selection,
+                                                        const gchar *uri);
+
 const gchar *          e_editor_selection_get_string   (EEditorSelection *selection);
 
 void                   e_editor_selection_replace      (EEditorSelection *selection,
diff --git a/e-util/e-editor-url-properties-dialog.c b/e-util/e-editor-url-properties-dialog.c
new file mode 100644
index 0000000..40096b1
--- /dev/null
+++ b/e-util/e-editor-url-properties-dialog.c
@@ -0,0 +1,393 @@
+/*
+ * e-editor-url-properties-dialog.h
+ *
+ * This program 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; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "e-editor-url-properties-dialog.h"
+#include "e-editor-selection.h"
+#include "e-editor-utils.h"
+
+#include <glib/gi18n-lib.h>
+
+G_DEFINE_TYPE (
+       EEditorUrlPropertiesDialog,
+       e_editor_url_properties_dialog,
+       GTK_TYPE_WINDOW);
+
+struct _EEditorUrlPropertiesDialogPrivate {
+       EEditor *editor;
+
+       GtkWidget *url_edit;
+       GtkWidget *label_edit;
+       GtkWidget *test_button;
+
+       GtkWidget *remove_link_button;
+       GtkWidget *close_button;
+       GtkWidget *ok_button;
+};
+
+enum {
+       PROP_0,
+       PROP_EDITOR
+};
+
+static WebKitDOMElement *
+find_anchor_element (WebKitDOMRange *range)
+{
+       WebKitDOMElement *link;
+       WebKitDOMNode *node;
+
+       node = webkit_dom_range_get_start_container (range, NULL);
+
+       /* Try to find if the selection is within a link */
+       link = NULL;
+       link = e_editor_dom_node_get_parent_element (
+                       node, WEBKIT_TYPE_DOM_HTML_ANCHOR_ELEMENT);
+
+       /* ...or if there is a link within selection */
+       if (!link) {
+               WebKitDOMNode *start_node = node;
+               gboolean found = FALSE;
+               do {
+                       if (WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT (node)) {
+                               found = TRUE;
+                               break;
+                       }
+
+                       if (webkit_dom_node_has_child_nodes (node)) {
+                               node = webkit_dom_node_get_first_child (node);
+                       } else if (webkit_dom_node_get_next_sibling (node)) {
+                               node = webkit_dom_node_get_next_sibling (node);
+                       } else {
+                               node = webkit_dom_node_get_parent_node (node);
+                       }
+               } while (!webkit_dom_node_is_same_node (node, start_node));
+
+               if (found) {
+                       link = WEBKIT_DOM_ELEMENT (node);
+               }
+       }
+
+       return link;
+}
+
+
+static void
+editor_url_properties_dialog_test_url (EEditorUrlPropertiesDialog *dialog)
+{
+       gtk_show_uri (
+               gtk_window_get_screen (GTK_WINDOW (dialog)),
+               gtk_entry_get_text (GTK_ENTRY (dialog->priv->url_edit)),
+               GDK_CURRENT_TIME,
+               NULL);
+}
+
+static void
+editor_url_properties_dialog_close (EEditorUrlPropertiesDialog *dialog)
+{
+       gtk_widget_hide (GTK_WIDGET (dialog));
+}
+
+static void
+editor_url_properties_dialog_remove_link (EEditorUrlPropertiesDialog *dialog)
+{
+       EEditorSelection *selection;
+       EEditorWidget *widget;
+
+       widget = e_editor_get_editor_widget (dialog->priv->editor);
+       selection = e_editor_widget_get_selection (widget);
+       e_editor_selection_unlink (selection);
+
+       editor_url_properties_dialog_close (dialog);
+}
+
+static void
+editor_url_properties_dialog_ok (EEditorUrlPropertiesDialog *dialog)
+{
+       EEditorWidget *widget;
+       EEditorSelection *selection;
+       WebKitDOMDocument *document;
+       WebKitDOMDOMWindow *window;
+       WebKitDOMDOMSelection *dom_selection;
+       WebKitDOMRange *range;
+       WebKitDOMElement *link;
+
+       widget = e_editor_get_editor_widget (dialog->priv->editor);
+       selection = e_editor_widget_get_selection (widget);
+
+       document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (widget));
+       window = webkit_dom_document_get_default_view (document);
+       dom_selection = webkit_dom_dom_window_get_selection (window);
+
+       if (!dom_selection ||
+           (webkit_dom_dom_selection_get_range_count (dom_selection) == 0)) {
+               return;
+       }
+
+       range = webkit_dom_dom_selection_get_range_at (dom_selection, 0, NULL);
+       link = find_anchor_element (range);
+
+       if (link) {
+               webkit_dom_html_anchor_element_set_href (
+                       WEBKIT_DOM_HTML_ANCHOR_ELEMENT (link),
+                       gtk_entry_get_text (GTK_ENTRY (dialog->priv->url_edit)));
+       } else {
+               gchar *text;
+
+               /* Check whether a text is selected or not */
+               text = webkit_dom_range_get_text (range);
+               if (text && *text) {
+                       e_editor_selection_create_link (
+                               selection,
+                               gtk_entry_get_text (
+                                       GTK_ENTRY (dialog->priv->url_edit)));
+               } else {
+                       gchar *html = g_strdup_printf (
+                               "<a href=\"%s\">%s</a>",
+                               gtk_entry_get_text (
+                                       GTK_ENTRY (dialog->priv->url_edit)),
+                               gtk_entry_get_text (
+                                       GTK_ENTRY (dialog->priv->label_edit)));
+
+                       webkit_dom_document_exec_command (
+                               document, "insertHTML", FALSE, html);
+
+                       g_free (html);
+
+               }
+
+               g_free (text);
+       }
+
+       editor_url_properties_dialog_close (dialog);
+}
+
+static void
+editor_url_properties_dialog_show (GtkWidget *widget)
+{
+       EEditorUrlPropertiesDialog *dialog;
+       EEditorWidget *editor_widget;
+       WebKitDOMDocument *document;
+       WebKitDOMDOMWindow *window;
+       WebKitDOMDOMSelection *dom_selection;
+       WebKitDOMRange *range;
+       WebKitDOMElement *link;
+
+       dialog = E_EDITOR_URL_PROPERTIES_DIALOG (widget);
+       editor_widget = e_editor_get_editor_widget (dialog->priv->editor);
+
+       document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (editor_widget));
+       window = webkit_dom_document_get_default_view (document);
+       dom_selection = webkit_dom_dom_window_get_selection (window);
+
+       /* Reset to default values */
+       gtk_entry_set_text (GTK_ENTRY (dialog->priv->url_edit), "http://";);
+       gtk_entry_set_text (GTK_ENTRY (dialog->priv->label_edit), "");
+       gtk_widget_set_sensitive (dialog->priv->label_edit, TRUE);
+       gtk_widget_set_sensitive (dialog->priv->remove_link_button, TRUE);
+
+       /* No selection at all */
+       if (!dom_selection ||
+           webkit_dom_dom_selection_get_range_count (dom_selection) < 1) {
+
+               goto chainup;
+       }
+
+       range = webkit_dom_dom_selection_get_range_at (dom_selection, 0, NULL);
+       link = find_anchor_element (range);
+
+       if (link) {
+               gchar *href, *text;
+
+               href = webkit_dom_html_anchor_element_get_href (
+                               WEBKIT_DOM_HTML_ANCHOR_ELEMENT (link));
+               text = webkit_dom_html_element_get_inner_text (
+                               WEBKIT_DOM_HTML_ELEMENT (link));
+
+               gtk_entry_set_text (
+                       GTK_ENTRY (dialog->priv->url_edit), href);
+               gtk_entry_set_text (
+                       GTK_ENTRY (dialog->priv->label_edit), text);
+               gtk_widget_set_sensitive (dialog->priv->label_edit, FALSE);
+
+               g_free (text);
+               g_free (href);
+       } else {
+               gchar *text;
+
+               text = webkit_dom_range_get_text (range);
+               if (text && *text) {
+                       gtk_entry_set_text (
+                               GTK_ENTRY (dialog->priv->label_edit), text);
+                       gtk_widget_set_sensitive (
+                               dialog->priv->label_edit, FALSE);
+                       gtk_widget_set_sensitive (
+                               dialog->priv->remove_link_button, FALSE);
+               }
+               g_free (text);
+       }
+
+ chainup:
+       /* Chain up to parent implementation */
+       GTK_WIDGET_CLASS (e_editor_url_properties_dialog_parent_class)->show (widget);
+}
+
+static void
+editor_url_properties_dialog_set_property (GObject *object,
+                                          guint property_id,
+                                          const GValue *value,
+                                          GParamSpec *pspec)
+{
+       switch (property_id) {
+               case PROP_EDITOR:
+                       E_EDITOR_URL_PROPERTIES_DIALOG (object)->priv->editor =
+                               g_object_ref (g_value_get_object (value));
+                       return;
+       }
+
+       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+editor_url_properties_dialog_finalize (GObject *object)
+{
+       EEditorUrlPropertiesDialogPrivate *priv;
+       priv = E_EDITOR_URL_PROPERTIES_DIALOG (object)->priv;
+
+       g_clear_object (&priv->editor);
+
+       /* Chain up to parent implementation */
+       G_OBJECT_CLASS (e_editor_url_properties_dialog_parent_class)->finalize (object);
+}
+
+static void
+e_editor_url_properties_dialog_class_init (EEditorUrlPropertiesDialogClass *klass)
+{
+       GObjectClass *object_class;
+       GtkWidgetClass *widget_class;
+
+       e_editor_url_properties_dialog_parent_class  = g_type_class_peek_parent (klass);
+       g_type_class_add_private (klass, sizeof (EEditorUrlPropertiesDialogPrivate));
+
+
+       widget_class = GTK_WIDGET_CLASS (klass);
+       widget_class->show = editor_url_properties_dialog_show;
+
+       object_class = G_OBJECT_CLASS (klass);
+       object_class->set_property = editor_url_properties_dialog_set_property;
+       object_class->finalize = editor_url_properties_dialog_finalize;
+
+       g_object_class_install_property (
+               object_class,
+               PROP_EDITOR,
+               g_param_spec_object (
+                       "editor",
+                       NULL,
+                       NULL,
+                       E_TYPE_EDITOR,
+                       G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+}
+
+static void
+e_editor_url_properties_dialog_init (EEditorUrlPropertiesDialog *dialog)
+{
+       GtkGrid *main_layout;
+       GtkBox *button_box;
+       GtkWidget *widget;
+
+       dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (
+                               dialog, E_TYPE_EDITOR_URL_PROPERTIES_DIALOG,
+                               EEditorUrlPropertiesDialogPrivate);
+
+       main_layout = GTK_GRID (gtk_grid_new ());
+       gtk_grid_set_row_spacing (main_layout, 10);
+       gtk_grid_set_column_spacing (main_layout, 10);
+       gtk_container_add (GTK_CONTAINER (dialog), GTK_WIDGET (main_layout));
+       gtk_container_set_border_width (GTK_CONTAINER (dialog), 10);
+
+       widget = gtk_entry_new ();
+       gtk_grid_attach (main_layout, widget, 1, 0, 1, 1);
+       dialog->priv->url_edit = widget;
+
+       widget = gtk_label_new_with_mnemonic (_("URL:"));
+       gtk_label_set_mnemonic_widget (GTK_LABEL (widget), dialog->priv->url_edit);
+       gtk_grid_attach (main_layout, widget, 0, 0, 1, 1);
+
+       widget = gtk_button_new_with_label (_("Test URL..."));
+       gtk_grid_attach (main_layout, widget, 2, 0, 1, 1);
+       g_signal_connect_swapped (
+               widget, "clicked",
+               G_CALLBACK (editor_url_properties_dialog_test_url), dialog);
+       dialog->priv->test_button = widget;
+
+       widget = gtk_entry_new ();
+       gtk_grid_attach (main_layout, widget, 1, 1, 2, 1);
+       dialog->priv->label_edit = widget;
+
+       widget = gtk_label_new_with_mnemonic (_("Description:"));
+       gtk_label_set_mnemonic_widget (GTK_LABEL (widget), dialog->priv->label_edit);
+       gtk_grid_attach (main_layout, widget, 0, 1, 1, 1);
+
+       button_box = GTK_BOX (gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL));
+       gtk_box_set_spacing (button_box, 5);
+       gtk_button_box_set_layout (GTK_BUTTON_BOX (button_box), GTK_BUTTONBOX_END);
+       gtk_grid_attach (main_layout, GTK_WIDGET (button_box), 0, 2, 3, 1);
+
+       widget = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
+       g_signal_connect_swapped (
+               widget, "clicked",
+               G_CALLBACK (editor_url_properties_dialog_close), dialog);
+       gtk_box_pack_start (button_box, widget, FALSE, FALSE, 5);
+       dialog->priv->close_button = widget;
+
+       widget = gtk_button_new_with_label (_("Remove Link"));
+       g_signal_connect_swapped (
+               widget, "clicked",
+               G_CALLBACK (editor_url_properties_dialog_remove_link), dialog);
+       gtk_box_pack_start (button_box, widget, FALSE, FALSE, 5);
+       dialog->priv->remove_link_button = widget;
+
+       widget = gtk_button_new_from_stock (GTK_STOCK_OK);
+       g_signal_connect_swapped (
+               widget, "clicked",
+               G_CALLBACK (editor_url_properties_dialog_ok), dialog);
+       gtk_box_pack_start (button_box, widget, FALSE, FALSE, 5);
+       dialog->priv->ok_button = widget;
+
+       gtk_widget_show_all (GTK_WIDGET (main_layout));
+}
+
+GtkWidget *
+e_editor_url_properties_dialog_new (EEditor *editor)
+{
+       return GTK_WIDGET (
+               g_object_new (
+                       E_TYPE_EDITOR_URL_PROPERTIES_DIALOG,
+                       "destroy-with-parent", TRUE,
+                       "events", GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK,
+                       "editor", editor,
+                       "icon-name", "insert-link",
+                       "resizable", FALSE,
+                       "title", N_("Link Properties"),
+                       "transient-for", gtk_widget_get_toplevel (GTK_WIDGET (editor)),
+                       "type", GTK_WINDOW_TOPLEVEL,
+                       "window-position", GTK_WIN_POS_CENTER_ON_PARENT,
+                       NULL));
+}
diff --git a/e-util/e-editor-url-properties-dialog.h b/e-util/e-editor-url-properties-dialog.h
new file mode 100644
index 0000000..5e36fc6
--- /dev/null
+++ b/e-util/e-editor-url-properties-dialog.h
@@ -0,0 +1,70 @@
+/*
+ * e-editor-url-properties-dialog.h
+ *
+ * This program 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; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; 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_EDITOR_URL_PROPERTIES_DIALOG_H
+#define E_EDITOR_URL_PROPERTIES_DIALOG_H
+
+#include <gtk/gtk.h>
+#include <e-util/e-editor.h>
+
+/* Standard GObject macros */
+#define E_TYPE_EDITOR_URL_PROPERTIES_DIALOG \
+       (e_editor_url_properties_dialog_get_type ())
+#define E_EDITOR_URL_PROPERTIES_DIALOG(obj) \
+       (G_TYPE_CHECK_INSTANCE_CAST \
+       ((obj), E_TYPE_EDITOR_URL_PROPERTIES_DIALOG, EEditorUrlPropertiesDialog))
+#define E_EDITOR_URL_PROPERTIES_DIALOG_CLASS(cls) \
+       (G_TYPE_CHECK_CLASS_CAST \
+       ((cls), E_TYPE_EDITOR_URL_PROPERTIES_DIALOG, EEditorUrlPropertiesDialogClass))
+#define E_IS_EDITOR_URL_PROPERTIES_DIALOG(obj) \
+       (G_TYPE_CHECK_INSTANCE_TYPE \
+       ((obj), E_TYPE_EDITOR_URL_PROPERTIES_DIALOG))
+#define E_IS_EDITOR_URL_PROPERTIES_DIALOG_CLASS(cls) \
+       (G_TYPE_CHECK_CLASS_TYPE \
+       ((cls), E_TYPE_EDITOR_URL_PROPERTIES_DIALOG))
+#define E_EDITOR_URL_PROPERTIES_DIALOG_GET_CLASS(obj) \
+       (G_TYPE_INSTANCE_GET_CLASS \
+       ((obj), E_TYPE_EDITOR_URL_PROPERTIES_DIALOG, EEditorUrlPropertiesDialogClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EEditorUrlPropertiesDialog EEditorUrlPropertiesDialog;
+typedef struct _EEditorUrlPropertiesDialogClass EEditorUrlPropertiesDialogClass;
+typedef struct _EEditorUrlPropertiesDialogPrivate EEditorUrlPropertiesDialogPrivate;
+
+struct _EEditorUrlPropertiesDialog {
+       GtkWindow parent;
+
+       EEditorUrlPropertiesDialogPrivate *priv;
+};
+
+struct _EEditorUrlPropertiesDialogClass {
+       GtkWindowClass parent_class;
+};
+
+GType          e_editor_url_properties_dialog_get_type (void);
+
+GtkWidget*     e_editor_url_properties_dialog_new      (EEditor *editor);
+
+G_END_DECLS
+
+#endif /* E_EDITOR_URL_PROPERTIES_DIALOG_H */
diff --git a/e-util/e-editor-utils.c b/e-util/e-editor-utils.c
new file mode 100644
index 0000000..8509e03
--- /dev/null
+++ b/e-util/e-editor-utils.c
@@ -0,0 +1,39 @@
+/*
+ * e-editor-utils.c
+ *
+ * This program 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; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "e-editor-utils.h"
+
+
+WebKitDOMElement *
+e_editor_dom_node_get_parent_element (WebKitDOMNode *node,
+                                     GType parent_type)
+{
+       while (node) {
+
+               if (G_TYPE_CHECK_INSTANCE_TYPE (node, parent_type))
+                       return (WebKitDOMElement *) node;
+
+               node = (WebKitDOMNode *) webkit_dom_node_get_parent_element (node);
+       }
+
+       return NULL;
+}
diff --git a/e-util/e-editor-utils.h b/e-util/e-editor-utils.h
new file mode 100644
index 0000000..5405244
--- /dev/null
+++ b/e-util/e-editor-utils.h
@@ -0,0 +1,32 @@
+/*
+ * e-editor-utils.h
+ *
+ * This program 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; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; 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_EDITOR_UTILS_H
+#define E_EDITOR_UTILS_H
+
+#include <webkit/webkitdom.h>
+
+WebKitDOMElement *     e_editor_dom_node_get_parent_element
+                                                       (WebKitDOMNode *node,
+                                                        GType parent_type);
+
+#endif /* E_EDITOR_UTILS_H */
diff --git a/e-util/e-util.h b/e-util/e-util.h
index 169b0a8..7b4491b 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -95,6 +95,8 @@
 #include <e-util/e-editor-find-dialog.h>
 #include <e-util/e-editor-replace-dialog.h>
 #include <e-util/e-editor-selection.h>
+#include <e-util/e-editor-url-properties-dialog.h>
+#include <e-util/e-editor-utils.h>
 #include <e-util/e-editor-widget.h>
 #include <e-util/e-editor-widgets.h>
 #include <e-util/e-editor.h>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]