[evolution/webkit-composer: 71/72] Move EActionComboBox from widgets/misc to widgets/editor



commit 464eb5c9c3ccd6c2bedbf56acea2d60477280be1
Author: Dan VrÃtil <dvratil redhat com>
Date:   Tue Sep 11 10:16:47 2012 +0200

    Move EActionComboBox from widgets/misc to widgets/editor

 modules/mail/e-mail-shell-backend.c |    3 +-
 shell/Makefile.am                   |    1 +
 shell/e-shell-content.c             |    1 -
 shell/e-shell-searchbar.c           |    2 +-
 shell/e-shell-searchbar.h           |    2 +-
 widgets/Makefile.am                 |    1 +
 widgets/editor/e-action-combo-box.c |  267 ++++++++++++-----
 widgets/editor/e-action-combo-box.h |   19 +-
 widgets/editor/e-editor-actions.c   |    1 -
 widgets/editor/e-editor-test.c      |   21 +-
 widgets/misc/Makefile.am            |    2 -
 widgets/misc/e-action-combo-box.c   |  578 -----------------------------------
 widgets/misc/e-action-combo-box.h   |   85 -----
 widgets/misc/e-charset-combo-box.h  |    2 +-
 14 files changed, 226 insertions(+), 759 deletions(-)
---
diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c
index fa85c9a..1839f35 100644
--- a/modules/mail/e-mail-shell-backend.c
+++ b/modules/mail/e-mail-shell-backend.c
@@ -394,9 +394,10 @@ mail_shell_backend_window_added_cb (GtkApplication *application,
 		shell_settings = e_shell_get_shell_settings (shell);
 
 		/* Express mode does not honor this setting. */
-		if (!e_shell_get_express_mode (shell))
+		if (!e_shell_get_express_mode (shell)) {
 			active = e_shell_settings_get_boolean (
 				shell_settings, "composer-format-html");
+		}
 
 		e_editor_widget_set_mode (
 			editor_widget,
diff --git a/shell/Makefile.am b/shell/Makefile.am
index 0d413e7..281febd 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -97,6 +97,7 @@ libeshell_la_LIBADD =					\
 	$(top_builddir)/e-util/libeutil.la		\
 	$(top_builddir)/filter/libfilter.la		\
 	$(top_builddir)/smclient/libeggsmclient.la	\
+	$(top_builddir)/widgets/editor/libeeditor.la	\
 	$(top_builddir)/widgets/misc/libemiscwidgets.la	\
 	$(top_builddir)/widgets/menus/libmenus.la	\
 	$(top_builddir)/libemail-utils/libemail-utils.la \
diff --git a/shell/e-shell-content.c b/shell/e-shell-content.c
index fe35f66..d24a75e 100644
--- a/shell/e-shell-content.c
+++ b/shell/e-shell-content.c
@@ -38,7 +38,6 @@
 #include "libevolution-utils/e-alert-dialog.h"
 #include "libevolution-utils/e-alert-sink.h"
 #include "filter/e-rule-editor.h"
-#include "widgets/misc/e-action-combo-box.h"
 #include "widgets/misc/e-alert-bar.h"
 
 #include "e-shell-backend.h"
diff --git a/shell/e-shell-searchbar.c b/shell/e-shell-searchbar.c
index 9d9ad5a..39c353c 100644
--- a/shell/e-shell-searchbar.c
+++ b/shell/e-shell-searchbar.c
@@ -35,7 +35,7 @@
 #include <libebackend/libebackend.h>
 
 #include "e-util/e-util.h"
-#include "widgets/misc/e-action-combo-box.h"
+#include "widgets/editor/e-action-combo-box.h"
 
 #include "e-shell-window-actions.h"
 
diff --git a/shell/e-shell-searchbar.h b/shell/e-shell-searchbar.h
index a9e73c9..dc14a92 100644
--- a/shell/e-shell-searchbar.h
+++ b/shell/e-shell-searchbar.h
@@ -24,7 +24,7 @@
 
 #include <shell/e-shell-common.h>
 #include <shell/e-shell-view.h>
-#include <misc/e-action-combo-box.h>
+#include <editor/e-action-combo-box.h>
 
 /* Standard GObject macros */
 #define E_TYPE_SHELL_SEARCHBAR \
diff --git a/widgets/Makefile.am b/widgets/Makefile.am
index 137446c..20e7988 100644
--- a/widgets/Makefile.am
+++ b/widgets/Makefile.am
@@ -1,5 +1,6 @@
 
 SUBDIRS =			\
+	editor			\
 	misc			\
 	text			\
 	e-timezone-dialog	\
diff --git a/widgets/editor/e-action-combo-box.c b/widgets/editor/e-action-combo-box.c
index bb6f0f9..0747a6e 100644
--- a/widgets/editor/e-action-combo-box.c
+++ b/widgets/editor/e-action-combo-box.c
@@ -1,5 +1,8 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
 /* e-action-combo-box.c
  *
+ * Copyright (C) 2008 Novell, Inc.
+ *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of version 2 of the GNU Lesser General Public
  * License as published by the Free Software Foundation.
@@ -21,12 +24,11 @@
 
 #include "e-action-combo-box.h"
 
-#include <glib/gi18n-lib.h>
+#include <glib/gi18n.h>
 
-G_DEFINE_TYPE (
-	EActionComboBox,
-	e_action_combo_box,
-	GTK_TYPE_COMBO_BOX);
+#define E_ACTION_COMBO_BOX_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE \
+	((obj), E_TYPE_ACTION_COMBO_BOX, EActionComboBoxPrivate))
 
 enum {
 	COLUMN_ACTION,
@@ -45,12 +47,18 @@ struct _EActionComboBoxPrivate {
 	guint changed_handler_id;		/* action::changed */
 	guint group_sensitive_handler_id;	/* action-group::sensitive */
 	guint group_visible_handler_id;		/* action-group::visible */
+	gboolean group_has_icons : 1;
 };
 
+G_DEFINE_TYPE (
+	EActionComboBox,
+	e_action_combo_box,
+	GTK_TYPE_COMBO_BOX)
+
 static void
-combo_box_action_changed_cb (GtkRadioAction *action,
-                             GtkRadioAction *current,
-                             EActionComboBox *combo_box)
+action_combo_box_action_changed_cb (GtkRadioAction *action,
+                                    GtkRadioAction *current,
+                                    EActionComboBox *combo_box)
 {
 	GtkTreeRowReference *reference;
 	GtkTreeModel *model;
@@ -73,9 +81,9 @@ combo_box_action_changed_cb (GtkRadioAction *action,
 }
 
 static void
-combo_box_action_group_notify_cb (GtkActionGroup *action_group,
-                                  GParamSpec *pspec,
-                                  EActionComboBox *combo_box)
+action_combo_box_action_group_notify_cb (GtkActionGroup *action_group,
+                                         GParamSpec *pspec,
+                                         EActionComboBox *combo_box)
 {
 	g_object_set (
 		combo_box, "sensitive",
@@ -84,20 +92,29 @@ combo_box_action_group_notify_cb (GtkActionGroup *action_group,
 }
 
 static void
-combo_box_render_pixbuf (GtkCellLayout *layout,
-                         GtkCellRenderer *renderer,
-                         GtkTreeModel *model,
-                         GtkTreeIter *iter,
-                         EActionComboBox *combo_box)
+action_combo_box_render_pixbuf (GtkCellLayout *layout,
+                                GtkCellRenderer *renderer,
+                                GtkTreeModel *model,
+                                GtkTreeIter *iter,
+                                EActionComboBox *combo_box)
 {
 	GtkRadioAction *action;
 	gchar *icon_name;
 	gchar *stock_id;
 	gboolean sensitive;
 	gboolean visible;
+	gint width;
 
 	gtk_tree_model_get (model, iter, COLUMN_ACTION, &action, -1);
 
+	/* Do any of the actions have an icon? */
+	if (!combo_box->priv->group_has_icons)
+		return;
+
+	/* A NULL action means the row is a separator. */
+	if (action == NULL)
+		return;
+
 	g_object_get (
 		G_OBJECT (action),
 		"icon-name", &icon_name,
@@ -106,34 +123,58 @@ combo_box_render_pixbuf (GtkCellLayout *layout,
 		"visible", &visible,
 		NULL);
 
-	g_object_set (
-		G_OBJECT (renderer),
-		"icon-name", icon_name,
-		"sensitive", sensitive,
-		"stock-id", stock_id,
-		"stock-size", GTK_ICON_SIZE_MENU,
-		"visible", visible,
-		NULL);
+	/* Keep the pixbuf renderer a fixed size for proper alignment. */
+	gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, NULL);
+
+	/* We can't set both "icon-name" and "stock-id" because setting
+	 * one unsets the other.  So pick the one that has a non-NULL
+	 * value.  If both are non-NULL, "stock-id" wins. */
+
+	if (stock_id != NULL)
+		g_object_set (
+			G_OBJECT (renderer),
+			"sensitive", sensitive,
+			"icon-name", NULL,
+			"stock-id", stock_id,
+			"stock-size", GTK_ICON_SIZE_MENU,
+			"visible", visible,
+			"width", width,
+			NULL);
+	else
+		g_object_set (
+			G_OBJECT (renderer),
+			"sensitive", sensitive,
+			"icon-name", icon_name,
+			"stock-id", NULL,
+			"stock-size", GTK_ICON_SIZE_MENU,
+			"visible", visible,
+			"width", width,
+			NULL);
 
 	g_free (icon_name);
 	g_free (stock_id);
 }
 
 static void
-combo_box_render_text (GtkCellLayout *layout,
-                       GtkCellRenderer *renderer,
-                       GtkTreeModel *model,
-                       GtkTreeIter *iter,
-                       EActionComboBox *combo_box)
+action_combo_box_render_text (GtkCellLayout *layout,
+                              GtkCellRenderer *renderer,
+                              GtkTreeModel *model,
+                              GtkTreeIter *iter,
+                              EActionComboBox *combo_box)
 {
 	GtkRadioAction *action;
 	gchar **strv;
 	gchar *label;
 	gboolean sensitive;
 	gboolean visible;
+	gint xpad;
 
 	gtk_tree_model_get (model, iter, COLUMN_ACTION, &action, -1);
 
+	/* A NULL action means the row is a separator. */
+	if (action == NULL)
+		return;
+
 	g_object_get (
 		G_OBJECT (action),
 		"label", &label,
@@ -147,18 +188,37 @@ combo_box_render_text (GtkCellLayout *layout,
 	label = g_strjoinv (NULL, strv);
 	g_strfreev (strv);
 
+	xpad = combo_box->priv->group_has_icons ? 3 : 0;
+
 	g_object_set (
 		G_OBJECT (renderer),
 		"sensitive", sensitive,
 		"text", label,
 		"visible", visible,
+		"xpad", xpad,
 		NULL);
 
 	g_free (label);
 }
 
+static gboolean
+action_combo_box_is_row_separator (GtkTreeModel *model,
+                                   GtkTreeIter *iter)
+{
+	GtkAction *action;
+	gboolean separator;
+
+	/* NULL actions are rendered as separators. */
+	gtk_tree_model_get (model, iter, COLUMN_ACTION, &action, -1);
+	separator = (action == NULL);
+	if (action != NULL)
+		g_object_unref (action);
+
+	return separator;
+}
+
 static void
-combo_box_update_model (EActionComboBox *combo_box)
+action_combo_box_update_model (EActionComboBox *combo_box)
 {
 	GtkListStore *list_store;
 	GSList *list;
@@ -170,23 +230,37 @@ combo_box_update_model (EActionComboBox *combo_box)
 		return;
 	}
 
+	/* We store values in the sort column as floats so that we can
+	 * insert separators in between consecutive integer values and
+	 * still maintain the proper ordering. */
 	list_store = gtk_list_store_new (
-		2, GTK_TYPE_RADIO_ACTION, G_TYPE_INT);
+		2, GTK_TYPE_RADIO_ACTION, G_TYPE_FLOAT);
 
 	list = gtk_radio_action_get_group (combo_box->priv->action);
+	combo_box->priv->group_has_icons = FALSE;
 
 	while (list != NULL) {
 		GtkTreeRowReference *reference;
 		GtkRadioAction *action = list->data;
 		GtkTreePath *path;
 		GtkTreeIter iter;
+		gchar *icon_name;
+		gchar *stock_id;
 		gint value;
 
+		g_object_get (
+			action, "icon-name", &icon_name,
+			"stock-id", &stock_id, NULL);
+		combo_box->priv->group_has_icons |=
+			(icon_name != NULL || stock_id != NULL);
+		g_free (icon_name);
+		g_free (stock_id);
+
 		gtk_list_store_append (list_store, &iter);
-		g_object_get (G_OBJECT (action), "value", &value, NULL);
+		g_object_get (action, "value", &value, NULL);
 		gtk_list_store_set (
 			list_store, &iter, COLUMN_ACTION,
-			list->data, COLUMN_SORT, value, -1);
+			list->data, COLUMN_SORT, (gfloat) value, -1);
 
 		path = gtk_tree_model_get_path (
 			GTK_TREE_MODEL (list_store), &iter);
@@ -206,17 +280,17 @@ combo_box_update_model (EActionComboBox *combo_box)
 	gtk_combo_box_set_model (
 		GTK_COMBO_BOX (combo_box), GTK_TREE_MODEL (list_store));
 
-	combo_box_action_changed_cb (
+	action_combo_box_action_changed_cb (
 		combo_box->priv->action,
 		combo_box->priv->action,
 		combo_box);
 }
 
 static void
-combo_box_set_property (GObject *object,
-                        guint property_id,
-                        const GValue *value,
-                        GParamSpec *pspec)
+action_combo_box_set_property (GObject *object,
+                               guint property_id,
+                               const GValue *value,
+                               GParamSpec *pspec)
 {
 	switch (property_id) {
 		case PROP_ACTION:
@@ -230,10 +304,10 @@ combo_box_set_property (GObject *object,
 }
 
 static void
-combo_box_get_property (GObject *object,
-                        guint property_id,
-                        GValue *value,
-                        GParamSpec *pspec)
+action_combo_box_get_property (GObject *object,
+                               guint property_id,
+                               GValue *value,
+                               GParamSpec *pspec)
 {
 	switch (property_id) {
 		case PROP_ACTION:
@@ -247,9 +321,9 @@ combo_box_get_property (GObject *object,
 }
 
 static void
-combo_box_dispose (GObject *object)
+action_combo_box_dispose (GObject *object)
 {
-	EActionComboBoxPrivate *priv = E_ACTION_COMBO_BOX (object)->priv;
+	EActionComboBoxPrivate *priv = E_ACTION_COMBO_BOX_GET_PRIVATE (object);
 
 	if (priv->action != NULL) {
 		g_object_unref (priv->action);
@@ -268,9 +342,9 @@ combo_box_dispose (GObject *object)
 }
 
 static void
-combo_box_finalize (GObject *object)
+action_combo_box_finalize (GObject *object)
 {
-	EActionComboBoxPrivate *priv = E_ACTION_COMBO_BOX (object)->priv;
+	EActionComboBoxPrivate *priv = E_ACTION_COMBO_BOX_GET_PRIVATE (object);
 
 	g_hash_table_destroy (priv->index);
 
@@ -279,7 +353,7 @@ combo_box_finalize (GObject *object)
 }
 
 static void
-combo_box_constructed (GObject *object)
+action_combo_box_constructed (GObject *object)
 {
 	GtkComboBox *combo_box;
 	GtkCellRenderer *renderer;
@@ -294,7 +368,7 @@ combo_box_constructed (GObject *object)
 		GTK_CELL_LAYOUT (combo_box), renderer, FALSE);
 	gtk_cell_layout_set_cell_data_func (
 		GTK_CELL_LAYOUT (combo_box), renderer,
-		(GtkCellLayoutDataFunc) combo_box_render_pixbuf,
+		(GtkCellLayoutDataFunc) action_combo_box_render_pixbuf,
 		combo_box, NULL);
 
 	renderer = gtk_cell_renderer_text_new ();
@@ -302,12 +376,16 @@ combo_box_constructed (GObject *object)
 		GTK_CELL_LAYOUT (combo_box), renderer, TRUE);
 	gtk_cell_layout_set_cell_data_func (
 		GTK_CELL_LAYOUT (combo_box), renderer,
-		(GtkCellLayoutDataFunc) combo_box_render_text,
+		(GtkCellLayoutDataFunc) action_combo_box_render_text,
 		combo_box, NULL);
+
+	gtk_combo_box_set_row_separator_func (
+		combo_box, (GtkTreeViewRowSeparatorFunc)
+		action_combo_box_is_row_separator, NULL, NULL);
 }
 
 static void
-combo_box_changed (GtkComboBox *combo_box)
+action_combo_box_changed (GtkComboBox *combo_box)
 {
 	GtkRadioAction *action;
 	GtkTreeModel *model;
@@ -321,28 +399,27 @@ combo_box_changed (GtkComboBox *combo_box)
 
 	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);
+	g_object_get (action, "value", &value, NULL);
 	gtk_radio_action_set_current_value (action, value);
 }
 
 static void
-e_action_combo_box_class_init (EActionComboBoxClass *klass)
+e_action_combo_box_class_init (EActionComboBoxClass *class)
 {
 	GObjectClass *object_class;
 	GtkComboBoxClass *combo_box_class;
 
-	e_action_combo_box_parent_class = g_type_class_peek_parent (klass);
-	g_type_class_add_private (klass, sizeof (EActionComboBoxPrivate));
+	g_type_class_add_private (class, sizeof (EActionComboBoxPrivate));
 
-	object_class = G_OBJECT_CLASS (klass);
-	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;
-	object_class->constructed = combo_box_constructed;
+	object_class = G_OBJECT_CLASS (class);
+	object_class->set_property = action_combo_box_set_property;
+	object_class->get_property = action_combo_box_get_property;
+	object_class->dispose = action_combo_box_dispose;
+	object_class->finalize = action_combo_box_finalize;
+	object_class->constructed = action_combo_box_constructed;
 
-	combo_box_class = GTK_COMBO_BOX_CLASS (klass);
-	combo_box_class->changed = combo_box_changed;
+	combo_box_class = GTK_COMBO_BOX_CLASS (class);
+	combo_box_class->changed = action_combo_box_changed;
 
 	g_object_class_install_property (
 		object_class,
@@ -358,8 +435,7 @@ e_action_combo_box_class_init (EActionComboBoxClass *klass)
 static void
 e_action_combo_box_init (EActionComboBox *combo_box)
 {
-	combo_box->priv = G_TYPE_INSTANCE_GET_PRIVATE (
-		combo_box, E_TYPE_ACTION_COMBO_BOX, EActionComboBoxPrivate);
+	combo_box->priv = E_ACTION_COMBO_BOX_GET_PRIVATE (combo_box);
 
 	combo_box->priv->index = g_hash_table_new_full (
 		g_direct_hash, g_direct_equal,
@@ -382,16 +458,16 @@ e_action_combo_box_new_with_action (GtkRadioAction *action)
 GtkRadioAction *
 e_action_combo_box_get_action (EActionComboBox *combo_box)
 {
-	g_return_val_if_fail (E_IS_ACTION_COMBO_BOX (combo_box), NULL);
+	g_return_val_if_fail (E_ACTION_IS_COMBO_BOX (combo_box), NULL);
 
 	return combo_box->priv->action;
 }
 
 void
 e_action_combo_box_set_action (EActionComboBox *combo_box,
-			       GtkRadioAction *action)
+                               GtkRadioAction *action)
 {
-	g_return_if_fail (E_IS_ACTION_COMBO_BOX (combo_box));
+	g_return_if_fail (E_ACTION_IS_COMBO_BOX (combo_box));
 
 	if (action != NULL)
 		g_return_if_fail (GTK_IS_RADIO_ACTION (action));
@@ -418,34 +494,39 @@ e_action_combo_box_set_action (EActionComboBox *combo_box,
 		g_object_get (
 			g_object_ref (action), "action-group",
 			&combo_box->priv->action_group, NULL);
+
 	combo_box->priv->action = action;
-	combo_box_update_model (combo_box);
+	action_combo_box_update_model (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);
+			G_CALLBACK (action_combo_box_action_changed_cb),
+			combo_box);
 
 	if (combo_box->priv->action_group != NULL) {
+		g_object_ref (combo_box->priv->action_group);
 		combo_box->priv->group_sensitive_handler_id =
 			g_signal_connect (
 				combo_box->priv->action_group,
-				"notify::sensitive",
-				G_CALLBACK (combo_box_action_group_notify_cb),
+				"notify::sensitive", G_CALLBACK (
+				action_combo_box_action_group_notify_cb),
 				combo_box);
 		combo_box->priv->group_visible_handler_id =
 			g_signal_connect (
 				combo_box->priv->action_group,
-				"notify::visible",
-				G_CALLBACK (combo_box_action_group_notify_cb),
+				"notify::visible", G_CALLBACK (
+				action_combo_box_action_group_notify_cb),
 				combo_box);
 	}
+
+	g_object_notify (G_OBJECT (combo_box), "action");
 }
 
 gint
 e_action_combo_box_get_current_value (EActionComboBox *combo_box)
 {
-	g_return_val_if_fail (E_IS_ACTION_COMBO_BOX (combo_box), 0);
+	g_return_val_if_fail (E_ACTION_IS_COMBO_BOX (combo_box), 0);
 	g_return_val_if_fail (combo_box->priv->action != NULL, 0);
 
 	return gtk_radio_action_get_current_value (combo_box->priv->action);
@@ -453,11 +534,45 @@ e_action_combo_box_get_current_value (EActionComboBox *combo_box)
 
 void
 e_action_combo_box_set_current_value (EActionComboBox *combo_box,
-				      gint current_value)
+                                      gint current_value)
 {
-	g_return_if_fail (E_IS_ACTION_COMBO_BOX (combo_box));
+	g_return_if_fail (E_ACTION_IS_COMBO_BOX (combo_box));
 	g_return_if_fail (combo_box->priv->action != NULL);
 
 	gtk_radio_action_set_current_value (
 		combo_box->priv->action, current_value);
 }
+
+void
+e_action_combo_box_add_separator_before (EActionComboBox *combo_box,
+                                         gint action_value)
+{
+	GtkTreeModel *model;
+	GtkTreeIter iter;
+
+	g_return_if_fail (E_ACTION_IS_COMBO_BOX (combo_box));
+
+	/* NULL actions are rendered as separators. */
+	model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
+	gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+	gtk_list_store_set (
+		GTK_LIST_STORE (model), &iter, COLUMN_ACTION,
+		NULL, COLUMN_SORT, (gfloat) action_value - 0.5, -1);
+}
+
+void
+e_action_combo_box_add_separator_after (EActionComboBox *combo_box,
+                                        gint action_value)
+{
+	GtkTreeModel *model;
+	GtkTreeIter iter;
+
+	g_return_if_fail (E_ACTION_IS_COMBO_BOX (combo_box));
+
+	/* NULL actions are rendered as separators. */
+	model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
+	gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+	gtk_list_store_set (
+		GTK_LIST_STORE (model), &iter, COLUMN_ACTION,
+		NULL, COLUMN_SORT, (gfloat) action_value + 0.5, -1);
+}
diff --git a/widgets/editor/e-action-combo-box.h b/widgets/editor/e-action-combo-box.h
index 9a172d9..3003386 100644
--- a/widgets/editor/e-action-combo-box.h
+++ b/widgets/editor/e-action-combo-box.h
@@ -1,5 +1,8 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
 /* e-action-combo-box.h
  *
+ * Copyright (C) 2008 Novell, Inc.
+ *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of version 2 of the GNU Lesser General Public
  * License as published by the Free Software Foundation.
@@ -19,7 +22,8 @@
 #define E_ACTION_COMBO_BOX_H
 
 /* This is a GtkComboBox that is driven by a group of GtkRadioActions.
- * Just plug in a GtkRadioAction and the widget will handle the rest. */
+ * Just plug in a GtkRadioAction and the widget will handle the rest.
+ * (Based on GtkhtmlComboBox.) */
 
 #include <gtk/gtk.h>
 
@@ -32,10 +36,10 @@
 #define E_ACTION_COMBO_BOX_CLASS(cls) \
 	(G_TYPE_CHECK_CLASS_CAST \
 	((cls), E_TYPE_ACTION_COMBO_BOX, EActionComboBoxClass))
-#define E_IS_ACTION_COMBO_BOX(obj) \
+#define E_ACTION_IS_COMBO_BOX(obj) \
 	(G_TYPE_CHECK_INSTANCE_TYPE \
 	((obj), E_TYPE_ACTION_COMBO_BOX))
-#define E_IS_ACTION_COMBO_BOX_CLASS(cls) \
+#define E_ACTION_IS_COMBO_BOX_CLASS(cls) \
 	(G_TYPE_CHECK_CLASS_TYPE \
 	((cls), E_TYPE_ACTION_COMBO_BOX))
 #define E_ACTION_COMBO_BOX_GET_CLASS(obj) \
@@ -61,8 +65,7 @@ GType		e_action_combo_box_get_type	(void);
 GtkWidget *	e_action_combo_box_new		(void);
 GtkWidget *	e_action_combo_box_new_with_action
 						(GtkRadioAction *action);
-GtkRadioAction *
-		e_action_combo_box_get_action	(EActionComboBox *combo_box);
+GtkRadioAction *e_action_combo_box_get_action	(EActionComboBox *combo_box);
 void		e_action_combo_box_set_action	(EActionComboBox *combo_box,
 						 GtkRadioAction *action);
 gint		e_action_combo_box_get_current_value
@@ -70,6 +73,12 @@ gint		e_action_combo_box_get_current_value
 void		e_action_combo_box_set_current_value
 						(EActionComboBox *combo_box,
 						 gint current_value);
+void		e_action_combo_box_add_separator_before
+						(EActionComboBox *combo_box,
+						 gint action_value);
+void		e_action_combo_box_add_separator_after
+						(EActionComboBox *combo_box,
+						 gint action_value);
 
 G_END_DECLS
 
diff --git a/widgets/editor/e-editor-actions.c b/widgets/editor/e-editor-actions.c
index 5a6ce52..72b01d5 100644
--- a/widgets/editor/e-editor-actions.c
+++ b/widgets/editor/e-editor-actions.c
@@ -1986,5 +1986,4 @@ editor_actions_init (EEditor *editor)
 		editor->priv->selection, "underline",
 		ACTION (UNDERLINE), "active",
 		G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
-
 }
diff --git a/widgets/editor/e-editor-test.c b/widgets/editor/e-editor-test.c
index 10c335a..559340d 100644
--- a/widgets/editor/e-editor-test.c
+++ b/widgets/editor/e-editor-test.c
@@ -129,7 +129,7 @@ save_dialog (EEditor *editor)
 static void
 view_source_dialog (EEditor *editor,
                     const gchar *title,
-                    const gchar *content_type,
+                    gboolean plain_text,
 		    gboolean show_source)
 {
 	GtkWidget *dialog;
@@ -161,9 +161,16 @@ view_source_dialog (EEditor *editor,
 	gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 6);
 	gtk_window_set_default_size (GTK_WINDOW (dialog), 400, 300);
 
-	html = e_editor_widget_get_text_html (
-		e_editor_get_editor_widget (editor));
-	if (show_source) {
+
+	if (plain_text) {
+		html = e_editor_widget_get_text_plain (
+				e_editor_get_editor_widget (editor));
+	} else {
+		html = e_editor_widget_get_text_html (
+			e_editor_get_editor_widget (editor));
+	}
+
+	if (show_source || plain_text) {
 		GtkTextBuffer *buffer;
 
 
@@ -249,21 +256,21 @@ static void
 action_view_html_output (GtkAction *action,
                          EEditor *editor)
 {
-	view_source_dialog (editor, _("HTML Output"), "text/html", FALSE);
+	view_source_dialog (editor, _("HTML Output"), FALSE, FALSE);
 }
 
 static void
 action_view_html_source (GtkAction *action,
                          EEditor *editor)
 {
-	view_source_dialog (editor, _("HTML Source"), "text/html", TRUE);
+	view_source_dialog (editor, _("HTML Source"), FALSE, TRUE);
 }
 
 static void
 action_view_plain_source (GtkAction *action,
                           EEditor *editor)
 {
-	view_source_dialog (editor, _("Plain Source"), "text/plain", FALSE);
+	view_source_dialog (editor, _("Plain Source"), TRUE, FALSE);
 }
 
 static void
diff --git a/widgets/misc/Makefile.am b/widgets/misc/Makefile.am
index c5e5926..d2a7e2f 100644
--- a/widgets/misc/Makefile.am
+++ b/widgets/misc/Makefile.am
@@ -5,7 +5,6 @@ widgetsincludedir = $(privincludedir)/misc
 ui_DATA = e-send-options.ui
 
 widgetsinclude_HEADERS =			\
-	e-action-combo-box.h			\
 	e-activity-bar.h			\
 	e-activity-proxy.h			\
 	e-alarm-selector.h			\
@@ -95,7 +94,6 @@ libemiscwidgets_la_CPPFLAGS =						\
 
 libemiscwidgets_la_SOURCES =			\
 	$(widgetsinclude_HEADERS)		\
-	e-action-combo-box.c			\
 	e-activity-bar.c			\
 	e-activity-proxy.c			\
 	e-alarm-selector.c			\
diff --git a/widgets/misc/e-charset-combo-box.h b/widgets/misc/e-charset-combo-box.h
index 471dfa6..8000b7d 100644
--- a/widgets/misc/e-charset-combo-box.h
+++ b/widgets/misc/e-charset-combo-box.h
@@ -22,7 +22,7 @@
 #ifndef E_CHARSET_COMBO_BOX_H
 #define E_CHARSET_COMBO_BOX_H
 
-#include <misc/e-action-combo-box.h>
+#include <editor/e-action-combo-box.h>
 
 /* Standard GObject macros */
 #define E_TYPE_CHARSET_COMBO_BOX \



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