[evolution/webkit-composer: 27/210] Refactor EEditorDialog... classes



commit 39b471568b6065401b9c0b98f4f623f49caf1f89
Author: Dan Vrátil <dvratil redhat com>
Date:   Tue Aug 7 14:19:26 2012 +0200

    Refactor EEditorDialog... classes
    
    Move some common code to abstract class EEditorDialog and rename
    EEditorUrlPropertiesDialog to EEditorLinkDialog.

 e-util/Makefile.am                                 |    6 +-
 e-util/e-editor-actions.c                          |   16 +-
 e-util/e-editor-dialog.c                           |  148 ++++++++++++++++++++
 e-util/e-editor-dialog.h                           |   70 +++++++++
 e-util/e-editor-find-dialog.c                      |   64 +--------
 e-util/e-editor-find-dialog.h                      |    7 +-
 ...-properties-dialog.c => e-editor-link-dialog.c} |  133 ++++++------------
 e-util/e-editor-link-dialog.h                      |   69 +++++++++
 e-util/e-editor-private.h                          |    4 +-
 e-util/e-editor-replace-dialog.c                   |   69 ++--------
 e-util/e-editor-replace-dialog.h                   |    7 +-
 e-util/e-editor-url-properties-dialog.h            |   70 ---------
 e-util/e-util.h                                    |    3 +-
 13 files changed, 364 insertions(+), 302 deletions(-)
---
diff --git a/e-util/Makefile.am b/e-util/Makefile.am
index 7d452e6..5bd30af 100644
--- a/e-util/Makefile.am
+++ b/e-util/Makefile.am
@@ -179,10 +179,11 @@ evolution_util_include_HEADERS =  \
        e-dialog-utils.h \
        e-dialog-widgets.h \
        e-editor-actions.h \
+       e-editor-dialog.h \
        e-editor-find-dialog.h \
+       e-editor-link-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 \
@@ -435,11 +436,12 @@ libevolution_util_la_SOURCES = \
        e-dialog-utils.c \
        e-dialog-widgets.c \
        e-editor-actions.c \
+       e-editor-dialog.c \
        e-editor-find-dialog.c \
+       e-editor-link-dialog.c \
        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 \
