[evolution/wip/webkit-composer] Hide insensitive paragraph styles in the Plain Text mode



commit c052e6bf80ede1466c6c4eee36fbf13850f7dde2
Author: Milan Crha <mcrha redhat com>
Date:   Wed Mar 19 11:01:20 2014 +0100

    Hide insensitive paragraph styles in the Plain Text mode
    
    Instead of showing a complete list of paragraph styles with some
    insensitive in the Plain Text mode, hide those insensitive completely.
    It makes the UI nicer and doesn't confuse users with options, which
    are not applicable in the Plain Text mode, the same way as the HTML
    toolbar is hidden.

 e-util/e-action-combo-box.c |   30 +++++++++++++++++++++++++-----
 e-util/e-action-combo-box.h |    1 +
 e-util/e-editor-actions.c   |   12 ++++++++++++
 e-util/e-editor.c           |    8 ++++++++
 e-util/e-editor.h           |    1 +
 5 files changed, 47 insertions(+), 5 deletions(-)
---
diff --git a/e-util/e-action-combo-box.c b/e-util/e-action-combo-box.c
index 9967124..b7eba30 100644
--- a/e-util/e-action-combo-box.c
+++ b/e-util/e-action-combo-box.c
@@ -244,13 +244,25 @@ action_combo_box_update_model (EActionComboBox *combo_box)
                GtkRadioAction *action = list->data;
                GtkTreePath *path;
                GtkTreeIter iter;
-               gchar *icon_name;
-               gchar *stock_id;
+               gchar *icon_name = NULL;
+               gchar *stock_id = NULL;
+               gboolean visible = FALSE;
                gint value;
 
-               g_object_get (
-                       action, "icon-name", &icon_name,
-                       "stock-id", &stock_id, NULL);
+               g_object_get (action,
+                       "icon-name", &icon_name,
+                       "stock-id", &stock_id,
+                       "visible", &visible,
+                       NULL);
+
+               if (!visible) {
+                       g_free (icon_name);
+                       g_free (stock_id);
+
+                       list = g_slist_next (list);
+                       continue;
+               }
+
                combo_box->priv->group_has_icons |=
                        (icon_name != NULL || stock_id != NULL);
                g_free (icon_name);
@@ -582,3 +594,11 @@ e_action_combo_box_add_separator_after (EActionComboBox *combo_box,
                GTK_LIST_STORE (model), &iter, COLUMN_ACTION,
                NULL, COLUMN_SORT, (gfloat) action_value + 0.5, -1);
 }
+
+void
+e_action_combo_box_update_model (EActionComboBox *combo_box)
+{
+       g_return_if_fail (E_IS_ACTION_COMBO_BOX (combo_box));
+
+       action_combo_box_update_model (combo_box);
+}
diff --git a/e-util/e-action-combo-box.h b/e-util/e-action-combo-box.h
index f3a5a0b..3a44ed7 100644
--- a/e-util/e-action-combo-box.h
+++ b/e-util/e-action-combo-box.h
@@ -81,6 +81,7 @@ void          e_action_combo_box_add_separator_before
 void           e_action_combo_box_add_separator_after
                                                (EActionComboBox *combo_box,
                                                 gint action_value);
+void           e_action_combo_box_update_model (EActionComboBox *combo_box);
 
 G_END_DECLS
 
diff --git a/e-util/e-editor-actions.c b/e-util/e-editor-actions.c
index 917881e..06881aa 100644
--- a/e-util/e-editor-actions.c
+++ b/e-util/e-editor-actions.c
@@ -643,6 +643,7 @@ action_mode_cb (GtkRadioAction *action,
 {
        GtkActionGroup *action_group;
        EEditorWidget *editor_widget;
+       GtkWidget *style_combo_box;
        gboolean is_html;
 
        editor_widget = e_editor_get_editor_widget (editor);
@@ -668,12 +669,23 @@ action_mode_cb (GtkRadioAction *action,
 
        /* Certain paragraph styles are HTML-only. */
        gtk_action_set_sensitive (ACTION (STYLE_H1), is_html);
+       gtk_action_set_visible (ACTION (STYLE_H1), is_html);
        gtk_action_set_sensitive (ACTION (STYLE_H2), is_html);
+       gtk_action_set_visible (ACTION (STYLE_H2), is_html);
        gtk_action_set_sensitive (ACTION (STYLE_H3), is_html);
+       gtk_action_set_visible (ACTION (STYLE_H3), is_html);
        gtk_action_set_sensitive (ACTION (STYLE_H4), is_html);
+       gtk_action_set_visible (ACTION (STYLE_H4), is_html);
        gtk_action_set_sensitive (ACTION (STYLE_H5), is_html);
+       gtk_action_set_visible (ACTION (STYLE_H5), is_html);
        gtk_action_set_sensitive (ACTION (STYLE_H6), is_html);
+       gtk_action_set_visible (ACTION (STYLE_H6), is_html);
        gtk_action_set_sensitive (ACTION (STYLE_ADDRESS), is_html);
+       gtk_action_set_visible (ACTION (STYLE_ADDRESS), is_html);
+
+       /* Hide them from the action combo box as well */
+       style_combo_box = e_editor_get_style_combo_box (editor);
+       e_action_combo_box_update_model (E_ACTION_COMBO_BOX (style_combo_box));
 }
 
 static void
diff --git a/e-util/e-editor.c b/e-util/e-editor.c
index 1738a5c..a9bdd2e 100644
--- a/e-util/e-editor.c
+++ b/e-util/e-editor.c
@@ -1090,6 +1090,14 @@ e_editor_get_managed_widget (EEditor *editor,
        return widget;
 }
 
+GtkWidget *
+e_editor_get_style_combo_box (EEditor *editor)
+{
+       g_return_val_if_fail (E_IS_EDITOR (editor), NULL);
+
+       return editor->priv->style_combo_box;
+}
+
 /**
  * e_editor_get_filename:
  * @editor: an #EEditor
diff --git a/e-util/e-editor.h b/e-util/e-editor.h
index 00831ac..31db13b 100644
--- a/e-util/e-editor.h
+++ b/e-util/e-editor.h
@@ -82,6 +82,7 @@ GtkWidget *   e_editor_get_widget             (EEditor *editor,
                                                 const gchar *widget_name);
 GtkWidget *    e_editor_get_managed_widget     (EEditor *editor,
                                                 const gchar *widget_path);
+GtkWidget *    e_editor_get_style_combo_box    (EEditor *editor);
 const gchar *  e_editor_get_filename           (EEditor *editor);
 void           e_editor_set_filename           (EEditor *editor,
                                                 const gchar *filename);


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