[evolution/webkit-composer: 66/231] Port EMailSignatureEditor to EEditorWindow
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/webkit-composer: 66/231] Port EMailSignatureEditor to EEditorWindow
- Date: Fri, 13 Sep 2013 14:11:32 +0000 (UTC)
commit ae84cfefc2592f1d7c113da887a193445435d118
Author: Dan Vrátil <dvratil redhat com>
Date: Mon Aug 27 17:23:07 2012 +0200
Port EMailSignatureEditor to EEditorWindow
e-util/e-mail-signature-editor.c | 135 ++++++++++++++++++-------------------
e-util/e-mail-signature-editor.h | 5 +-
e-util/e-mail-signature-manager.c | 2 +-
3 files changed, 69 insertions(+), 73 deletions(-)
---
diff --git a/e-util/e-mail-signature-editor.c b/e-util/e-mail-signature-editor.c
index c4a3c44..95f2028 100644
--- a/e-util/e-mail-signature-editor.c
+++ b/e-util/e-mail-signature-editor.c
@@ -28,7 +28,6 @@
#include "e-alert-dialog.h"
#include "e-alert-sink.h"
#include "e-alert-bar.h"
-#include "e-editor.h"
#define E_MAIL_SIGNATURE_EDITOR_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
@@ -44,8 +43,6 @@ struct _EMailSignatureEditorPrivate {
ESource *source;
gchar *original_name;
- EEditor *editor;
-
GtkWidget *entry; /* not referenced */
GtkWidget *alert_bar; /* not referenced */
};
@@ -89,7 +86,7 @@ static void e_mail_signature_editor_alert_sink_init
G_DEFINE_TYPE_WITH_CODE (
EMailSignatureEditor,
e_mail_signature_editor,
- GTK_TYPE_WINDOW,
+ E_TYPE_EDITOR_WINDOW,
G_IMPLEMENT_INTERFACE (
E_TYPE_ALERT_SINK,
e_mail_signature_editor_alert_sink_init))
@@ -113,10 +110,11 @@ mail_signature_editor_loaded_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
+ EEditor *editor;
EEditorWidget *editor_widget;
EEditorSelection *editor_selection;
ESource *source;
- EMailSignatureEditor *editor;
+ EMailSignatureEditor *window;
ESourceMailSignature *extension;
const gchar *extension_name;
const gchar *mime_type;
@@ -125,7 +123,7 @@ mail_signature_editor_loaded_cb (GObject *object,
GError *error = NULL;
source = E_SOURCE (object);
- editor = E_MAIL_SIGNATURE_EDITOR (user_data);
+ window = E_MAIL_SIGNATURE_EDITOR (user_data);
e_source_mail_signature_load_finish (
source, result, &contents, NULL, &error);
@@ -133,17 +131,17 @@ mail_signature_editor_loaded_cb (GObject *object,
/* Ignore cancellations. */
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
g_warn_if_fail (contents == NULL);
- g_object_unref (editor);
+ g_object_unref (window);
g_error_free (error);
return;
} else if (error != NULL) {
g_warn_if_fail (contents == NULL);
e_alert_submit (
- E_ALERT_SINK (editor),
+ E_ALERT_SINK (window),
"widgets:no-load-signature",
error->message, NULL);
- g_object_unref (editor);
+ g_object_unref (window);
g_error_free (error);
return;
}
@@ -156,7 +154,8 @@ mail_signature_editor_loaded_cb (GObject *object,
mime_type = e_source_mail_signature_get_mime_type (extension);
is_html = (g_strcmp0 (mime_type, "text/html") == 0);
- editor_widget = e_editor_get_editor_widget (editor->priv->editor);
+ editor = e_editor_window_get_editor (E_EDITOR_WINDOW (object));
+ editor_widget = e_editor_get_editor_widget (editor);
e_editor_widget_set_mode (editor_widget,
(is_html) ? E_EDITOR_WIDGET_MODE_HTML : E_EDITOR_WIDGET_MODE_PLAIN_TEXT);
@@ -169,7 +168,7 @@ mail_signature_editor_loaded_cb (GObject *object,
g_free (contents);
- g_object_unref (editor);
+ g_object_unref (window);
}
static gboolean
@@ -188,16 +187,18 @@ mail_signature_editor_delete_event_cb (EMailSignatureEditor *editor,
static void
action_close_cb (GtkAction *action,
- EMailSignatureEditor *editor)
+ EMailSignatureEditor *window)
{
+ EEditor *editor;
EEditorWidget *editor_widget;
gboolean something_changed = FALSE;
const gchar *original_name;
const gchar *signature_name;
- original_name = editor->priv->original_name;
- signature_name = gtk_entry_get_text (GTK_ENTRY (editor->priv->entry));
- editor_widget = e_editor_get_editor_widget (editor->priv->editor);
+ original_name = window->priv->original_name;
+ signature_name = gtk_entry_get_text (GTK_ENTRY (window->priv->entry));
+ editor = e_editor_window_get_editor (E_EDITOR_WINDOW (window));
+ editor_widget = e_editor_get_editor_widget (editor);
something_changed |= webkit_web_view_can_undo (WEBKIT_WEB_VIEW (editor_widget));
something_changed |= (strcmp (signature_name, original_name) != 0);
@@ -206,12 +207,12 @@ action_close_cb (GtkAction *action,
gint response;
response = e_alert_run_dialog_for_args (
- GTK_WINDOW (editor),
+ GTK_WINDOW (window),
"widgets:ask-signature-changed", NULL);
if (response == GTK_RESPONSE_YES) {
GtkActionGroup *action_group;
- action_group = editor->priv->action_group;
+ action_group = window->priv->action_group;
action = gtk_action_group_get_action (
action_group, "save-and-close");
gtk_action_activate (action);
@@ -220,7 +221,7 @@ action_close_cb (GtkAction *action,
return;
}
- gtk_widget_destroy (GTK_WIDGET (editor));
+ gtk_widget_destroy (GTK_WIDGET (window));
}
static void
@@ -478,9 +479,10 @@ mail_signature_editor_finalize (GObject *object)
static void
mail_signature_editor_constructed (GObject *object)
{
- EMailSignatureEditor *editor;
+ EMailSignatureEditor *window;
GtkActionGroup *action_group;
EFocusTracker *focus_tracker;
+ EEditor *editor;
EEditorWidget *editor_widget;
GtkUIManager *ui_manager;
GDBusObject *dbus_object;
@@ -495,11 +497,11 @@ mail_signature_editor_constructed (GObject *object)
G_OBJECT_CLASS (e_mail_signature_editor_parent_class)->
constructed (object);
- editor = E_MAIL_SIGNATURE_EDITOR (object);
- editor->priv->editor = E_EDITOR (e_editor_new ());
- editor_widget = e_editor_get_editor_widget (editor->priv->editor);
+ window = E_MAIL_SIGNATURE_EDITOR (object);
+ editor = e_editor_window_get_editor (E_EDITOR_WINDOW (window));
+ editor_widget = e_editor_get_editor_widget (editor);
- ui_manager = e_editor_get_ui_manager (editor->priv->editor);
+ ui_manager = e_editor_get_ui_manager (editor);
/* Because we are loading from a hard-coded string, there is
* no chance of I/O errors. Failure here implies a malformed
@@ -513,25 +515,25 @@ mail_signature_editor_constructed (GObject *object)
action_group, GETTEXT_PACKAGE);
gtk_action_group_add_actions (
action_group, entries,
- G_N_ELEMENTS (entries), editor);
+ G_N_ELEMENTS (entries), window);
gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
- editor->priv->action_group = g_object_ref (action_group);
+ window->priv->action_group = g_object_ref (action_group);
/* Hide page properties because it is not inherited in the mail. */
- action = e_editor_get_action (editor->priv->editor, "properties-page");
+ action = e_editor_get_action (editor, "properties-page");
gtk_action_set_visible (action, FALSE);
- action = e_editor_get_action (editor->priv->editor, "context-properties-page");
+ action = e_editor_get_action (editor, "context-properties-page");
gtk_action_set_visible (action, FALSE);
gtk_ui_manager_ensure_update (ui_manager);
- gtk_window_set_title (GTK_WINDOW (editor), _("Edit Signature"));
+ gtk_window_set_title (GTK_WINDOW (window), _("Edit Signature"));
/* Construct the signature name entry. */
container = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
- gtk_container_add (GTK_CONTAINER (editor), container);
+ e_editor_window_pack_above (E_EDITOR_WINDOW (window), container);
gtk_widget_show (container);
/* Construct the alert bar for errors. */
@@ -539,76 +541,64 @@ mail_signature_editor_constructed (GObject *object)
gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
/* Position 5 should be between the style toolbar and editing area. */
gtk_box_reorder_child (GTK_BOX (container), widget, 5);
- editor->priv->alert_bar = widget; /* not referenced */
+ window->priv->alert_bar = widget; /* not referenced */
/* EAlertBar controls its own visibility. */
- gtk_box_pack_end (
- GTK_BOX (container), GTK_WIDGET (editor->priv->editor), TRUE, TRUE, 0);
- gtk_widget_show (GTK_WIDGET (editor->priv->editor));
-
widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_container_set_border_width (GTK_CONTAINER (widget), 6);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- /* Position 2 should be between the main and style toolbars. */
- gtk_box_reorder_child (GTK_BOX (container), widget, 2);
+ e_editor_window_pack_above (E_EDITOR_WINDOW (window), widget);
gtk_widget_show (widget);
container = widget;
- gtk_widget_show (container);
widget = gtk_entry_new ();
gtk_box_pack_end (GTK_BOX (container), widget, TRUE, TRUE, 0);
- editor->priv->entry = widget; /* not referenced */
+ window->priv->entry = widget; /* not referenced */
gtk_widget_show (widget);
widget = gtk_label_new_with_mnemonic (_("_Signature Name:"));
- gtk_label_set_mnemonic_widget (GTK_LABEL (widget), editor->priv->entry);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (widget), window->priv->entry);
gtk_box_pack_end (GTK_BOX (container), widget, FALSE, FALSE, 0);
gtk_widget_show (widget);
g_signal_connect (
- editor, "delete-event",
+ window, "delete-event",
G_CALLBACK (mail_signature_editor_delete_event_cb), NULL);
- /* Configure an EFocusTracker to manage selection actions.
- *
- * XXX GtkhtmlEditor does not manage its own selection actions,
- * which is technically a bug but works in our favor here
- * because it won't cause any conflicts with EFocusTracker. */
-
- focus_tracker = e_focus_tracker_new (GTK_WINDOW (editor));
+ /* Configure an EFocusTracker to manage selection actions. */
+ focus_tracker = e_focus_tracker_new (GTK_WINDOW (window));
- action = e_editor_get_action (editor->priv->editor, "cut");
+ action = e_editor_get_action (editor, "cut");
e_focus_tracker_set_cut_clipboard_action (focus_tracker, action);
- action = e_editor_get_action (editor->priv->editor, "copy");
+ action = e_editor_get_action (editor, "copy");
e_focus_tracker_set_copy_clipboard_action (focus_tracker, action);
- action = e_editor_get_action (editor->priv->editor, "paste");
+ action = e_editor_get_action (editor, "paste");
e_focus_tracker_set_paste_clipboard_action (focus_tracker, action);
- action = e_editor_get_action (editor->priv->editor, "select-all");
+ action = e_editor_get_action (editor, "select-all");
e_focus_tracker_set_select_all_action (focus_tracker, action);
- editor->priv->focus_tracker = focus_tracker;
+ window->priv->focus_tracker = focus_tracker;
- source = e_mail_signature_editor_get_source (editor);
+ source = e_mail_signature_editor_get_source (window);
display_name = e_source_get_display_name (source);
if (display_name == NULL || *display_name == '\0')
display_name = _("Unnamed");
/* Set the entry text before we grab focus. */
- g_free (editor->priv->original_name);
- editor->priv->original_name = g_strdup (display_name);
- gtk_entry_set_text (GTK_ENTRY (editor->priv->entry), display_name);
+ g_free (window->priv->original_name);
+ window->priv->original_name = g_strdup (display_name);
+ gtk_entry_set_text (GTK_ENTRY (window->priv->entry), display_name);
/* Set the focus appropriately. If this is a new signature, draw
* the user's attention to the signature name entry. Otherwise go
* straight to the editing area. */
if (source == NULL) {
- gtk_widget_grab_focus (editor->priv->entry);
+ gtk_widget_grab_focus (window->priv->entry);
} else {
gtk_widget_grab_focus (GTK_WIDGET (editor_widget));
}
@@ -626,10 +616,10 @@ mail_signature_editor_constructed (GObject *object)
G_PRIORITY_DEFAULT,
cancellable,
mail_signature_editor_loaded_cb,
- g_object_ref (editor));
+ g_object_ref (window));
- g_warn_if_fail (editor->priv->cancellable == NULL);
- editor->priv->cancellable = cancellable;
+ g_warn_if_fail (window->priv->cancellable == NULL);
+ window->priv->cancellable = cancellable;
g_object_unref (dbus_object);
}
@@ -822,7 +812,7 @@ mail_signature_editor_commit_cb (GObject *object,
}
void
-e_mail_signature_editor_commit (EMailSignatureEditor *editor,
+e_mail_signature_editor_commit (EMailSignatureEditor *window,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
@@ -835,14 +825,16 @@ e_mail_signature_editor_commit (EMailSignatureEditor *editor,
const gchar *extension_name;
const gchar *mime_type;
gchar *contents;
+ EEditor *editor;
EEditorWidget *editor_widget;
EEditorWidgetMode mode;
- g_return_if_fail (E_IS_MAIL_SIGNATURE_EDITOR (editor));
+ g_return_if_fail (E_IS_MAIL_SIGNATURE_EDITOR (window));
- registry = e_mail_signature_editor_get_registry (editor);
- source = e_mail_signature_editor_get_source (editor);
- editor_widget = e_editor_get_editor_widget (editor->priv->editor);
+ registry = e_mail_signature_editor_get_registry (window);
+ source = e_mail_signature_editor_get_source (window);
+ editor = e_editor_window_get_editor (E_EDITOR_WINDOW (window));
+ editor_widget = e_editor_get_editor_widget (editor);
mode = e_editor_widget_get_mode (editor_widget);
if (mode == E_EDITOR_WIDGET_MODE_HTML) {
@@ -866,7 +858,7 @@ e_mail_signature_editor_commit (EMailSignatureEditor *editor,
async_context->cancellable = g_object_ref (cancellable);
simple = g_simple_async_result_new (
- G_OBJECT (editor), callback, user_data,
+ G_OBJECT (window), callback, user_data,
e_mail_signature_editor_commit);
g_simple_async_result_set_op_res_gpointer (
@@ -898,9 +890,12 @@ e_mail_signature_editor_commit_finish (EMailSignatureEditor *editor,
}
EEditorWidget *
-e_mail_signature_editor_get_editor_widget (EMailSignatureEditor *editor)
+e_mail_signature_editor_get_editor_widget (EMailSignatureEditor *window)
{
- g_return_val_if_fail (E_IS_MAIL_SIGNATURE_EDITOR (editor), NULL);
+ EEditor *editor;
+
+ g_return_val_if_fail (E_IS_MAIL_SIGNATURE_EDITOR (window), NULL);
- return e_editor_get_editor_widget (editor->priv->editor);
+ editor = e_editor_window_get_editor (E_EDITOR_WINDOW (window));
+ return e_editor_get_editor_widget (editor);
}
diff --git a/e-util/e-mail-signature-editor.h b/e-util/e-mail-signature-editor.h
index 0d689f9..0b9cacc 100644
--- a/e-util/e-mail-signature-editor.h
+++ b/e-util/e-mail-signature-editor.h
@@ -26,6 +26,7 @@
#include <libedataserver/libedataserver.h>
#include <e-util/e-editor-widget.h>
+#include <e-util/e-editor-window.h>
#include <e-util/e-focus-tracker.h>
/* Standard GObject macros */
@@ -54,12 +55,12 @@ typedef struct _EMailSignatureEditorClass EMailSignatureEditorClass;
typedef struct _EMailSignatureEditorPrivate EMailSignatureEditorPrivate;
struct _EMailSignatureEditor {
- GtkWindow parent;
+ EEditorWindow parent;
EMailSignatureEditorPrivate *priv;
};
struct _EMailSignatureEditorClass {
- GtkWindowClass parent_class;
+ EEditorWindowClass parent_class;
};
GType e_mail_signature_editor_get_type
diff --git a/e-util/e-mail-signature-manager.c b/e-util/e-mail-signature-manager.c
index 937d41e..54ca3be 100644
--- a/e-util/e-mail-signature-manager.c
+++ b/e-util/e-mail-signature-manager.c
@@ -444,8 +444,8 @@ mail_signature_manager_editor_created (EMailSignatureManager *manager,
gtk_window_set_transient_for (GTK_WINDOW (editor), parent);
gtk_window_set_position (GTK_WINDOW (editor), position);
- gtk_widget_show (GTK_WIDGET (editor));
gtk_widget_set_size_request (GTK_WIDGET (editor), 450, 300);
+ gtk_widget_show (GTK_WIDGET (editor));
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]