[evolution/449-support-markdown-in-composer] Composer: Hide actions unrelated to Markdown modes
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/449-support-markdown-in-composer] Composer: Hide actions unrelated to Markdown modes
- Date: Tue, 8 Feb 2022 11:02:30 +0000 (UTC)
commit 65c1900141f3606e634cf3815045f38ec0bcfcdb
Author: Milan Crha <mcrha redhat com>
Date: Tue Feb 8 12:01:43 2022 +0100
Composer: Hide actions unrelated to Markdown modes
src/composer/e-composer-actions.c | 25 ++++++++++++
src/e-util/e-html-editor-private.h | 1 +
src/e-util/e-html-editor.c | 79 ++++++++++++++++++++++++++++++++++++++
3 files changed, 105 insertions(+)
---
diff --git a/src/composer/e-composer-actions.c b/src/composer/e-composer-actions.c
index 9e59844936..67adb5e15d 100644
--- a/src/composer/e-composer-actions.c
+++ b/src/composer/e-composer-actions.c
@@ -569,6 +569,24 @@ eca_transform_mode_html_to_boolean_cb (GBinding *binding,
return TRUE;
}
+static gboolean
+eca_mode_to_bool_hide_in_markdown_cb (GBinding *binding,
+ const GValue *from_value,
+ GValue *to_value,
+ gpointer user_data)
+{
+ EContentEditorMode mode;
+
+ mode = g_value_get_enum (from_value);
+
+ g_value_set_boolean (to_value,
+ mode != E_CONTENT_EDITOR_MODE_MARKDOWN &&
+ mode != E_CONTENT_EDITOR_MODE_MARKDOWN_PLAIN_TEXT &&
+ mode != E_CONTENT_EDITOR_MODE_MARKDOWN_HTML);
+
+ return TRUE;
+}
+
void
e_composer_actions_init (EMsgComposer *composer)
{
@@ -724,6 +742,13 @@ e_composer_actions_init (EMsgComposer *composer)
e_html_editor_get_action (editor, "visually-wrap-long-lines"), "active",
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
+ e_binding_bind_property_full (
+ editor, "mode",
+ e_html_editor_get_action (editor, "visually-wrap-long-lines"), "visible",
+ G_BINDING_SYNC_CREATE,
+ eca_mode_to_bool_hide_in_markdown_cb,
+ NULL, NULL, NULL);
+
#if defined (ENABLE_SMIME)
visible = TRUE;
#else
diff --git a/src/e-util/e-html-editor-private.h b/src/e-util/e-html-editor-private.h
index 23a4dc435d..8c95c57f95 100644
--- a/src/e-util/e-html-editor-private.h
+++ b/src/e-util/e-html-editor-private.h
@@ -86,6 +86,7 @@ struct _EHTMLEditorPrivate {
GtkWidget *fg_color_combo_box;
GtkWidget *bg_color_combo_box;
GtkWidget *mode_combo_box;
+ GtkToolItem *mode_tool_item;
GtkWidget *size_combo_box;
GtkWidget *style_combo_box;
GtkWidget *font_name_combo_box;
diff --git a/src/e-util/e-html-editor.c b/src/e-util/e-html-editor.c
index 8c5c4003ab..b2898fd4b6 100644
--- a/src/e-util/e-html-editor.c
+++ b/src/e-util/e-html-editor.c
@@ -765,6 +765,24 @@ html_editor_get_paste_plain_prefer_pre (EHTMLEditor *editor)
return editor->priv->paste_plain_prefer_pre;
}
+static gboolean
+e_html_editor_mode_to_bool_hide_in_markdown_cb (GBinding *binding,
+ const GValue *from_value,
+ GValue *to_value,
+ gpointer user_data)
+{
+ EContentEditorMode mode;
+
+ mode = g_value_get_enum (from_value);
+
+ g_value_set_boolean (to_value,
+ mode != E_CONTENT_EDITOR_MODE_MARKDOWN &&
+ mode != E_CONTENT_EDITOR_MODE_MARKDOWN_PLAIN_TEXT &&
+ mode != E_CONTENT_EDITOR_MODE_MARKDOWN_HTML);
+
+ return TRUE;
+}
+
static void
html_editor_set_property (GObject *object,
guint property_id,
@@ -925,6 +943,7 @@ html_editor_constructed (GObject *object)
gtk_widget_set_tooltip_text (widget, _("Editing Mode"));
gtk_toolbar_insert (toolbar, tool_item, 0);
priv->mode_combo_box = g_object_ref (widget);
+ priv->mode_tool_item = g_object_ref (tool_item);
gtk_widget_show_all (GTK_WIDGET (tool_item));
/* Add some combo boxes to the "html" toolbar. */
@@ -969,6 +988,41 @@ html_editor_constructed (GObject *object)
priv->font_name_combo_box = g_object_ref (widget);
gtk_widget_show_all (GTK_WIDGET (tool_item));
+ e_binding_bind_property_full (
+ editor, "mode",
+ E_HTML_EDITOR_ACTION (editor, "paragraph-style-menu"), "visible",
+ G_BINDING_SYNC_CREATE,
+ e_html_editor_mode_to_bool_hide_in_markdown_cb,
+ NULL, NULL, NULL);
+
+ e_binding_bind_property_full (
+ editor, "mode",
+ E_HTML_EDITOR_ACTION (editor, "justify-menu"), "visible",
+ G_BINDING_SYNC_CREATE,
+ e_html_editor_mode_to_bool_hide_in_markdown_cb,
+ NULL, NULL, NULL);
+
+ e_binding_bind_property_full (
+ editor, "mode",
+ E_HTML_EDITOR_ACTION_WRAP_LINES (editor), "visible",
+ G_BINDING_SYNC_CREATE,
+ e_html_editor_mode_to_bool_hide_in_markdown_cb,
+ NULL, NULL, NULL);
+
+ e_binding_bind_property_full (
+ editor, "mode",
+ E_HTML_EDITOR_ACTION_INDENT (editor), "visible",
+ G_BINDING_SYNC_CREATE,
+ e_html_editor_mode_to_bool_hide_in_markdown_cb,
+ NULL, NULL, NULL);
+
+ e_binding_bind_property_full (
+ editor, "mode",
+ E_HTML_EDITOR_ACTION_UNINDENT (editor), "visible",
+ G_BINDING_SYNC_CREATE,
+ e_html_editor_mode_to_bool_hide_in_markdown_cb,
+ NULL, NULL, NULL);
+
g_signal_connect_after (object, "realize", G_CALLBACK (html_editor_realize), NULL);
settings = e_util_ref_settings ("org.gnome.evolution.mail");
@@ -1010,6 +1064,7 @@ html_editor_dispose (GObject *object)
g_clear_object (&priv->fg_color_combo_box);
g_clear_object (&priv->bg_color_combo_box);
g_clear_object (&priv->mode_combo_box);
+ g_clear_object (&priv->mode_tool_item);
g_clear_object (&priv->size_combo_box);
g_clear_object (&priv->font_name_combo_box);
g_clear_object (&priv->style_combo_box);
@@ -1632,10 +1687,34 @@ e_html_editor_set_mode (EHTMLEditor *editor,
e_weak_ref_new (editor));
gtk_widget_hide (GTK_WIDGET (editor->priv->use_content_editor));
+
+ if (E_IS_MARKDOWN_EDITOR (editor->priv->use_content_editor)) {
+ GtkToolbar *toolbar;
+
+ toolbar = e_markdown_editor_get_action_toolbar (E_MARKDOWN_EDITOR
(editor->priv->use_content_editor));
+ gtk_container_remove (GTK_CONTAINER (toolbar), GTK_WIDGET
(editor->priv->mode_tool_item));
+
+ toolbar = GTK_TOOLBAR (editor->priv->edit_toolbar);
+ gtk_toolbar_insert (toolbar, editor->priv->mode_tool_item, 0);
+
+ gtk_widget_show (GTK_WIDGET (editor->priv->edit_toolbar));
+ }
}
gtk_widget_show (GTK_WIDGET (cnt_editor));
+ if (E_IS_MARKDOWN_EDITOR (cnt_editor)) {
+ GtkToolbar *toolbar;
+
+ toolbar = GTK_TOOLBAR (editor->priv->edit_toolbar);
+ gtk_container_remove (GTK_CONTAINER (toolbar), GTK_WIDGET
(editor->priv->mode_tool_item));
+
+ toolbar = e_markdown_editor_get_action_toolbar (E_MARKDOWN_EDITOR
(cnt_editor));
+ gtk_toolbar_insert (toolbar, editor->priv->mode_tool_item, 0);
+
+ gtk_widget_hide (GTK_WIDGET (editor->priv->edit_toolbar));
+ }
+
if (is_focused)
e_content_editor_grab_focus (cnt_editor);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]