[evolution/wip/webkit-composer: 527/966] Port Replace dialog and it's functionality



commit 88214ce7ae2d0d242e814190036cc0f19cbceb76
Author: Dan Vrátil <dvratil redhat com>
Date:   Tue Jul 31 10:48:04 2012 +0200

    Port Replace dialog and it's functionality
    
    Create EEditorReplaceDialog class and move all the find&replace functionality
    in there. The dialog is constructed manually, instead of using Glade UI.
    
    Known issues:
     - WebKit does not draw text selection when it does not have focus,
       which means that we can't see which string we are replacing atm.
     - WebKit seems to eat all the shortcuts, therefore Ctl+F and Ctrl+G don't
       work.

 e-util/Makefile.am               |    2 +
 e-util/e-editor-actions.c        |  182 +----------------------------
 e-util/e-editor-actions.h        |    4 -
 e-util/e-editor-builder.ui       |  234 --------------------------------------
 e-util/e-editor-private.h        |    2 +
 e-util/e-editor-replace-dialog.c |  166 +++++++++++++++++++++++++++
 e-util/e-editor-replace-dialog.h |   22 ++++
 e-util/e-editor-widgets.h        |   30 -----
 e-util/e-util.h                  |    1 +
 9 files changed, 200 insertions(+), 443 deletions(-)
---
diff --git a/e-util/Makefile.am b/e-util/Makefile.am
index e60bd99..ffa6f13 100644
--- a/e-util/Makefile.am
+++ b/e-util/Makefile.am
@@ -181,6 +181,7 @@ evolution_util_include_HEADERS =  \
        e-dialog-widgets.h \
        e-editor-actions.h \
        e-editor-find-dialog.h \
+       e-editor-replace-dialog.h \
        e-editor-selection.h \
        e-editor-widget.h \
        e-editor-widgets.h \
@@ -442,6 +443,7 @@ libevolution_util_la_SOURCES = \
        e-editor-actions.c \
        e-editor-find-dialog.c \
        e-editor-private.h \
+       e-editor-replace-dialog.c \
        e-editor-selection.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 552f967..94e5702 100644
--- a/e-util/e-editor-actions.c
+++ b/e-util/e-editor-actions.c
@@ -106,16 +106,6 @@ insert_text_file_ready_cb (GFile *file,
        g_object_unref (editor);
 }
 
-static void
-replace_answer (EEditor *editor,
-                EEditorWidgetReplaceAnswer answer)
-{
-       /* FIXME WEBKIT
-       if (e_editor_widget_replace (e_editor_get_editor_widget (editor), answer))
-               gtk_widget_hide (WIDGET (REPLACE_CONFIRMATION_WINDOW));
-       */
-}
-
 /*****************************************************************************
  * Action Callbacks
  *****************************************************************************/
@@ -132,35 +122,6 @@ action_bold_cb (GtkToggleAction *action,
                selection, gtk_toggle_action_get_active (action));
 }
 