diff --git a/e-util/e-editor-actions.c b/e-util/e-editor-actions.c
index b53db85..adb40e2 100644
--- a/e-util/e-editor-actions.c
+++ b/e-util/e-editor-actions.c
@@ -673,12 +673,12 @@ static void
 action_insert_link_cb (GtkAction *action,
                        EEditor *editor)
 {
-       if (editor->priv->url_properties_dialog == NULL) {
-               editor->priv->url_properties_dialog =
-                       e_editor_url_properties_dialog_new (editor);
+       if (editor->priv->link_dialog == NULL) {
+               editor->priv->link_dialog =
+                       e_editor_link_dialog_new (editor);
        }
 
-       gtk_window_present (GTK_WINDOW (editor->priv->url_properties_dialog));
+       gtk_window_present (GTK_WINDOW (editor->priv->link_dialog));
 }
 
 static void
@@ -969,12 +969,12 @@ static void
 action_properties_link_cb (GtkAction *action,
                            EEditor *editor)
 {
-       if (editor->priv->url_properties_dialog == NULL) {
-               editor->priv->url_properties_dialog =
-                       e_editor_url_properties_dialog_new (editor);
+       if (editor->priv->link_dialog == NULL) {
+               editor->priv->link_dialog =
+                       e_editor_link_dialog_new (editor);
        }
 
-       gtk_window_present (GTK_WINDOW (editor->priv->url_properties_dialog));
+       gtk_window_present (GTK_WINDOW (editor->priv->link_dialog));
 }
 
 static void
diff --git a/e-util/e-editor-dialog.c b/e-util/e-editor-dialog.c
new file mode 100644
index 0000000..717a534
--- /dev/null
+++ b/e-util/e-editor-dialog.c
@@ -0,0 +1,148 @@
+/*
+ * e-editor-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-dialog.h"
+
+G_DEFINE_ABSTRACT_TYPE (
+       EEditorDialog,
+       e_editor_dialog,
+       GTK_TYPE_WINDOW);
+
+struct _EEditorDialogPrivate {
+       EEditor *editor;
+};
+
+enum {
+       PROP_0,
+       PROP_EDITOR,
+};
+
+static void
+editor_dialog_set_editor (EEditorDialog *dialog,
+                         EEditor *editor)
+{
+       dialog->priv->editor = g_object_ref (editor);
+
+       gtk_window_set_transient_for (
+               GTK_WINDOW (dialog),
+               GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (editor))));
+
+       g_object_notify (G_OBJECT (dialog), "editor");
+}
+
+static void
+editor_dialog_get_property (GObject *object,
+                           guint property_id,
+                           GValue *value,
+                           GParamSpec *pspec)
+{
+       switch (property_id) {
+               case PROP_EDITOR:
+                       g_value_set_object (value,
+                       e_editor_dialog_get_editor (E_EDITOR_DIALOG (object)));
+                       return;
+       }
+
+       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+editor_dialog_set_property (GObject *object,
+                           guint property_id,
+                           const GValue *value,
+                           GParamSpec *pspec)
+{
+       switch (property_id) {
+               case PROP_EDITOR:
+                       editor_dialog_set_editor (
+                               E_EDITOR_DIALOG (object),
+                               g_value_get_object (value));
+                       return;
+       }
+
+       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+editor_dialog_dispose (GObject *object)
+{
+       EEditorDialogPrivate *priv = E_EDITOR_DIALOG (object)->priv;
+
+       g_clear_object (&priv->editor);
+
+       /* Chain up to parent's implementation */
+       G_OBJECT_CLASS (e_editor_dialog_parent_class)->dispose (object);
+}
+
+static void
+e_editor_dialog_class_init (EEditorDialogClass *klass)
+{
+       GObjectClass *object_class;
+
+       g_type_class_peek_parent (klass);
+       g_type_class_add_private (klass, sizeof (EEditorDialogPrivate));
+
+       object_class = G_OBJECT_CLASS (klass);
+       object_class->get_property = editor_dialog_get_property;
+       object_class->set_property = editor_dialog_set_property;
+       object_class->dispose = editor_dialog_dispose;
+
+       g_object_class_install_property (
+               object_class,
+               PROP_EDITOR,
+               g_param_spec_object (
+                       "editor",
+                       NULL,
+                       NULL,
+                       E_TYPE_EDITOR,
+                       G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
+}
+
+static void
+e_editor_dialog_init (EEditorDialog *dialog)
+{
+       dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (
+               dialog, E_TYPE_EDITOR_DIALOG, EEditorDialogPrivate);
+
+       g_object_set (
+               G_OBJECT (dialog),
+               "destroy-with-parent", TRUE,
+               "resizable", FALSE,
+               "type-hint", GDK_WINDOW_TYPE_HINT_POPUP_MENU,
+               "window-position", GTK_WIN_POS_CENTER_ON_PARENT,
+               NULL);
+
+       /* Don't destroy the dialog when closed! */
+       g_signal_connect (
+               dialog, "delete-event",
+               G_CALLBACK (gtk_widget_hide_on_delete), NULL);
+}
+
+
+
+EEditor *
+e_editor_dialog_get_editor (EEditorDialog *dialog)
+{
+       g_return_val_if_fail (E_IS_EDITOR_DIALOG (dialog), NULL);
+
+       return dialog->priv->editor;
+}
diff --git a/e-util/e-editor-dialog.h b/e-util/e-editor-dialog.h
new file mode 100644
index 0000000..0fa873d
--- /dev/null
+++ b/e-util/e-editor-dialog.h
@@ -0,0 +1,70 @@
+/*
+ * e-editor-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_DIALOG_H
+#define E_EDITOR_DIALOG_H
+
+#include <gtk/gtk.h>
+#include <e-util/e-editor.h>
+
+/* Standard GObject macros */
+#define E_TYPE_EDITOR_DIALOG \
+       (e_editor_dialog_get_type ())
+#define E_EDITOR_DIALOG(obj) \
+       (G_TYPE_CHECK_INSTANCE_CAST \
+       ((obj), E_TYPE_EDITOR_DIALOG, EEditorDialog))
+#define E_EDITOR_DIALOG_CLASS(cls) \
+       (G_TYPE_CHECK_CLASS_CAST \
+       ((cls), E_TYPE_EDITOR_DIALOG, EEditorDialogClass))
+#define E_IS_EDITOR_DIALOG(obj) \
+       (G_TYPE_CHECK_INSTANCE_TYPE \
+       ((obj), E_TYPE_EDITOR_DIALOG))
+#define E_IS_EDITOR_DIALOG_CLASS(cls) \
+       (G_TYPE_CHECK_CLASS_TYPE \
+       ((cls), E_TYPE_EDITOR_DIALOG))
+#define E_EDITOR_DIALOG_GET_CLASS(obj) \
+       (G_TYPE_INSTANCE_GET_CLASS \
+       ((obj), E_TYPE_EDITOR_DIALOG, EEditorDialogClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EEditorDialog EEditorDialog;
+typedef struct _EEditorDialogClass EEditorDialogClass;
+typedef struct _EEditorDialogPrivate EEditorDialogPrivate;
+
+struct _EEditorDialog {
+       GtkWindow parent;
+
+       EEditorDialogPrivate *priv;
+};
+
+struct _EEditorDialogClass {
+       GtkWindowClass parent_class;
+};
+
+GType          e_editor_dialog_get_type        (void);
+
+EEditor *      e_editor_dialog_get_editor      (EEditorDialog *dialog);
+
+G_END_DECLS
+
+#endif /* E_EDITOR_DIALOG_H */
diff --git a/e-util/e-editor-find-dialog.c b/e-util/e-editor-find-dialog.c
index f3ef249..b8cb8a3 100644
--- a/e-util/e-editor-find-dialog.c
+++ b/e-util/e-editor-find-dialog.c
@@ -28,7 +28,7 @@
 G_DEFINE_TYPE (
        EEditorFindDialog,
        e_editor_find_dialog,
-       GTK_TYPE_WINDOW);
+       E_TYPE_EDITOR_DIALOG);
 
 struct _EEditorFindDialogPrivate {
        GtkWidget *entry;
@@ -40,13 +40,6 @@ struct _EEditorFindDialogPrivate {
        GtkWidget *cancel_button;
 
        GtkWidget *result_label;
-
-       EEditor *editor;
-};
-
-enum {
-       PROP_0,
-       PROP_EDITOR
 };
 
 static void
@@ -78,9 +71,11 @@ static void
 editor_find_dialog_find_cb (EEditorFindDialog *dialog)
 {
        gboolean found;
+       EEditor *editor;
        EEditorWidget *editor_widget;
 
-       editor_widget = e_editor_get_editor_widget (dialog->priv->editor);
+       editor = e_editor_dialog_get_editor (E_EDITOR_DIALOG (dialog));
+       editor_widget = e_editor_get_editor_widget (editor);
        found = webkit_web_view_search_text (
                        WEBKIT_WEB_VIEW (editor_widget),
                        gtk_entry_get_text (
@@ -123,38 +118,8 @@ entry_key_release_event (GtkWidget *widget,
 }
 
 static void
-editor_find_dialog_set_property (GObject *object,
-                                guint property_id,
-                                const GValue *value,
-                                GParamSpec *pspec)
-{
-       EEditorFindDialog *dialog = E_EDITOR_FIND_DIALOG (object);
-
-       switch (property_id) {
-               case PROP_EDITOR:
-                       dialog->priv->editor =
-                               g_object_ref (g_value_get_object (value));
-                       return;
-       }
-
-       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-editor_find_dialog_finalize (GObject *object)
-{
-       EEditorFindDialogPrivate *priv = E_EDITOR_FIND_DIALOG (object)->priv;
-
-       g_clear_object (&priv->editor);
-
-       /* Chain up to parent's finalize */
-       G_OBJECT_CLASS (e_editor_find_dialog_parent_class)->finalize (object);
-}
-
-static void
 e_editor_find_dialog_class_init (EEditorFindDialogClass *klass)
 {
-       GObjectClass *object_class;
        GtkWidgetClass *widget_class;
 
        e_editor_find_dialog_parent_class = g_type_class_peek_parent (klass);
@@ -162,20 +127,6 @@ e_editor_find_dialog_class_init (EEditorFindDialogClass *klass)
 
        widget_class = GTK_WIDGET_CLASS (klass);
        widget_class->show = editor_find_dialog_show;
-
-       object_class = G_OBJECT_CLASS (klass);
-       object_class->set_property = editor_find_dialog_set_property;
-       object_class->finalize = editor_find_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
@@ -258,16 +209,9 @@ e_editor_find_dialog_new(EEditor *editor)
        return GTK_WIDGET (
                g_object_new (
                        E_TYPE_EDITOR_FIND_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", GTK_STOCK_FIND,
-                       "resizable", FALSE,
                        "title", N_("Find"),
-                       "transient-for", gtk_widget_get_toplevel (GTK_WIDGET (editor)),
-                       "type", GTK_WINDOW_TOPLEVEL,
-                       "type-hint", GDK_WINDOW_TYPE_HINT_POPUP_MENU,
-                       "window-position", GTK_WIN_POS_CENTER_ON_PARENT,
                        NULL));
 }
 
diff --git a/e-util/e-editor-find-dialog.h b/e-util/e-editor-find-dialog.h
index 43e2d9e..633318b 100644
--- a/e-util/e-editor-find-dialog.h
+++ b/e-util/e-editor-find-dialog.h
@@ -23,8 +23,7 @@
 #ifndef E_EDITOR_FIND_DIALOG_H
 #define E_EDITOR_FIND_DIALOG_H
 
-#include <gtk/gtk.h>
-#include <e-util/e-editor.h>
+#include <e-util/e-editor-dialog.h>
 
 /* Standard GObject macros */
 #define E_TYPE_EDITOR_FIND_DIALOG \
@@ -52,13 +51,13 @@ typedef struct _EEditorFindDialogClass EEditorFindDialogClass;
 typedef struct _EEditorFindDialogPrivate EEditorFindDialogPrivate;
 
 struct _EEditorFindDialog {
-       GtkWindow parent;
+       EEditorDialog parent;
 
        EEditorFindDialogPrivate *priv;
 };
 
 struct _EEditorFindDialogClass {
-       GtkWindowClass parent_class;
+       EEditorDialogClass parent_class;
 };
 
 GType          e_editor_find_dialog_get_type   (void);
diff --git a/e-util/e-editor-url-properties-dialog.c b/e-util/e-editor-link-dialog.c
similarity index 69%
rename from e-util/e-editor-url-properties-dialog.c
rename to e-util/e-editor-link-dialog.c
index 40096b1..1db2790 100644
--- a/e-util/e-editor-url-properties-dialog.c
+++ b/e-util/e-editor-link-dialog.c
@@ -1,5 +1,5 @@
 /*
- * e-editor-url-properties-dialog.h
+ * e-editor-link-dialog.h
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -20,20 +20,18 @@
 #include <config.h>
 #endif
 
-#include "e-editor-url-properties-dialog.h"
+#include "e-editor-link-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;
+       EEditorLinkDialog,
+       e_editor_link_dialog,
+       E_TYPE_EDITOR_DIALOG);
 
+struct _EEditorLinkDialogPrivate {
        GtkWidget *url_edit;
        GtkWidget *label_edit;
        GtkWidget *test_button;
@@ -43,11 +41,6 @@ struct _EEditorUrlPropertiesDialogPrivate {
        GtkWidget *ok_button;
 };
 
-enum {
-       PROP_0,
-       PROP_EDITOR
-};
-
 static WebKitDOMElement *
 find_anchor_element (WebKitDOMRange *range)
 {
@@ -90,7 +83,7 @@ find_anchor_element (WebKitDOMRange *range)
 
 
 static void
-editor_url_properties_dialog_test_url (EEditorUrlPropertiesDialog *dialog)
+editor_link_dialog_test_link (EEditorLinkDialog *dialog)
 {
        gtk_show_uri (
                gtk_window_get_screen (GTK_WINDOW (dialog)),
@@ -100,27 +93,30 @@ editor_url_properties_dialog_test_url (EEditorUrlPropertiesDialog *dialog)
 }
 
 static void
-editor_url_properties_dialog_close (EEditorUrlPropertiesDialog *dialog)
+editor_link_dialog_close (EEditorLinkDialog *dialog)
 {
        gtk_widget_hide (GTK_WIDGET (dialog));
 }
 
 static void
-editor_url_properties_dialog_remove_link (EEditorUrlPropertiesDialog *dialog)
+editor_link_dialog_remove_link (EEditorLinkDialog *dialog)
 {
-       EEditorSelection *selection;
+       EEditor *editor;
        EEditorWidget *widget;
+       EEditorSelection *selection;
 
-       widget = e_editor_get_editor_widget (dialog->priv->editor);
+       editor = e_editor_dialog_get_editor (E_EDITOR_DIALOG (dialog));
+       widget = e_editor_get_editor_widget (editor);
        selection = e_editor_widget_get_selection (widget);
        e_editor_selection_unlink (selection);
 
-       editor_url_properties_dialog_close (dialog);
+       editor_link_dialog_close (dialog);
 }
 
 static void
-editor_url_properties_dialog_ok (EEditorUrlPropertiesDialog *dialog)
+editor_link_dialog_ok (EEditorLinkDialog *dialog)
 {
+       EEditor *editor;
        EEditorWidget *widget;
        EEditorSelection *selection;
        WebKitDOMDocument *document;
@@ -129,7 +125,8 @@ editor_url_properties_dialog_ok (EEditorUrlPropertiesDialog *dialog)
        WebKitDOMRange *range;
        WebKitDOMElement *link;
 
-       widget = e_editor_get_editor_widget (dialog->priv->editor);
+       editor = e_editor_dialog_get_editor (E_EDITOR_DIALOG (dialog));
+       widget = e_editor_get_editor_widget (editor);
        selection = e_editor_widget_get_selection (widget);
 
        document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (widget));
@@ -176,22 +173,24 @@ editor_url_properties_dialog_ok (EEditorUrlPropertiesDialog *dialog)
                g_free (text);
        }
 
-       editor_url_properties_dialog_close (dialog);
+       editor_link_dialog_close (dialog);
 }
 
 static void
-editor_url_properties_dialog_show (GtkWidget *widget)
+editor_link_dialog_show (GtkWidget *widget)
 {
-       EEditorUrlPropertiesDialog *dialog;
+       EEditor *editor;
        EEditorWidget *editor_widget;
+       EEditorLinkDialog *dialog;
        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);
+       dialog = E_EDITOR_LINK_DIALOG (widget);
+       editor = e_editor_dialog_get_editor (E_EDITOR_DIALOG (dialog));
+       editor_widget = e_editor_get_editor_widget (editor);
 
        document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (editor_widget));
        window = webkit_dom_document_get_default_view (document);
@@ -246,75 +245,31 @@ editor_url_properties_dialog_show (GtkWidget *widget)
 
  chainup:
        /* Chain up to parent implementation */
-       GTK_WIDGET_CLASS (e_editor_url_properties_dialog_parent_class)->show (widget);
+       GTK_WIDGET_CLASS (e_editor_link_dialog_parent_class)->show (widget);
 }
 
 static void
-editor_url_properties_dialog_set_property (GObject *object,
-                                          guint property_id,
-                                          const GValue *value,
-                                          GParamSpec *pspec)
+e_editor_link_dialog_class_init (EEditorLinkDialogClass *klass)
 {
-       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));
-
+       e_editor_link_dialog_parent_class  = g_type_class_peek_parent (klass);
+       g_type_class_add_private (klass, sizeof (EEditorLinkDialogPrivate));
 
        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));
+       widget_class->show = editor_link_dialog_show;
 }
 
 static void
-e_editor_url_properties_dialog_init (EEditorUrlPropertiesDialog *dialog)
+e_editor_link_dialog_init (EEditorLinkDialog *dialog)
 {
        GtkGrid *main_layout;
        GtkBox *button_box;
        GtkWidget *widget;
 
        dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (
-                               dialog, E_TYPE_EDITOR_URL_PROPERTIES_DIALOG,
-                               EEditorUrlPropertiesDialogPrivate);
+                               dialog, E_TYPE_EDITOR_LINK_DIALOG,
+                               EEditorLinkDialogPrivate);
 
        main_layout = GTK_GRID (gtk_grid_new ());
        gtk_grid_set_row_spacing (main_layout, 10);
@@ -326,15 +281,15 @@ e_editor_url_properties_dialog_init (EEditorUrlPropertiesDialog *dialog)
        gtk_grid_attach (main_layout, widget, 1, 0, 1, 1);
        dialog->priv->url_edit = widget;
 
-       widget = gtk_label_new_with_mnemonic (_("URL:"));
+       widget = gtk_label_new_with_mnemonic (_("LINK:"));
        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..."));
+       widget = gtk_button_new_with_label (_("Test LINK..."));
        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);
+               G_CALLBACK (editor_link_dialog_test_link), dialog);
        dialog->priv->test_button = widget;
 
        widget = gtk_entry_new ();
@@ -353,21 +308,21 @@ e_editor_url_properties_dialog_init (EEditorUrlPropertiesDialog *dialog)
        widget = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
        g_signal_connect_swapped (
                widget, "clicked",
-               G_CALLBACK (editor_url_properties_dialog_close), dialog);
+               G_CALLBACK (editor_link_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);
+               G_CALLBACK (editor_link_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);
+               G_CALLBACK (editor_link_dialog_ok), dialog);
        gtk_box_pack_start (button_box, widget, FALSE, FALSE, 5);
        dialog->priv->ok_button = widget;
 
@@ -375,19 +330,13 @@ e_editor_url_properties_dialog_init (EEditorUrlPropertiesDialog *dialog)
 }
 
 GtkWidget *
