gtkhtml r8886 - trunk/components/editor



Author: mbarnes
Date: Sat Jul  5 18:35:35 2008
New Revision: 8886
URL: http://svn.gnome.org/viewvc/gtkhtml?rev=8886&view=rev

Log:
2008-07-05  Matthew Barnes  <mbarnes redhat com>

	* Implements the first of several suggested UI improvements in
	  bug #408707.

	* components/editor/gtkhtml-editor.ui:
	* components/editor/gtkhtml-editor-actions.c:
	* components/editor/gtkhtml-editor-private.c:
	* components/editor/gtkhtml-editor-private.h:
	Split HTML-only actions into a second editing toolbar.
	This new toolbar is only visible in HTML editing mode.

	* components/editor/gtkhtml-combo-box.c:
	Use enums when referencing tree model columns.
	Other miscellaneous code cleanups.

	* components/editor/gtkhtml-editor.c (gtkhtml_editor_get_html_mode),
	(gtkhtml_editor_set_html_mode):
	* components/editor/gtkhtml-editor-actions.c (action_mode_cb):
	* components/editor/gtkhtml-editor-actions.h:
	Editing mode is now stored as radio actions instead of a toggle
	actions.  Adapt.



Modified:
   trunk/components/editor/ChangeLog
   trunk/components/editor/gtkhtml-combo-box.c
   trunk/components/editor/gtkhtml-editor-actions.c
   trunk/components/editor/gtkhtml-editor-actions.h
   trunk/components/editor/gtkhtml-editor-private.c
   trunk/components/editor/gtkhtml-editor-private.h
   trunk/components/editor/gtkhtml-editor.c
   trunk/components/editor/gtkhtml-editor.ui

Modified: trunk/components/editor/gtkhtml-combo-box.c
==============================================================================
--- trunk/components/editor/gtkhtml-combo-box.c	(original)
+++ trunk/components/editor/gtkhtml-combo-box.c	Sat Jul  5 18:35:35 2008
@@ -27,6 +27,11 @@
 	((obj), GTKHTML_TYPE_COMBO_BOX, GtkhtmlComboBoxPrivate))
 
 enum {
+	COLUMN_ACTION,
+	COLUMN_SORT
+};
+
+enum {
 	PROP_0,
 	PROP_ACTION
 };
@@ -79,27 +84,11 @@
 }
 
 static void
-combo_box_active_changed_cb (GtkComboBox *combo_box)
-{
-	GtkRadioAction *action;
-	GtkTreeModel *model;
-	GtkTreeIter iter;
-	gint value;
-
-	if (!gtk_combo_box_get_active_iter (combo_box, &iter))
-		return;
-
-	model = gtk_combo_box_get_model (combo_box);
-	gtk_tree_model_get (model, &iter, 0, &action, -1);
-	g_object_get (G_OBJECT (action), "value", &value, NULL);
-	gtk_radio_action_set_current_value (action, value);
-}
-
-static void
-combo_box_render_pixbuf (GtkhtmlComboBox *combo_box,
+combo_box_render_pixbuf (GtkCellLayout *layout,
                          GtkCellRenderer *renderer,
                          GtkTreeModel *model,
-                         GtkTreeIter *iter)
+                         GtkTreeIter *iter,
+                         GtkhtmlComboBox *combo_box)
 {
 	GtkRadioAction *action;
 	gchar *icon_name;
@@ -107,7 +96,7 @@
 	gboolean sensitive;
 	gboolean visible;
 
-	gtk_tree_model_get (model, iter, 0, &action, -1);
+	gtk_tree_model_get (model, iter, COLUMN_ACTION, &action, -1);
 
 	g_object_get (
 		G_OBJECT (action),
@@ -131,10 +120,11 @@
 }
 
 static void
-combo_box_render_text (GtkhtmlComboBox *combo_box,
+combo_box_render_text (GtkCellLayout *layout,
                        GtkCellRenderer *renderer,
                        GtkTreeModel *model,
-                       GtkTreeIter *iter)
+                       GtkTreeIter *iter,
+                       GtkhtmlComboBox *combo_box)
 {
 	GtkRadioAction *action;
 	gchar **strv;
@@ -142,7 +132,7 @@
 	gboolean sensitive;
 	gboolean visible;
 
-	gtk_tree_model_get (model, iter, 0, &action, -1);
+	gtk_tree_model_get (model, iter, COLUMN_ACTION, &action, -1);
 
 	g_object_get (
 		G_OBJECT (action),
@@ -195,7 +185,8 @@
 		gtk_list_store_append (list_store, &iter);
 		g_object_get (G_OBJECT (action), "value", &value, NULL);
 		gtk_list_store_set (
-			list_store, &iter, 0, list->data, 1, value, -1);
+			list_store, &iter, COLUMN_ACTION,
+			list->data, COLUMN_SORT, value, -1);
 
 		path = gtk_tree_model_get_path (
 			GTK_TREE_MODEL (list_store), &iter);
@@ -210,7 +201,8 @@
 	}
 
 	gtk_tree_sortable_set_sort_column_id (
-		GTK_TREE_SORTABLE (list_store), 1, GTK_SORT_ASCENDING);
+		GTK_TREE_SORTABLE (list_store),
+		COLUMN_SORT, GTK_SORT_ASCENDING);
 	gtk_combo_box_set_model (
 		GTK_COMBO_BOX (combo_box), GTK_TREE_MODEL (list_store));
 