-
-static void
-action_confirm_replace_cb (GtkAction *action,
-                           EEditor *editor)
-{
-       replace_answer (editor, E_EDITOR_WIDGET_REPLACE_ANSWER_REPLACE);
-}
-
-static void
-action_confirm_replace_all_cb (GtkAction *action,
-                               EEditor *editor)
-{
-       replace_answer (editor, E_EDITOR_WIDGET_REPLACE_ANSWER_REPLACE_ALL);
-}
-
-static void
-action_confirm_replace_cancel_cb (GtkAction *action,
-                                  EEditor *editor)
-{
-       replace_answer (editor, E_EDITOR_WIDGET_REPLACE_ANSWER_CANCEL);
-}
-
-static void
-action_confirm_replace_next_cb (GtkAction *action,
-                                EEditor *editor)
-{
-       replace_answer (editor, E_EDITOR_WIDGET_REPLACE_ANSWER_NEXT);
-}
-
 static WebKitDOMNode *
 find_parent_element_by_type (WebKitDOMNode *node, GType type)
 {
@@ -612,105 +573,6 @@ action_cut_cb (GtkAction *action,
 }
 
 static void
-action_find_and_replace_cb (GtkAction *action,
-                            EEditor *editor)
-{
-       WebKitDOMDocument *document;
-       WebKitDOMNode *start, *end;
-       WebKitDOMNodeList *children;
-       WebKitDOMDOMWindow *window;
-       WebKitDOMDOMSelection *selection;
-       WebKitDOMRange *range;
-       WebKitDOMNode *node;
-
-       gulong length, i;
-       const gchar *needle, *replacement;
-       gboolean case_sensitive, backwards, wrap, only_selection;
-
-       needle = gtk_entry_get_text (GTK_ENTRY (WIDGET (REPLACE_ENTRY)));
-       replacement = gtk_entry_get_text (
-                               GTK_ENTRY (WIDGET (REPLACE_WITH_ENTRY)));
-       case_sensitive = gtk_toggle_button_get_active (
-                               GTK_TOGGLE_BUTTON (WIDGET (REPLACE_CASE_SENSITIVE)));
-       wrap = gtk_toggle_button_get_active (
-                               GTK_TOGGLE_BUTTON (WIDGET (REPLACE_WRAP)));
-       backwards = gtk_toggle_button_get_active (
-                               GTK_TOGGLE_BUTTON (WIDGET (REPLACE_BACKWARDS)));
-       only_selection = gtk_toggle_button_get_active (
-                               GTK_TOGGLE_BUTTON (WIDGET (REPLACE_ONLY_SELECTION)));
-
-       /* XXX Port this if to native WebKit API if they ever implement
-        * support for find&replace...unless this implementation
-        * is better ;) */
-
-       /* FIXME WEBKIT This is not working at all */
-       document = webkit_web_view_get_dom_document (
-                       WEBKIT_WEB_VIEW (e_editor_get_editor_widget (editor)));
-       window = webkit_dom_document_get_default_view (document);
-       selection = webkit_dom_dom_window_get_selection (window);
-       if (webkit_dom_dom_selection_get_range_count (selection) < 1)
-               return;
-
-       range = webkit_dom_dom_selection_get_range_at (selection, 0, NULL);
-       start = webkit_dom_range_get_start_container (range, NULL);
-
-       if (only_selection) {
-               end = webkit_dom_range_get_end_container (range, NULL);
-       } else {
-               end = NULL;
-       }
-
-       /* WEBKIT FIXME Implement me! */
-       /*
-       node = start;
-       while (node && (node != end)) {
-
-
-
-       }
-       */
-
-       /*
-       html = gtkhtml_editor_get_html (editor);
-
-       gtk_widget_hide (WIDGET (REPLACE_WINDOW));
-
-       html_engine_replace (
-               html->engine,
-               gtk_entry_get_text (GTK_ENTRY (WIDGET (REPLACE_ENTRY))),
-               gtk_entry_get_text (GTK_ENTRY (WIDGET (REPLACE_WITH_ENTRY))),
-               gtk_toggle_button_get_active (
-                       GTK_TOGGLE_BUTTON (WIDGET (REPLACE_CASE_SENSITIVE))),
-               !gtk_toggle_button_get_active (
-                       GTK_TOGGLE_BUTTON (WIDGET (REPLACE_BACKWARDS))),
-               FALSE, replace_ask_cb, editor);
-       */
-}
-
-/* FIXME WEBKIT
-static void
-replace_ask_cb (HTMLEngine *engine,
-                gpointer data)
-{
-       GtkhtmlEditor *editor = data;
-
-       gtk_window_present (GTK_WINDOW (WIDGET (REPLACE_CONFIRMATION_WINDOW)));
-}
-
-static void
-replace_answer (GtkhtmlEditor *editor,
-                HTMLReplaceQueryAnswer answer)
-{
-       GtkHTML *html;
-
-       html = gtkhtml_editor_get_html (editor);
-
-       if (html_engine_replace_do (html->engine, answer))
-               gtk_widget_hide (WIDGET (REPLACE_CONFIRMATION_WINDOW));
-}
-*/
-
-static void
 action_indent_cb (GtkAction *action,
                   EEditor *editor)
 {
@@ -1263,7 +1125,12 @@ static void
 action_show_replace_cb (GtkAction *action,
                         EEditor *editor)
 {
-       gtk_window_present (GTK_WINDOW (WIDGET (REPLACE_WINDOW)));
+       if (editor->priv->replace_dialog == NULL) {
+               editor->priv->replace_dialog =
+                       e_editor_replace_dialog_new (editor);
+       }
+
+       gtk_window_present (GTK_WINDOW (editor->priv->replace_dialog));
 }
 
 static void
@@ -1379,34 +1246,6 @@ action_wrap_lines_cb (GtkAction *action,
 
 static GtkActionEntry core_entries[] = {
 
-       { "confirm-replace",
-         NULL,
-         N_("_Replace"),
-         NULL,
-         NULL,
-         G_CALLBACK (action_confirm_replace_cb) },
-
-       { "confirm-replace-all",
-         NULL,
-         N_("Replace _All"),
-         NULL,
-         NULL,
-         G_CALLBACK (action_confirm_replace_all_cb) },
-
-       { "confirm-replace-cancel",
-         GTK_STOCK_CLOSE,
-         NULL,
-         NULL,
-         NULL,
-         G_CALLBACK (action_confirm_replace_cancel_cb) },
-
-       { "confirm-replace-next",
-         NULL,
-         N_("_Next"),
-         NULL,
-         NULL,
-         G_CALLBACK (action_confirm_replace_next_cb) },
-
        { "copy",
          GTK_STOCK_COPY,
          N_("_Copy"),
@@ -1421,13 +1260,6 @@ static GtkActionEntry core_entries[] = {
          NULL,
          G_CALLBACK (action_cut_cb) },
 
-       { "find-and-replace",
-         GTK_STOCK_FIND_AND_REPLACE,
-         NULL,
-         NULL,
-         NULL,
-         G_CALLBACK (action_find_and_replace_cb) },
-
        { "indent",
          GTK_STOCK_INDENT,
          N_("_Increase Indent"),
@@ -2388,7 +2220,7 @@ editor_actions_init (EEditor *editor)
                G_OBJECT (ACTION (SHOW_FIND)),
                "short-label", _("_Find"), NULL);
        g_object_set (
-               G_OBJECT (ACTION (FIND_AND_REPLACE)),
+               G_OBJECT (ACTION (SHOW_REPLACE)),
                "short-label", _("Re_place"), NULL);
        g_object_set (
                G_OBJECT (ACTION (INSERT_IMAGE)),
diff --git a/e-util/e-editor-actions.h b/e-util/e-editor-actions.h
index 9f0616a..1fdab3b 100644
--- a/e-util/e-editor-actions.h
+++ b/e-util/e-editor-actions.h
@@ -80,12 +80,8 @@
        E_EDITOR_ACTION ((editor), "cut")
 #define E_EDITOR_ACTION_EDIT_MENU(editor) \
        E_EDITOR_ACTION ((editor), "edit-menu")
-#define E_EDITOR_ACTION_FIND(editor) \
-       E_EDITOR_ACTION ((editor), "find")
 #define E_EDITOR_ACTION_FIND_AGAIN(editor) \
        E_EDITOR_ACTION ((editor), "find-again")
-#define E_EDITOR_ACTION_FIND_AND_REPLACE(editor) \
-       E_EDITOR_ACTION ((editor), "find-and-replace")
 #define E_EDITOR_ACTION_FORMAT_MENU(editor) \
        E_EDITOR_ACTION ((editor), "format-menu")
 #define E_EDITOR_ACTION_FORMAT_TEXT(editor) \
diff --git a/e-util/e-editor-builder.ui b/e-util/e-editor-builder.ui
index 6552439..5414238 100644
--- a/e-util/e-editor-builder.ui
+++ b/e-util/e-editor-builder.ui
@@ -760,240 +760,6 @@
       </object>
     </child>
   </object>
-  <object class="GtkWindow" id="replace-window">
-    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | 
GDK_BUTTON_RELEASE_MASK</property>
-    <property name="title" translatable="yes">Replace</property>
-    <property name="resizable">False</property>
-    <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
-    <property name="destroy_with_parent">True</property>
-    <signal handler="gtk_widget_hide_on_delete" name="delete_event"/>
-    <signal handler="gtk_widget_grab_focus" name="show" object="replace-entry"/>
-    <child>
-      <object class="GtkVBox" id="replace-vbox">
-        <property name="visible">True</property>
-        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-        <property name="border_width">12</property>
-        <property name="spacing">12</property>
-        <child>
-          <object class="GtkTable" id="replace-table">
-            <property name="visible">True</property>
-            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-            <property name="n_rows">3</property>
-            <property name="n_columns">3</property>
-            <property name="column_spacing">6</property>
-            <property name="row_spacing">6</property>
-            <child>
-              <object class="GtkEntry" id="replace-with-entry">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="right_attach">3</property>
-                <property name="top_attach">1</property>
-                <property name="bottom_attach">2</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkEntry" id="replace-entry">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="right_attach">3</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="replace-with-label">
-                <property name="visible">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="xalign">1</property>
-                <property name="label" translatable="yes">_With:</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">replace-with-entry</property>
-              </object>
-              <packing>
-                <property name="top_attach">1</property>
-                <property name="bottom_attach">2</property>
-                <property name="x_options">GTK_FILL</property>
-                <property name="y_options"/>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="replace-label">
-                <property name="visible">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="xalign">1</property>
-                <property name="label" translatable="yes">R_eplace:</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">replace-entry</property>
-              </object>
-              <packing>
-                <property name="x_options">GTK_FILL</property>
-                <property name="y_options"/>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkCheckButton" id="replace-backwards">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="label" translatable="yes">Search _backwards</property>
-                <property name="use_underline">True</property>
-                <property name="draw_indicator">True</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="right_attach">2</property>
-                <property name="top_attach">2</property>
-                <property name="bottom_attach">3</property>
-                <property name="x_options"/>
-                <property name="y_options"/>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkCheckButton" id="replace-case-sensitive">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="label" translatable="yes">Case _sensitive</property>
-                <property name="use_underline">True</property>
-                <property name="draw_indicator">True</property>
-              </object>
-              <packing>
-                <property name="left_attach">2</property>
-                <property name="right_attach">3</property>
-                <property name="top_attach">2</property>
-                <property name="bottom_attach">3</property>
-                <property name="y_options"/>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkAlignment" id="replace-alignment">
-                <property name="visible">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <child>
-                  <placeholder/>
-                </child>
-              </object>
-              <packing>
-                <property name="top_attach">2</property>
-                <property name="bottom_attach">3</property>
-                <property name="x_options"/>
-                <property name="y_options"/>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkHButtonBox" id="replace-button-box">
-            <property name="visible">True</property>
-            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-            <property name="spacing">12</property>
-            <property name="layout_style">GTK_BUTTONBOX_END</property>
-            <child>
-              <object class="GtkButton" id="replace-close-button">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="label">gtk-close</property>
-                <property name="use_stock">True</property>
-                <signal handler="gtk_widget_hide" name="clicked" object="replace-window"/>
-              </object>
-            </child>
-            <child>
-              <object class="GtkButton" id="replace-button">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="has_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="label">gtk-find-and-replace</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="pack_type">GTK_PACK_END</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-      </object>
-    </child>
-  </object>
-  <object class="GtkWindow" id="replace-confirmation-window">
-    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | 
GDK_BUTTON_RELEASE_MASK</property>
-    <property name="title" translatable="yes">Replace Confirmation</property>
-    <property name="resizable">False</property>
-    <property name="destroy_with_parent">True</property>
-    <property name="icon_name">gtk-find-and-replace</property>
-    <signal handler="gtkhtml_editor_replace_confirmation_delete_event_cb" name="delete_event"/>
-    <child>
-      <object class="GtkHButtonBox" id="replace-confirmation-button-box">
-        <property name="visible">True</property>
-        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-        <property name="border_width">12</property>
-        <property name="spacing">12</property>
-        <property name="homogeneous">True</property>
-        <child>
-          <object class="GtkButton" id="replace-confirmation-replace-all-button">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">True</property>
-            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-          </object>
-        </child>
-        <child>
-          <object class="GtkButton" id="replace-confirmation-next-button">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">True</property>
-            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-          </object>
-          <packing>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkButton" id="replace-confirmation-close-button">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">True</property>
-            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-            <property name="use_stock">True</property>
-          </object>
-          <packing>
-            <property name="position">2</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkButton" id="replace-confirmation-replace-button">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">True</property>
-            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-          </object>
-          <packing>
-            <property name="position">3</property>
-          </packing>
-        </child>
-      </object>
-    </child>
-  </object>
   <object class="GtkWindow" id="link-properties-window">
     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | 
GDK_BUTTON_RELEASE_MASK</property>
     <property name="title" translatable="yes">Link Properties</property>
diff --git a/e-util/e-editor-private.h b/e-util/e-editor-private.h
index 1688dd3..cdb2379 100644
--- a/e-util/e-editor-private.h
+++ b/e-util/e-editor-private.h
@@ -25,6 +25,7 @@
 #include <e-editor-widgets.h>
 #include <e-editor-widget.h>
 #include <e-editor-find-dialog.h>
+#include <e-editor-replace-dialog.h>
 
 #ifdef HAVE_XFREE
 #include <X11/XF86keysym.h>
@@ -54,6 +55,7 @@ struct _EEditorPrivate {
        GtkWidget *edit_area;
 
        GtkWidget *find_dialog;
+       GtkWidget *replace_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 4f7b64b..4e1b726 100644
--- a/e-util/e-editor-replace-dialog.c
+++ b/e-util/e-editor-replace-dialog.c
@@ -1,8 +1,11 @@
 /*
  * e-editor-replace-dialog.h
  *
+<<<<<<< HEAD
  * Copyright (C) 2012 Dan Vrátil <dvratil redhat com>
  *
+=======
+>>>>>>> Port Replace dialog and it's functionality
  * 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
@@ -26,6 +29,7 @@
 
 #include <glib/gi18n-lib.h>
 
+<<<<<<< HEAD
 #define E_EDITOR_REPLACE_DIALOG_GET_PRIVATE(obj) \
        (G_TYPE_INSTANCE_GET_PRIVATE \
        ((obj), E_TYPE_EDITOR_REPLACE_DIALOG, EEditorReplaceDialogPrivate))
@@ -34,6 +38,12 @@ G_DEFINE_TYPE (
        EEditorReplaceDialog,
        e_editor_replace_dialog,
        E_TYPE_EDITOR_DIALOG);
+=======
+G_DEFINE_TYPE (
+       EEditorReplaceDialog,
+       e_editor_replace_dialog,
+       GTK_TYPE_WINDOW);
+>>>>>>> Port Replace dialog and it's functionality
 
 struct _EEditorReplaceDialogPrivate {
        GtkWidget *search_entry;
@@ -45,14 +55,29 @@ struct _EEditorReplaceDialogPrivate {
 
        GtkWidget *result_label;
 
+<<<<<<< HEAD
+       GtkWidget *skip_button;
+       GtkWidget *replace_button;
+       GtkWidget *replace_all_button;
+=======
+       GtkWidget *close_button;
        GtkWidget *skip_button;
        GtkWidget *replace_button;
        GtkWidget *replace_all_button;
+
+       EEditor *editor;
+};
+
+enum {
+       PROP_0,
+       PROP_EDITOR
+>>>>>>> Port Replace dialog and it's functionality
 };
 
 static gboolean
 jump (EEditorReplaceDialog *dialog)
 {
+<<<<<<< HEAD
        EEditor *editor;
        WebKitWebView *webview;
        gboolean found;
@@ -60,6 +85,13 @@ jump (EEditorReplaceDialog *dialog)
        editor = e_editor_dialog_get_editor (E_EDITOR_DIALOG (dialog));
        webview = WEBKIT_WEB_VIEW (
                        e_editor_get_editor_widget (editor));
+=======
+       WebKitWebView *webview;
+       gboolean found;
+
+       webview = WEBKIT_WEB_VIEW (
+                       e_editor_get_editor_widget (dialog->priv->editor));
+>>>>>>> Port Replace dialog and it's functionality
 
        found = webkit_web_view_search_text (
                webview,
@@ -90,7 +122,10 @@ editor_replace_dialog_skip_cb (EEditorReplaceDialog *dialog)
 static void
 editor_replace_dialog_replace_cb (EEditorReplaceDialog *dialog)
 {
+<<<<<<< HEAD
        EEditor *editor;
+=======
+>>>>>>> Port Replace dialog and it's functionality
        EEditorWidget *editor_widget;
        EEditorSelection *selection;
 
@@ -105,8 +140,12 @@ editor_replace_dialog_replace_cb (EEditorReplaceDialog *dialog)
                gtk_widget_hide (dialog->priv->result_label);
        }
 
+<<<<<<< HEAD
        editor = e_editor_dialog_get_editor (E_EDITOR_DIALOG (dialog));
        editor_widget = e_editor_get_editor_widget (editor);
+=======
+       editor_widget = e_editor_get_editor_widget (dialog->priv->editor);
+>>>>>>> Port Replace dialog and it's functionality
        selection = e_editor_widget_get_selection (editor_widget);
 
        e_editor_selection_replace (
@@ -119,22 +158,32 @@ editor_replace_dialog_replace_all_cb (EEditorReplaceDialog *dialog)
 {
        gint i = 0;
        gchar *result;
+<<<<<<< HEAD
        EEditor *editor;
+=======
+>>>>>>> Port Replace dialog and it's functionality
        EEditorWidget *widget;
        EEditorSelection *selection;
        const gchar *replacement;
 
+<<<<<<< HEAD
        editor = e_editor_dialog_get_editor (E_EDITOR_DIALOG (dialog));
        widget = e_editor_get_editor_widget (editor);
+=======
+       widget = e_editor_get_editor_widget (dialog->priv->editor);
+>>>>>>> Port Replace dialog and it's functionality
        selection = e_editor_widget_get_selection (widget);
        replacement = gtk_entry_get_text (GTK_ENTRY (dialog->priv->replace_entry));
 
        while (jump (dialog)) {
                e_editor_selection_replace (selection, replacement);
                i++;
+<<<<<<< HEAD
 
                /* Jump behind the word */
                e_editor_selection_move (selection, TRUE, E_EDITOR_SELECTION_GRANULARITY_WORD);
+=======
+>>>>>>> Port Replace dialog and it's functionality
        }
 
        result = g_strdup_printf (_("%d occurences replaced"), i);
@@ -144,6 +193,15 @@ editor_replace_dialog_replace_all_cb (EEditorReplaceDialog *dialog)
 }
 
 static void
+<<<<<<< HEAD
+=======
+editor_replace_dialog_close_cb (EEditorReplaceDialog *dialog)
+{
+       gtk_widget_hide (GTK_WIDGET (dialog));
+}
+
+static void
+>>>>>>> Port Replace dialog and it's functionality
 editor_replace_dialog_entry_changed (EEditorReplaceDialog *dialog)
 {
        gboolean ready;
@@ -170,6 +228,7 @@ editor_replace_dialog_show (GtkWidget *widget)
 }
 
 static void
+<<<<<<< HEAD
 e_editor_replace_dialog_class_init (EEditorReplaceDialogClass *class)
 {
        GtkWidgetClass *widget_class;
@@ -178,6 +237,59 @@ e_editor_replace_dialog_class_init (EEditorReplaceDialogClass *class)
 
        widget_class = GTK_WIDGET_CLASS (class);
        widget_class->show = editor_replace_dialog_show;
+=======
+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);
+       g_type_class_add_private (klass, sizeof (EEditorReplaceDialogPrivate));
+
+       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));
+>>>>>>> Port Replace dialog and it's functionality
 }
 
 static void
@@ -185,11 +297,24 @@ e_editor_replace_dialog_init (EEditorReplaceDialog *dialog)
 {
        GtkGrid *main_layout;
        GtkWidget *widget, *layout;
+<<<<<<< HEAD
        GtkBox *button_box;
 
        dialog->priv = E_EDITOR_REPLACE_DIALOG_GET_PRIVATE (dialog);
 
        main_layout = e_editor_dialog_get_container (E_EDITOR_DIALOG (dialog));
+=======
+
+       dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (
+                               dialog, E_TYPE_EDITOR_REPLACE_DIALOG,
+                               EEditorReplaceDialogPrivate);
+
+       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);
+>>>>>>> Port Replace dialog and it's functionality
 
        widget = gtk_entry_new ();
        gtk_grid_attach (main_layout, widget, 1, 0, 2, 1);
@@ -215,7 +340,11 @@ e_editor_replace_dialog_init (EEditorReplaceDialog *dialog)
        gtk_label_set_justify (GTK_LABEL (widget), GTK_JUSTIFY_RIGHT);
        gtk_grid_attach (main_layout, widget, 0, 1, 1, 1);
 
+<<<<<<< HEAD
        layout = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
+=======
+       layout = gtk_hbox_new (FALSE, 5);
+>>>>>>> Port Replace dialog and it's functionality
        gtk_grid_attach (main_layout, layout, 1, 2, 2, 1);
 
        widget = gtk_check_button_new_with_mnemonic (_("Search _backwards"));
@@ -234,10 +363,27 @@ e_editor_replace_dialog_init (EEditorReplaceDialog *dialog)
        gtk_grid_attach (main_layout, widget, 0, 3, 2, 1);
        dialog->priv->result_label = widget;
 
+<<<<<<< HEAD
        button_box = e_editor_dialog_get_button_box (E_EDITOR_DIALOG (dialog));
 
        widget = gtk_button_new_with_mnemonic (_("_Skip"));
        gtk_box_pack_start (button_box, widget, FALSE, FALSE, 5);
+=======
+       layout = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
+       gtk_box_set_spacing (GTK_BOX (layout), 5);
+       gtk_button_box_set_layout (GTK_BUTTON_BOX (layout), GTK_BUTTONBOX_START);
+       gtk_grid_attach (main_layout, layout, 2, 3, 1, 1);
+
+       widget = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
+       gtk_box_pack_start (GTK_BOX (layout), widget, FALSE, FALSE, 5);
+       dialog->priv->close_button = widget;
+       g_signal_connect_swapped (
+               widget, "clicked",
+               G_CALLBACK (editor_replace_dialog_close_cb), dialog);
+
+       widget = gtk_button_new_with_mnemonic (_("_Skip"));
+       gtk_box_pack_start (GTK_BOX (layout), widget, FALSE, FALSE, 5);
+>>>>>>> Port Replace dialog and it's functionality
        gtk_widget_set_sensitive (widget, FALSE);
        dialog->priv->skip_button = widget;
        g_signal_connect_swapped (
@@ -245,7 +391,11 @@ e_editor_replace_dialog_init (EEditorReplaceDialog *dialog)
                G_CALLBACK (editor_replace_dialog_skip_cb), dialog);
 
        widget = gtk_button_new_with_mnemonic (_("_Replace"));
+<<<<<<< HEAD
        gtk_box_pack_start (button_box, widget, FALSE, FALSE, 5);
+=======
+       gtk_box_pack_start (GTK_BOX (layout), widget, FALSE, FALSE, 5);
+>>>>>>> Port Replace dialog and it's functionality
        gtk_widget_set_sensitive (widget, FALSE);
        dialog->priv->replace_button = widget;
        g_signal_connect_swapped (
@@ -253,7 +403,11 @@ e_editor_replace_dialog_init (EEditorReplaceDialog *dialog)
                G_CALLBACK (editor_replace_dialog_replace_cb), dialog);
 
        widget = gtk_button_new_with_mnemonic (_("Replace _All"));
+<<<<<<< HEAD
        gtk_box_pack_start (button_box, widget, FALSE, FALSE, 5);
+=======
+       gtk_box_pack_start (GTK_BOX (layout), widget, FALSE, FALSE, 5);
+>>>>>>> Port Replace dialog and it's functionality
        gtk_widget_set_sensitive (widget, FALSE);
        dialog->priv->replace_all_button = widget;
        g_signal_connect_swapped (
@@ -269,8 +423,20 @@ e_editor_replace_dialog_new (EEditor *editor)
        return GTK_WIDGET (
                g_object_new (
                        E_TYPE_EDITOR_REPLACE_DIALOG,
+<<<<<<< HEAD
+                       "editor", editor,
+                       "icon-name", GTK_STOCK_FIND_AND_REPLACE,
+                       "title", N_("Replace"),
+=======
+                       "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,
+>>>>>>> Port Replace dialog and it's functionality
                        NULL));
 }
diff --git a/e-util/e-editor-replace-dialog.h b/e-util/e-editor-replace-dialog.h
index 4ee9f7e..807b64d 100644
--- a/e-util/e-editor-replace-dialog.h
+++ b/e-util/e-editor-replace-dialog.h
@@ -1,8 +1,11 @@
 /*
  * e-editor-replace-dialog.h
  *
+<<<<<<< HEAD
  * Copyright (C) 2012 Dan Vrátil <dvratil redhat com>
  *
+=======
+>>>>>>> Port Replace dialog and it's functionality
  * 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
@@ -25,7 +28,12 @@
 #ifndef E_EDITOR_REPLACE_DIALOG_H
 #define E_EDITOR_REPLACE_DIALOG_H
 
+<<<<<<< HEAD
 #include <e-util/e-editor-dialog.h>
+=======
+#include <gtk/gtk.h>
+#include <e-util/e-editor.h>
+>>>>>>> Port Replace dialog and it's functionality
 
 /* Standard GObject macros */
 #define E_TYPE_EDITOR_REPLACE_DIALOG \
@@ -53,17 +61,31 @@ typedef struct _EEditorReplaceDialogClass EEditorReplaceDialogClass;
 typedef struct _EEditorReplaceDialogPrivate EEditorReplaceDialogPrivate;
 
 struct _EEditorReplaceDialog {
+<<<<<<< HEAD
        EEditorDialog parent;
+=======
+       GtkWindow parent;
+
+>>>>>>> Port Replace dialog and it's functionality
        EEditorReplaceDialogPrivate *priv;
 };
 
 struct _EEditorReplaceDialogClass {
+<<<<<<< HEAD
        EEditorDialogClass parent_class;
 };
 
 GType          e_editor_replace_dialog_get_type
                                                (void) G_GNUC_CONST;
 GtkWidget *    e_editor_replace_dialog_new     (EEditor *editor);
+=======
+       GtkWindowClass parent_class;
+};
+
+GType          e_editor_replace_dialog_get_type        (void);
+
+GtkWidget*     e_editor_replace_dialog_new             (EEditor *editor);
+>>>>>>> Port Replace dialog and it's functionality
 
 G_END_DECLS
 
diff --git a/e-util/e-editor-widgets.h b/e-util/e-editor-widgets.h
index fb8bb45..6c697cf 100644
--- a/e-util/e-editor-widgets.h
+++ b/e-util/e-editor-widgets.h
@@ -123,36 +123,6 @@
 #define E_EDITOR_WIDGETS_PARAGRAPH_PROPERTIES_WINDOW(editor) \
        E_EDITOR_WIDGETS ((editor), "paragraph-properties-window")
 
-/* Replace Confirmation Window */
-#define E_EDITOR_WIDGETS_REPLACE_CONFIRMATION_CLOSE_BUTTON(editor) \
-       E_EDITOR_WIDGETS ((editor), "replace-confirmation-close-button")
-#define E_EDITOR_WIDGETS_REPLACE_CONFIRMATION_NEXT_BUTTON(editor) \
-       E_EDITOR_WIDGETS ((editor), "replace-confirmation-next-button")
-#define E_EDITOR_WIDGETS_REPLACE_CONFIRMATION_REPLACE_BUTTON(editor) \
-       E_EDITOR_WIDGETS ((editor), "replace-confirmation-replace-button")
-#define E_EDITOR_WIDGETS_REPLACE_CONFIRMATION_REPLACE_ALL_BUTTON(editor) \
-       E_EDITOR_WIDGETS ((editor), "replace-confirmation-replace-all-button")
-#define E_EDITOR_WIDGETS_REPLACE_CONFIRMATION_WINDOW(editor) \
-       E_EDITOR_WIDGETS ((editor), "replace-confirmation-window")
-
-/* Replace Window */
-#define E_EDITOR_WIDGETS_REPLACE_BACKWARDS(editor) \
-       E_EDITOR_WIDGETS ((editor), "replace-backwards")
-#define E_EDITOR_WIDGETS_REPLACE_BUTTON(editor) \
-       E_EDITOR_WIDGETS ((editor), "replace-button")
-#define E_EDITOR_WIDGETS_REPLACE_CASE_SENSITIVE(editor) \
-       E_EDITOR_WIDGETS ((editor), "replace-case-sensitive")
-#define E_EDITOR_WIDGETS_REPLACE_ENTRY(editor) \
-       E_EDITOR_WIDGETS ((editor), "replace-entry")
-#define E_EDITOR_WIDGETS_REPLACE_WITH_ENTRY(editor) \
-       E_EDITOR_WIDGETS ((editor), "replace-with-entry")
-#define E_EDITOR_WIDGETS_REPLACE_WINDOW(editor) \
-       E_EDITOR_WIDGETS ((editor), "replace-window")
-#define E_EDITOR_WIDGETS_REPLACE_WRAP(editor) \
-       E_EDITOR_WIDGETS ((editor), "replace-wrap")
-#define E_EDITOR_WIDGETS_REPLACE_ONLY_SELECTION(editor) \
-       E_EDITOR_WIDGETS ((editor), "replace-only-selection")
-
 /* Rule Properties Window */
 #define E_EDITOR_WIDGETS_RULE_PROPERTIES_ALIGNMENT_COMBO_BOX(editor) \
        E_EDITOR_WIDGETS ((editor), "rule-properties-alignment-combo-box")
diff --git a/e-util/e-util.h b/e-util/e-util.h
index 86da9dc..2a8dbbf 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -93,6 +93,7 @@
 #include <e-util/e-dialog-widgets.h>
 #include <e-util/e-editor-actions.h>
 #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-widget.h>
 #include <e-util/e-editor-widgets.h>


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