-e_editor_url_properties_dialog_new (EEditor *editor)
+e_editor_link_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,
+                       E_TYPE_EDITOR_LINK_DIALOG,
                        "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-link-dialog.h b/e-util/e-editor-link-dialog.h
new file mode 100644
index 0000000..8f0ea49
--- /dev/null
+++ b/e-util/e-editor-link-dialog.h
@@ -0,0 +1,69 @@
+/*
+ * e-editor-link-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_LINK_DIALOG_H
+#define E_EDITOR_LINK_DIALOG_H
+
+#include <e-util/e-editor-dialog.h>
+
+/* Standard GObject macros */
+#define E_TYPE_EDITOR_LINK_DIALOG \
+       (e_editor_link_dialog_get_type ())
+#define E_EDITOR_LINK_DIALOG(obj) \
+       (G_TYPE_CHECK_INSTANCE_CAST \
+       ((obj), E_TYPE_EDITOR_LINK_DIALOG, EEditorLinkDialog))
+#define E_EDITOR_LINK_DIALOG_CLASS(cls) \
+       (G_TYPE_CHECK_CLASS_CAST \
+       ((cls), E_TYPE_EDITOR_LINK_DIALOG, EEditorLinkDialogClass))
+#define E_IS_EDITOR_LINK_DIALOG(obj) \
+       (G_TYPE_CHECK_INSTANCE_TYPE \
+       ((obj), E_TYPE_EDITOR_LINK_DIALOG))
+#define E_IS_EDITOR_LINK_DIALOG_CLASS(cls) \
+       (G_TYPE_CHECK_CLASS_TYPE \
+       ((cls), E_TYPE_EDITOR_LINK_DIALOG))
+#define E_EDITOR_LINK_DIALOG_GET_CLASS(obj) \
+       (G_TYPE_INSTANCE_GET_CLASS \
+       ((obj), E_TYPE_EDITOR_LINK_DIALOG, EEditorLinkDialogClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EEditorLinkDialog EEditorLinkDialog;
+typedef struct _EEditorLinkDialogClass EEditorLinkDialogClass;
+typedef struct _EEditorLinkDialogPrivate EEditorLinkDialogPrivate;
+
+struct _EEditorLinkDialog {
+       EEditorDialog parent;
+
+       EEditorLinkDialogPrivate *priv;
+};
+
+struct _EEditorLinkDialogClass {
+       EEditorDialogClass parent_class;
+};
+
+GType          e_editor_link_dialog_get_type   (void);
+
+GtkWidget*     e_editor_link_dialog_new        (EEditor *editor);
+
+G_END_DECLS
+
+#endif /* E_EDITOR_LINK_DIALOG_H */
diff --git a/e-util/e-editor-private.h b/e-util/e-editor-private.h
index 25df5ef..5872a8a 100644
--- a/e-util/e-editor-private.h
+++ b/e-util/e-editor-private.h
@@ -26,7 +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>
+#include <e-editor-link-dialog.h>
 
 #ifdef HAVE_XFREE
 #include <X11/XF86keysym.h>
@@ -57,7 +57,7 @@ struct _EEditorPrivate {
 
        GtkWidget *find_dialog;
        GtkWidget *replace_dialog;
-       GtkWidget *url_properties_dialog;
+       GtkWidget *link_dialog;
 
        GtkWidget *color_combo_box;
        GtkWidget *mode_combo_box;
diff --git a/e-util/e-editor-replace-dialog.c b/e-util/e-editor-replace-dialog.c
index 150af90..b372d05 100644
--- a/e-util/e-editor-replace-dialog.c
+++ b/e-util/e-editor-replace-dialog.c
@@ -27,7 +27,7 @@
 G_DEFINE_TYPE (
        EEditorReplaceDialog,
        e_editor_replace_dialog,
-       GTK_TYPE_WINDOW);
+       E_TYPE_EDITOR_DIALOG);
 
 struct _EEditorReplaceDialogPrivate {
        GtkWidget *search_entry;
@@ -43,23 +43,18 @@ struct _EEditorReplaceDialogPrivate {
        GtkWidget *skip_button;
        GtkWidget *replace_button;
        GtkWidget *replace_all_button;
-
-       EEditor *editor;
-};
-
-enum {
-       PROP_0,
-       PROP_EDITOR
 };
 
 static gboolean
 jump (EEditorReplaceDialog *dialog)
 {
+       EEditor *editor;
        WebKitWebView *webview;
        gboolean found;
 
+       editor = e_editor_dialog_get_editor (E_EDITOR_DIALOG (dialog));
        webview = WEBKIT_WEB_VIEW (
-                       e_editor_get_editor_widget (dialog->priv->editor));
+                       e_editor_get_editor_widget (editor));
 
        found = webkit_web_view_search_text (
                webview,
@@ -90,6 +85,7 @@ editor_replace_dialog_skip_cb (EEditorReplaceDialog *dialog)
 static void
 editor_replace_dialog_replace_cb (EEditorReplaceDialog *dialog)
 {
+       EEditor *editor;
        EEditorWidget *editor_widget;
        EEditorSelection *selection;
 
@@ -104,7 +100,8 @@ editor_replace_dialog_replace_cb (EEditorReplaceDialog *dialog)
                gtk_widget_hide (dialog->priv->result_label);
        }
 
-       editor_widget = e_editor_get_editor_widget (dialog->priv->editor);
+       editor = e_editor_dialog_get_editor (E_EDITOR_DIALOG (dialog));
+       editor_widget = e_editor_get_editor_widget (editor);
        selection = e_editor_widget_get_selection (editor_widget);
 
        e_editor_selection_replace (
@@ -117,11 +114,13 @@ editor_replace_dialog_replace_all_cb (EEditorReplaceDialog *dialog)
 {
        gint i = 0;
        gchar *result;
+       EEditor *editor;
        EEditorWidget *widget;
        EEditorSelection *selection;
        const gchar *replacement;
 
-       widget = e_editor_get_editor_widget (dialog->priv->editor);
+       editor = e_editor_dialog_get_editor (E_EDITOR_DIALOG (dialog));
+       widget = e_editor_get_editor_widget (editor);
        selection = e_editor_widget_get_selection (widget);
        replacement = gtk_entry_get_text (GTK_ENTRY (dialog->priv->replace_entry));
 
@@ -169,36 +168,8 @@ editor_replace_dialog_show (GtkWidget *widget)
 }
 
 static void
-editor_replace_dialog_set_property (GObject *object,
-                                   guint property_id,
-                                   const GValue *value,
-                                   GParamSpec *pspec)
-{
-       switch (property_id) {
-               case PROP_EDITOR:
-                       E_EDITOR_REPLACE_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_replace_dialog_finalize (GObject *object)
-{
-       EEditorReplaceDialogPrivate *priv = E_EDITOR_REPLACE_DIALOG (object)->priv;
-
-       g_clear_object (&priv->editor);
-
-       /* Chain up to parent implementation */
-       G_OBJECT_CLASS (e_editor_replace_dialog_parent_class)->finalize (object);
-}
-
-static void
 e_editor_replace_dialog_class_init (EEditorReplaceDialogClass *klass)
 {
-       GObjectClass *object_class;
        GtkWidgetClass *widget_class;
 
        e_editor_replace_dialog_parent_class = g_type_class_peek_parent (klass);
@@ -206,20 +177,6 @@ e_editor_replace_dialog_class_init (EEditorReplaceDialogClass *klass)
 
        widget_class = GTK_WIDGET_CLASS (klass);
        widget_class->show = editor_replace_dialog_show;
-
-       object_class = G_OBJECT_CLASS (klass);
-       object_class->set_property = editor_replace_dialog_set_property;
-       object_class->finalize = editor_replace_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
@@ -326,14 +283,8 @@ e_editor_replace_dialog_new (EEditor *editor)
        return GTK_WIDGET (
                g_object_new (
                        E_TYPE_EDITOR_REPLACE_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", GTK_STOCK_FIND_AND_REPLACE,
-                       "resizable", FALSE,
                        "title", N_("Replace"),
-                       "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-replace-dialog.h b/e-util/e-editor-replace-dialog.h
index 99132f5..8912751 100644
--- a/e-util/e-editor-replace-dialog.h
+++ b/e-util/e-editor-replace-dialog.h
@@ -23,8 +23,7 @@
 #ifndef E_EDITOR_REPLACE_DIALOG_H
 #define E_EDITOR_REPLACE_DIALOG_H
 
-#include <gtk/gtk.h>
-#include <e-util/e-editor.h>
+#include <e-util/e-editor-dialog.h>
 
 /* Standard GObject macros */
 #define E_TYPE_EDITOR_REPLACE_DIALOG \
@@ -52,13 +51,13 @@ typedef struct _EEditorReplaceDialogClass EEditorReplaceDialogClass;
 typedef struct _EEditorReplaceDialogPrivate EEditorReplaceDialogPrivate;
 
 struct _EEditorReplaceDialog {
-       GtkWindow parent;
+       EEditorDialog parent;
 
        EEditorReplaceDialogPrivate *priv;
 };
 
 struct _EEditorReplaceDialogClass {
-       GtkWindowClass parent_class;
+       EEditorDialogClass parent_class;
 };
 
 GType          e_editor_replace_dialog_get_type        (void);
diff --git a/e-util/e-util.h b/e-util/e-util.h
index 13805dd..6c0b0ad 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -94,10 +94,11 @@
 #include <e-util/e-dialog-utils.h>
 #include <e-util/e-dialog-widgets.h>
 #include <e-util/e-editor-actions.h>
+#include <e-util/e-editor-dialog.h>
 #include <e-util/e-editor-find-dialog.h>
+#include <e-util/e-editor-link-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>


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