[evolution/webkit-composer-rebased: 22/105] Make (Un)indent actions work
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/webkit-composer-rebased: 22/105] Make (Un)indent actions work
- Date: Thu, 13 Dec 2012 17:14:24 +0000 (UTC)
commit e65ab792cc06112eeab530c08bc21a9f8f6306b5
Author: Dan VrÃtil <dvratil redhat com>
Date: Fri Aug 3 12:25:35 2012 +0200
Make (Un)indent actions work
Sensitivity of Unindent action is binded to 'indented' property
of EEditorSelection, so it's controlled automatically.
e-util/e-editor-actions.c | 18 +++++----------
e-util/e-editor-selection.c | 51 +++++++++++++++++++++++++++++++++++++++++++
e-util/e-editor-selection.h | 4 +++
3 files changed, 61 insertions(+), 12 deletions(-)
---
diff --git a/e-util/e-editor-actions.c b/e-util/e-editor-actions.c
index 0d78ff1..0043dda 100644
--- a/e-util/e-editor-actions.c
+++ b/e-util/e-editor-actions.c
@@ -564,11 +564,7 @@ static void
action_indent_cb (GtkAction *action,
EEditor *editor)
{
- WebKitDOMDocument *document;
-
- document = webkit_web_view_get_dom_document (
- WEBKIT_WEB_VIEW (e_editor_get_editor_widget (editor)));
- webkit_dom_document_exec_command (document, "indent", FALSE, "");
+ e_editor_selection_indent (editor->priv->selection);
}
static void
@@ -1126,12 +1122,7 @@ static void
action_unindent_cb (GtkAction *action,
EEditor *editor)
{
- WebKitDOMDocument *document;
-
- document = webkit_web_view_get_dom_document (
- WEBKIT_WEB_VIEW (e_editor_get_editor_widget (editor)));
- webkit_dom_document_exec_command (
- document, "outdent", FALSE, "");
+ e_editor_selection_unindent (editor->priv->selection);
}
static void
@@ -2176,12 +2167,15 @@ editor_actions_init (EEditor *editor)
editor->priv->selection, "alignment",
ACTION (JUSTIFY_LEFT), "current-value",
G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
-
g_object_bind_property (
editor->priv->selection, "bold",
ACTION (BOLD), "active",
G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
g_object_bind_property (
+ editor->priv->selection, "indented",
+ ACTION (UNINDENT), "sensitive",
+ G_BINDING_SYNC_CREATE);
+ g_object_bind_property (
editor->priv->selection, "italic",
ACTION (ITALIC), "active",
G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
diff --git a/e-util/e-editor-selection.c b/e-util/e-editor-selection.c
index 78eba97..086f6a9 100644
--- a/e-util/e-editor-selection.c
+++ b/e-util/e-editor-selection.c
@@ -59,6 +59,7 @@ enum {
PROP_FONT_SIZE,
PROP_FONT_COLOR,
PROP_BLOCK_FORMAT,
+ PROP_INDENTED,
PROP_ITALIC,
PROP_MONOSPACED,
PROP_STRIKE_THROUGH,
@@ -141,6 +142,7 @@ webview_selection_changed (WebKitWebView *webview,
g_object_notify (G_OBJECT (selection), "font-size");
g_object_notify (G_OBJECT (selection), "font-color");
g_object_notify (G_OBJECT (selection), "block-format");
+ g_object_notify (G_OBJECT (selection), "indented");
g_object_notify (G_OBJECT (selection), "italic");
g_object_notify (G_OBJECT (selection), "monospaced");
g_object_notify (G_OBJECT (selection), "strike-through");
@@ -207,6 +209,11 @@ e_editor_selection_get_property (GObject *object,
e_editor_selection_get_block_format (selection));
return;
+ case PROP_INDENTED:
+ g_value_set_boolean (value,
+ e_editor_selection_get_indented (selection));
+ return;
+
case PROP_ITALIC:
g_value_set_boolean (value,
e_editor_selection_get_italic (selection));
@@ -435,6 +442,16 @@ e_editor_selection_class_init (EEditorSelectionClass *klass)
g_object_class_install_property (
object_class,
+ PROP_INDENTED,
+ g_param_spec_boolean (
+ "indented",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READABLE));
+
+ g_object_class_install_property (
+ object_class,
PROP_ITALIC,
g_param_spec_boolean (
"italic",
@@ -916,6 +933,40 @@ e_editor_selection_set_font_size (EEditorSelection *selection,
}
gboolean
+e_editor_selection_get_indented (EEditorSelection *selection)
+{
+ g_return_val_if_fail (E_IS_EDITOR_SELECTION (selection), FALSE);
+
+ return get_has_style (selection, "blockquote");
+}
+
+void
+e_editor_selection_indent (EEditorSelection *selection)
+{
+ WebKitDOMDocument *document;
+
+ g_return_if_fail (E_IS_EDITOR_SELECTION (selection));
+
+ document = webkit_web_view_get_dom_document (selection->priv->webview);
+ webkit_dom_document_exec_command (document, "indent", FALSE, "");
+
+ g_object_notify (G_OBJECT (selection), "indented");
+}
+
+void
+e_editor_selection_unindent (EEditorSelection *selection)
+{
+ WebKitDOMDocument *document;
+
+ g_return_if_fail (E_IS_EDITOR_SELECTION (selection));
+
+ document = webkit_web_view_get_dom_document (selection->priv->webview);
+ webkit_dom_document_exec_command (document, "outdent", FALSE, "");
+
+ g_object_notify (G_OBJECT (selection), "indented");
+}
+
+gboolean
e_editor_selection_get_italic (EEditorSelection *selection)
{
g_return_val_if_fail (E_IS_EDITOR_SELECTION (selection), FALSE);
diff --git a/e-util/e-editor-selection.h b/e-util/e-editor-selection.h
index 8e732c2..a7164e8 100644
--- a/e-util/e-editor-selection.h
+++ b/e-util/e-editor-selection.h
@@ -141,6 +141,10 @@ EEditorSelectionBlockFormat
e_editor_selection_get_block_format
(EEditorSelection *selection);
+gboolean e_editor_selection_get_indented (EEditorSelection *selection);
+void e_editor_selection_indent (EEditorSelection *selection);
+void e_editor_selection_unindent (EEditorSelection *selection);
+
void e_editor_selection_set_italic (EEditorSelection *selection,
gboolean italic);
gboolean e_editor_selection_get_italic (EEditorSelection *selection);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]