@@ -220,24 +212,6 @@
 		combo_box);
 }
 
-static GObject *
-combo_box_constructor (GType type,
-                       guint n_construct_properties,
-                       GObjectConstructParam *construct_properties)
-{
-	GObject *object;
-
-	/* Chain up to parent's constructor() method. */
-	object = G_OBJECT_CLASS (parent_class)->constructor (
-		type, n_construct_properties, construct_properties);
-
-	g_signal_connect (
-		object, "changed",
-		G_CALLBACK (combo_box_active_changed_cb), NULL);
-
-	return object;
-}
-
 static void
 combo_box_set_property (GObject *object,
                         guint property_id,
@@ -277,14 +251,12 @@
 {
 	GtkhtmlComboBoxPrivate *priv = GTKHTML_COMBO_BOX_GET_PRIVATE (object);
 
-	if (priv->action != NULL)
-	{
+	if (priv->action != NULL) {
 		g_object_unref (priv->action);
 		priv->action = NULL;
 	}
 
-	if (priv->action_group != NULL)
-	{
+	if (priv->action_group != NULL) {
 		g_object_unref (priv->action_group);
 		priv->action_group = NULL;
 	}
@@ -307,20 +279,42 @@
 }
 
 static void
+combo_box_changed (GtkComboBox *combo_box)
+{
+	GtkRadioAction *action;
+	GtkTreeModel *model;
+	GtkTreeIter iter;
+	gint value;
+
+	/* This method is virtual, so no need to chain up. */
+
+	if (!gtk_combo_box_get_active_iter (combo_box, &iter))
+		return;
+
+	model = gtk_combo_box_get_model (combo_box);
+	gtk_tree_model_get (model, &iter, COLUMN_ACTION, &action, -1);
+	g_object_get (G_OBJECT (action), "value", &value, NULL);
+	gtk_radio_action_set_current_value (action, value);
+}
+
+static void
 combo_box_class_init (GtkhtmlComboBoxClass *class)
 {
 	GObjectClass *object_class;
+	GtkComboBoxClass *combo_box_class;
 
 	parent_class = g_type_class_peek_parent (class);
 	g_type_class_add_private (class, sizeof (GtkhtmlComboBoxPrivate));
 
 	object_class = G_OBJECT_CLASS (class);
-	object_class->constructor = combo_box_constructor;
 	object_class->set_property = combo_box_set_property;
 	object_class->get_property = combo_box_get_property;
 	object_class->dispose = combo_box_dispose;
 	object_class->finalize = combo_box_finalize;
 
+	combo_box_class = GTK_COMBO_BOX_CLASS (class);
+	combo_box_class->changed = combo_box_changed;
+
 	g_object_class_install_property (
 		object_class,
 		PROP_ACTION,
@@ -345,7 +339,7 @@
 	gtk_cell_layout_set_cell_data_func (
 		GTK_CELL_LAYOUT (combo_box), renderer,
 		(GtkCellLayoutDataFunc) combo_box_render_pixbuf,
-		NULL, NULL);
+		combo_box, NULL);
 
 	renderer = gtk_cell_renderer_text_new ();
 	gtk_cell_layout_pack_start (
@@ -353,7 +347,7 @@
 	gtk_cell_layout_set_cell_data_func (
 		GTK_CELL_LAYOUT (combo_box), renderer,
 		(GtkCellLayoutDataFunc) combo_box_render_text,
-		NULL, NULL);
+		combo_box, NULL);
 
 	combo_box->priv->index = g_hash_table_new_full (
 		g_direct_hash, g_direct_equal,
@@ -391,18 +385,13 @@
 GtkWidget *
 gtkhtml_combo_box_new (void)
 {
-	return g_object_new (GTKHTML_TYPE_COMBO_BOX, NULL);
+	return gtkhtml_combo_box_new_with_action (NULL);
 }
 
 GtkWidget *
 gtkhtml_combo_box_new_with_action (GtkRadioAction *action)
 {
-	GtkWidget *widget;
-
-	widget = gtkhtml_combo_box_new ();
-	gtkhtml_combo_box_set_action (GTKHTML_COMBO_BOX (widget), action);
-
-	return widget;
+	return g_object_new (GTKHTML_TYPE_COMBO_BOX, "action", action, NULL);
 }
 
 GtkRadioAction *
@@ -447,9 +436,10 @@
 	combo_box->priv->action = action;
 	combo_box_update_model (combo_box);
 
-	combo_box->priv->changed_handler_id = g_signal_connect (
-		combo_box->priv->action, "changed",
-		G_CALLBACK (combo_box_action_changed_cb), combo_box);
+	if (combo_box->priv->action != NULL)
+		combo_box->priv->changed_handler_id = g_signal_connect (
+			combo_box->priv->action, "changed",
+			G_CALLBACK (combo_box_action_changed_cb), combo_box);
 
 	if (combo_box->priv->action_group != NULL) {
 		combo_box->priv->group_sensitive_handler_id =

Modified: trunk/components/editor/gtkhtml-editor-actions.c
==============================================================================
--- trunk/components/editor/gtkhtml-editor-actions.c	(original)
+++ trunk/components/editor/gtkhtml-editor-actions.c	Sat Jul  5 18:35:35 2008
@@ -39,7 +39,6 @@
  * "find"
  * "find-again"
  * "find-and-replace"
- * "html-mode"		(toggle)
  * "indent"
  * "insert-html-file"
  * "insert-smiley-1"
@@ -58,6 +57,8 @@
  * "justify-center"	(radio)
  * "justify-left"	(radio)
  * "justify-right"	(radio)
+ * "mode-html"		(radio)
+ * "mode-plain"		(radio)
  * "paste"
  * "paste-quote"
  * "redo"
@@ -86,13 +87,13 @@
  * Core Actions (HTML Only)
  * ------------------------
  * "bold"		(toggle)
- * "properties-page"
  * "insert-image"
  * "insert-link"
  * "insert-rule"
  * "insert-table"
  * "italic"		(toggle)
  * "monospaced"		(toggle)
+ * "properties-page"
  * "size-minus-one"	(radio)
  * "size-minus-two"	(radio)
  * "size-plus-four"	(radio)
@@ -618,69 +619,6 @@
 }
 
 static void
-action_html_mode_cb (GtkToggleAction *action,
-                     GtkhtmlEditor *editor)
-{
-	GtkActionGroup *action_group;
-	HTMLPainter *new_painter;
-	HTMLPainter *old_painter;
-	GtkHTML *html;
-	gboolean active;
-
-	html = gtkhtml_editor_get_html (editor);
-	active = gtk_toggle_action_get_active (action);
-
-	action_group = editor->priv->html_actions;
-	gtk_action_group_set_sensitive (action_group, active);
-
-	action_group = editor->priv->html_context_actions;
-	gtk_action_group_set_visible (action_group, active);
-
-        gtk_widget_set_sensitive (editor->priv->color_combo_box, active);
-
-	/* Certain paragraph styles are HTML-only. */
-	gtk_action_set_sensitive (ACTION (STYLE_H1), active);
-	gtk_action_set_sensitive (ACTION (STYLE_H2), active);
-	gtk_action_set_sensitive (ACTION (STYLE_H3), active);
-	gtk_action_set_sensitive (ACTION (STYLE_H4), active);
-	gtk_action_set_sensitive (ACTION (STYLE_H5), active);
-	gtk_action_set_sensitive (ACTION (STYLE_H6), active);
-	gtk_action_set_sensitive (ACTION (STYLE_ADDRESS), active);
-
-	/* Swap painters. */
-
-	if (active) {
-		new_painter = editor->priv->html_painter;
-		old_painter = editor->priv->plain_painter;
-	} else {
-		new_painter = editor->priv->plain_painter;
-		old_painter = editor->priv->html_painter;
-	}
-
-	/* Might be true during initialization. */
-	if (html->engine->painter == new_painter)
-		return;
-
-	html_gdk_painter_unrealize (HTML_GDK_PAINTER (old_painter));
-	if (html->engine->window != NULL)
-		html_gdk_painter_realize (
-			HTML_GDK_PAINTER (new_painter),
-			html->engine->window);
-
-	html_font_manager_set_default (
-		&new_painter->font_manager,
-		old_painter->font_manager.variable.face,
-		old_painter->font_manager.fixed.face,
-		old_painter->font_manager.var_size,
-		old_painter->font_manager.var_points,
-		old_painter->font_manager.fix_size,
-		old_painter->font_manager.fix_points);
-
-	html_engine_set_painter (html->engine, new_painter);
-	html_engine_schedule_redraw (html->engine);
-}
-
-static void
 action_indent_cb (GtkAction *action,
                   GtkhtmlEditor *editor)
 {
@@ -962,6 +900,77 @@
 }
 
 static void
+action_mode_cb (GtkRadioAction *action,
+                GtkRadioAction *current,
+                GtkhtmlEditor *editor)
+{
+	GtkActionGroup *action_group;
+	HTMLPainter *new_painter;
+	HTMLPainter *old_painter;
+	GtkHTML *html;
+	EditorMode mode;
+	gboolean html_mode;
+
+	html = gtkhtml_editor_get_html (editor);
+	mode = gtk_radio_action_get_current_value (current);
+	html_mode = (mode == EDITOR_MODE_HTML);
+
+	action_group = editor->priv->html_actions;
+	gtk_action_group_set_sensitive (action_group, html_mode);
+
+	action_group = editor->priv->html_context_actions;
+	gtk_action_group_set_visible (action_group, html_mode);
+
+        gtk_widget_set_sensitive (editor->priv->color_combo_box, html_mode);
+
+	if (html_mode)
+		gtk_widget_show (editor->priv->html_toolbar);
+	else
+		gtk_widget_hide (editor->priv->html_toolbar);
+
+	/* Certain paragraph styles are HTML-only. */
+	gtk_action_set_sensitive (ACTION (STYLE_H1), html_mode);
+	gtk_action_set_sensitive (ACTION (STYLE_H2), html_mode);
+	gtk_action_set_sensitive (ACTION (STYLE_H3), html_mode);
+	gtk_action_set_sensitive (ACTION (STYLE_H4), html_mode);
+	gtk_action_set_sensitive (ACTION (STYLE_H5), html_mode);
+	gtk_action_set_sensitive (ACTION (STYLE_H6), html_mode);
+	gtk_action_set_sensitive (ACTION (STYLE_ADDRESS), html_mode);
+
+	/* Swap painters. */
+
+	if (html_mode) {
+		new_painter = editor->priv->html_painter;
+		old_painter = editor->priv->plain_painter;
+	} else {
+		new_painter = editor->priv->plain_painter;
+		old_painter = editor->priv->html_painter;
+	}
+
+	/* Might be true during initialization. */
+	if (html->engine->painter == new_painter)
+		return;
+
+	html_gdk_painter_unrealize (HTML_GDK_PAINTER (old_painter));
+	if (html->engine->window != NULL)
+		html_gdk_painter_realize (
+			HTML_GDK_PAINTER (new_painter),
+			html->engine->window);
+
+	html_font_manager_set_default (
+		&new_painter->font_manager,
+		old_painter->font_manager.variable.face,
+		old_painter->font_manager.fixed.face,
+		old_painter->font_manager.var_size,
+		old_painter->font_manager.var_points,
+		old_painter->font_manager.fix_size,
+		old_painter->font_manager.fix_points);
+
+	html_engine_set_painter (html->engine, new_painter);
+	html_engine_schedule_redraw (html->engine);
+}
+
+static void
 action_monospaced_cb (GtkToggleAction *action,
                       GtkhtmlEditor *editor)
 {
@@ -1601,17 +1610,6 @@
 	  NULL }
 };
 
-static GtkToggleActionEntry core_toggle_entries[] = {
-
-	{ "html-mode",
-	  NULL,
-	  N_("_HTML Mode"),
-	  NULL,
-	  N_("Toggle between HTML and plain text mode"),
-	  G_CALLBACK (action_html_mode_cb),
-	  TRUE },
-};
-
 static GtkRadioActionEntry core_justify_entries[] = {
 
 	{ "justify-center",
@@ -1636,6 +1634,23 @@
 	  GTK_HTML_PARAGRAPH_ALIGNMENT_RIGHT }
 };
 
+static GtkRadioActionEntry core_mode_entries[] = {
+
+	{ "mode-html",
+	  NULL,
+	  N_("_HTML"),
+	  NULL,
+	  N_("HTML editing mode"),
+	  EDITOR_MODE_HTML },
+
+	{ "mode-plain",
+	  NULL,
+	  N_("Plain _Text"),
+	  NULL,
+	  N_("Plain text editing mode"),
+	  EDITOR_MODE_TEXT }
+};
+
 static GtkRadioActionEntry core_style_entries[] = {
 
 	{ "style-normal",
@@ -2277,15 +2292,17 @@
 	gtk_action_group_add_actions (
 		action_group, core_entries,
 		G_N_ELEMENTS (core_entries), editor);
-	gtk_action_group_add_toggle_actions (
-		action_group, core_toggle_entries,
-		G_N_ELEMENTS (core_toggle_entries), editor);
 	gtk_action_group_add_radio_actions (
 		action_group, core_justify_entries,
 		G_N_ELEMENTS (core_justify_entries),
 		GTK_HTML_PARAGRAPH_ALIGNMENT_LEFT,
 		G_CALLBACK (action_justify_cb), editor);
 	gtk_action_group_add_radio_actions (
+		action_group, core_mode_entries,
+		G_N_ELEMENTS (core_mode_entries),
+		EDITOR_MODE_HTML,
+		G_CALLBACK (action_mode_cb), editor);
+	gtk_action_group_add_radio_actions (
 		action_group, core_style_entries,
 		G_N_ELEMENTS (core_style_entries),
 		GTK_HTML_PARAGRAPH_STYLE_NORMAL,

Modified: trunk/components/editor/gtkhtml-editor-actions.h
==============================================================================
--- trunk/components/editor/gtkhtml-editor-actions.h	(original)
+++ trunk/components/editor/gtkhtml-editor-actions.h	Sat Jul  5 18:35:35 2008
@@ -88,8 +88,6 @@
 	GTKHTML_EDITOR_ACTION ((editor), "format-menu")
 #define GTKHTML_EDITOR_ACTION_FORMAT_TEXT(editor) \
 	GTKHTML_EDITOR_ACTION ((editor), "format-text")
-#define GTKHTML_EDITOR_ACTION_HTML_MODE(editor) \
-	GTKHTML_EDITOR_ACTION ((editor), "html-mode")
 #define GTKHTML_EDITOR_ACTION_INSERT_IMAGE(editor) \
 	GTKHTML_EDITOR_ACTION ((editor), "insert-image")
 #define GTKHTML_EDITOR_ACTION_INSERT_LINK(editor) \
@@ -108,6 +106,10 @@
 	GTKHTML_EDITOR_ACTION ((editor), "justify-left")
 #define GTKHTML_EDITOR_ACTION_JUSTIFY_RIGHT(editor) \
 	GTKHTML_EDITOR_ACTION ((editor), "justify-right")
+#define GTKHTML_EDITOR_ACTION_MODE_HTML(editor) \
+	GTKHTML_EDITOR_ACTION ((editor), "mode-html")
+#define GTKHTML_EDITOR_ACTION_MODE_PLAIN(editor) \
+	GTKHTML_EDITOR_ACTION ((editor), "mode-plain")
 #define GTKHTML_EDITOR_ACTION_MONOSPACED(editor) \
 	GTKHTML_EDITOR_ACTION ((editor), "monospaced")
 #define GTKHTML_EDITOR_ACTION_PROPERTIES_RULE(editor) \

Modified: trunk/components/editor/gtkhtml-editor-private.c
==============================================================================
--- trunk/components/editor/gtkhtml-editor-private.c	(original)
+++ trunk/components/editor/gtkhtml-editor-private.c	Sat Jul  5 18:35:35 2008
@@ -143,6 +143,7 @@
 
 	GtkHTML *html;
 	GtkWidget *widget;
+	GtkToolbar *toolbar;
 	GtkToolItem *tool_item;
 	gchar *filename;
 	GError *error = NULL;
@@ -219,6 +220,12 @@
 	priv->edit_toolbar = g_object_ref (widget);
 	gtk_widget_show (widget);
 
+	widget = gtkhtml_editor_get_managed_widget (editor, "/html-toolbar");
+	gtk_toolbar_set_style (GTK_TOOLBAR (widget), GTK_TOOLBAR_ICONS);
+	gtk_box_pack_start (GTK_BOX (editor->vbox), widget, FALSE, FALSE, 0);
+	priv->html_toolbar = g_object_ref (widget);
+	gtk_widget_show (widget);
+
 	widget = gtk_scrolled_window_new (NULL, NULL);
 	gtk_scrolled_window_set_policy (
 		GTK_SCROLLED_WINDOW (widget),
@@ -236,9 +243,7 @@
 
 	/* Add some combo boxes to the "edit" toolbar. */
 
-	tool_item = gtk_separator_tool_item_new ();
-	gtk_toolbar_insert (GTK_TOOLBAR (priv->edit_toolbar), tool_item, 0);
-	gtk_widget_show_all (GTK_WIDGET (tool_item));
+	toolbar = GTK_TOOLBAR (priv->edit_toolbar);
 
 	tool_item = gtk_tool_item_new ();
 	widget = gtkhtml_combo_box_new_with_action (
@@ -246,36 +251,46 @@
 	gtk_combo_box_set_focus_on_click (GTK_COMBO_BOX (widget), FALSE);
 	gtk_container_add (GTK_CONTAINER (tool_item), widget);
 	gtk_widget_set_tooltip_text (widget, _("Paragraph Style"));
-	gtk_toolbar_insert (GTK_TOOLBAR (priv->edit_toolbar), tool_item, 0);
+	gtk_toolbar_insert (toolbar, tool_item, 0);
 	priv->style_combo_box = g_object_ref (widget);
 	gtk_widget_show_all (GTK_WIDGET (tool_item));
 
 	tool_item = gtk_separator_tool_item_new ();
-	gtk_toolbar_insert (GTK_TOOLBAR (priv->edit_toolbar), tool_item, 0);
+	gtk_toolbar_insert (toolbar, tool_item, 0);
 	gtk_widget_show_all (GTK_WIDGET (tool_item));
 
 	tool_item = gtk_tool_item_new ();
 	widget = gtkhtml_combo_box_new_with_action (
-		GTK_RADIO_ACTION (ACTION (SIZE_PLUS_ZERO)));
+		GTK_RADIO_ACTION (ACTION (MODE_HTML)));
 	gtk_combo_box_set_focus_on_click (GTK_COMBO_BOX (widget), FALSE);
 	gtk_container_add (GTK_CONTAINER (tool_item), widget);
-	gtk_widget_set_tooltip_text (widget, _("Font Size"));
-	gtk_toolbar_insert (GTK_TOOLBAR (priv->edit_toolbar), tool_item, 0);
-	priv->size_combo_box = g_object_ref (widget);
+	gtk_widget_set_tooltip_text (widget, _("Editing Mode"));
+	gtk_toolbar_insert (toolbar, tool_item, 0);
+	priv->mode_combo_box = g_object_ref (widget);
 	gtk_widget_show_all (GTK_WIDGET (tool_item));
 
-	tool_item = gtk_separator_tool_item_new ();
-	gtk_toolbar_insert (GTK_TOOLBAR (priv->edit_toolbar), tool_item, -1);
-	gtk_widget_show_all (GTK_WIDGET (tool_item));
+	/* Add some combo boxes to the "html" toolbar. */
+
+	toolbar = GTK_TOOLBAR (priv->html_toolbar);
 
 	tool_item = gtk_tool_item_new ();
 	widget = gtkhtml_color_combo_new ();
 	gtk_container_add (GTK_CONTAINER (tool_item), widget);
 	gtk_widget_set_tooltip_text (widget, _("Font Color"));
-	gtk_toolbar_insert (GTK_TOOLBAR (priv->edit_toolbar), tool_item, -1);
+	gtk_toolbar_insert (toolbar, tool_item, 0);
 	priv->color_combo_box = g_object_ref (widget);
 	gtk_widget_show_all (GTK_WIDGET (tool_item));
 
+	tool_item = gtk_tool_item_new ();
+	widget = gtkhtml_combo_box_new_with_action (
+		GTK_RADIO_ACTION (ACTION (SIZE_PLUS_ZERO)));
+	gtk_combo_box_set_focus_on_click (GTK_COMBO_BOX (widget), FALSE);
+	gtk_container_add (GTK_CONTAINER (tool_item), widget);
+	gtk_widget_set_tooltip_text (widget, _("Font Size"));
+	gtk_toolbar_insert (toolbar, tool_item, 0);
+	priv->size_combo_box = g_object_ref (widget);
+	gtk_widget_show_all (GTK_WIDGET (tool_item));
+
 	/* Initialize painters (requires "edit_area"). */
 
 	html = gtkhtml_editor_get_html (editor);
@@ -371,6 +386,7 @@
 	DISPOSE (priv->edit_area);
 
 	DISPOSE (priv->color_combo_box);
+	DISPOSE (priv->mode_combo_box);
 	DISPOSE (priv->size_combo_box);
 	DISPOSE (priv->style_combo_box);
 	DISPOSE (priv->scrolled_window);

Modified: trunk/components/editor/gtkhtml-editor-private.h
==============================================================================
--- trunk/components/editor/gtkhtml-editor-private.h	(original)
+++ trunk/components/editor/gtkhtml-editor-private.h	Sat Jul  5 18:35:35 2008
@@ -84,6 +84,11 @@
 G_BEGIN_DECLS
 
 typedef enum {
+	EDITOR_MODE_HTML,
+	EDITOR_MODE_TEXT
+} EditorMode;
+
+typedef enum {
 	TABLE_CELL_SCOPE_CELL,
 	TABLE_CELL_SCOPE_ROW,
 	TABLE_CELL_SCOPE_COLUMN,
@@ -121,9 +126,11 @@
 	GtkWidget *main_menu;
 	GtkWidget *main_toolbar;
 	GtkWidget *edit_toolbar;
+	GtkWidget *html_toolbar;
 	GtkWidget *edit_area;
 
 	GtkWidget *color_combo_box;
+	GtkWidget *mode_combo_box;
 	GtkWidget *size_combo_box;
 	GtkWidget *style_combo_box;
 	GtkWidget *scrolled_window;

Modified: trunk/components/editor/gtkhtml-editor.c
==============================================================================
--- trunk/components/editor/gtkhtml-editor.c	(original)
+++ trunk/components/editor/gtkhtml-editor.c	Sat Jul  5 18:35:35 2008
@@ -1077,25 +1077,29 @@
 gboolean
 gtkhtml_editor_get_html_mode (GtkhtmlEditor *editor)
 {
-	GtkToggleAction *action;
+	GtkRadioAction *action;
+	EditorMode mode;
 
 	g_return_val_if_fail (GTKHTML_IS_EDITOR (editor), FALSE);
 
-	action = GTK_TOGGLE_ACTION (ACTION (HTML_MODE));
+	action = GTK_RADIO_ACTION (ACTION (MODE_HTML));
+	mode = gtk_radio_action_get_current_value (action);
 
-	return gtk_toggle_action_get_active (action);
+	return (mode == EDITOR_MODE_HTML);
 }
 
 void
 gtkhtml_editor_set_html_mode (GtkhtmlEditor *editor,
                               gboolean html_mode)
 {
-	GtkToggleAction *action;
+	GtkRadioAction *action;
+	EditorMode mode;
 
 	g_return_if_fail (GTKHTML_IS_EDITOR (editor));
 
-	action = GTK_TOGGLE_ACTION (ACTION (HTML_MODE));
-	gtk_toggle_action_set_active (action, html_mode);
+	action = GTK_RADIO_ACTION (ACTION (MODE_HTML));
+	mode = html_mode ? EDITOR_MODE_HTML : EDITOR_MODE_TEXT;
+	gtk_radio_action_set_current_value (action, mode);
 
 	g_object_notify (G_OBJECT (editor), "html-mode");
 }

Modified: trunk/components/editor/gtkhtml-editor.ui
==============================================================================
--- trunk/components/editor/gtkhtml-editor.ui	(original)
+++ trunk/components/editor/gtkhtml-editor.ui	Sat Jul  5 18:35:35 2008
@@ -50,7 +50,8 @@
     <placeholder name='pre-format-menu'/>
     <menu action='format-menu'>
       <placeholder name='format-menu-top'/>
-      <menuitem action='html-mode'/>
+      <menuitem action='mode-html'/>
+      <menuitem action='mode-plain'/>
       <separator/>
       <menu action='font-style-menu'>
         <menuitem action='monospaced'/>
@@ -112,18 +113,8 @@
     <separator/>
     <toolitem action='show-find'/>
     <toolitem action='show-replace'/>
-    <separator/>
-    <toolitem action='insert-image'/>
-    <toolitem action='insert-link'/>
-    <toolitem action='insert-rule'/>
-    <toolitem action='insert-table'/>
   </toolbar>
   <toolbar name='edit-toolbar'>
-    <toolitem action='monospaced'/>
-    <toolitem action='bold'/>
-    <toolitem action='italic'/>
-    <toolitem action='underline'/>
-    <toolitem action='strikethrough'/>
     <separator/>
     <toolitem action='justify-left'/>
     <toolitem action='justify-center'/>
@@ -132,6 +123,19 @@
     <toolitem action='unindent'/>
     <toolitem action='indent'/>
   </toolbar>
+  <toolbar name='html-toolbar'>
+    <separator/>
+    <toolitem action='monospaced'/>
+    <toolitem action='bold'/>
+    <toolitem action='italic'/>
+    <toolitem action='underline'/>
+    <toolitem action='strikethrough'/>
+    <separator/>
+    <toolitem action='insert-image'/>
+    <toolitem action='insert-link'/>
+    <toolitem action='insert-rule'/>
+    <toolitem action='insert-table'/>
+  </toolbar>
   <popup name='context-menu'>
     <menuitem action='undo'/>
     <menuitem action='redo'/>



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