[evolution] ECellText cleanups.



commit 1884f66c02bfd0373b21f5d7f772523751256a5d
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sun Aug 29 08:27:27 2010 -0400

    ECellText cleanups.

 calendar/gui/e-cell-date-edit-text.c |    2 +-
 widgets/table/e-cell-date.c          |    4 +-
 widgets/table/e-cell-date.h          |   51 +++++++---
 widgets/table/e-cell-number.c        |    4 +-
 widgets/table/e-cell-number.h        |   47 +++++++---
 widgets/table/e-cell-percent.c       |    4 +-
 widgets/table/e-cell-percent.h       |   51 +++++++---
 widgets/table/e-cell-size.c          |    4 +-
 widgets/table/e-cell-size.h          |   47 +++++++---
 widgets/table/e-cell-text.c          |  170 +++++++++++++++++++++------------
 widgets/table/e-cell-text.h          |  125 +++++++++++++++++++------
 11 files changed, 346 insertions(+), 163 deletions(-)
---
diff --git a/calendar/gui/e-cell-date-edit-text.c b/calendar/gui/e-cell-date-edit-text.c
index 3788668..867cb89 100644
--- a/calendar/gui/e-cell-date-edit-text.c
+++ b/calendar/gui/e-cell-date-edit-text.c
@@ -296,7 +296,7 @@ e_cell_date_edit_text_get_type (void)
 		};
 
 		type = g_type_register_static (
-			E_CELL_TEXT_TYPE, "ECellDateEditText", &type_info, 0);
+			E_TYPE_CELL_TEXT, "ECellDateEditText", &type_info, 0);
 	}
 
 	return type;
diff --git a/widgets/table/e-cell-date.c b/widgets/table/e-cell-date.c
index a66ef1c..54b19ea 100644
--- a/widgets/table/e-cell-date.c
+++ b/widgets/table/e-cell-date.c
@@ -34,7 +34,7 @@
 
 #include "e-cell-date.h"
 
-G_DEFINE_TYPE (ECellDate, e_cell_date, E_CELL_TEXT_TYPE)
+G_DEFINE_TYPE (ECellDate, e_cell_date, E_TYPE_CELL_TEXT)
 
 static gchar *
 ecd_get_text(ECellText *cell, ETableModel *model, gint col, gint row)
@@ -102,7 +102,7 @@ e_cell_date_init (ECellDate *ecd)
 ECell *
 e_cell_date_new (const gchar *fontname, GtkJustification justify)
 {
-	ECellDate *ecd = g_object_new (E_CELL_DATE_TYPE, NULL);
+	ECellDate *ecd = g_object_new (E_TYPE_CELL_DATE, NULL);
 
 	e_cell_text_construct(E_CELL_TEXT(ecd), fontname, justify);
 
diff --git a/widgets/table/e-cell-date.h b/widgets/table/e-cell-date.h
index ec23bd6..5753d24 100644
--- a/widgets/table/e-cell-date.h
+++ b/widgets/table/e-cell-date.h
@@ -21,31 +21,50 @@
  *
  */
 
-#ifndef _E_CELL_DATE_H_
-#define _E_CELL_DATE_H_
+#ifndef E_CELL_DATE_H
+#define E_CELL_DATE_H
 
 #include <table/e-cell-text.h>
 
+/* Standard GObject macros */
+#define E_TYPE_CELL_DATE \
+	(e_cell_date_get_type ())
+#define E_CELL_DATE(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_CELL_DATE, ECellDate))
+#define E_CELL_DATE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_CELL_DATE, ECellDateClass))
+#define E_IS_CELL_DATE(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_CELL_DATE))
+#define E_IS_CELL_DATE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_CELL_DATE))
+#define E_CELL_DATE_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_CELL_DATE, ECellDateClass))
+
 G_BEGIN_DECLS
 
-#define E_CELL_DATE_TYPE        (e_cell_date_get_type ())
-#define E_CELL_DATE(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), E_CELL_DATE_TYPE, ECellDate))
-#define E_CELL_DATE_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST((k), E_CELL_DATE_TYPE, ECellDateClass))
-#define E_IS_CELL_DATE(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_CELL_DATE_TYPE))
-#define E_IS_CELL_DATE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_CELL_DATE_TYPE))
+typedef struct _ECellDate ECellDate;
+typedef struct _ECellDateClass ECellDateClass;
 
-typedef struct {
-	ECellText base;
-} ECellDate;
+struct _ECellDate {
+	ECellText parent;
+};
 
-typedef struct {
+struct _ECellDateClass {
 	ECellTextClass parent_class;
-} ECellDateClass;
+};
 
-GType      e_cell_date_get_type (void);
-ECell     *e_cell_date_new      (const gchar *fontname, GtkJustification justify);
-void       e_cell_date_set_format_component (ECellDate *ecd, const gchar *fmt_component);
+GType		e_cell_date_get_type		(void);
+ECell *		e_cell_date_new			(const gchar *fontname,
+						 GtkJustification justify);
+void		e_cell_date_set_format_component
+						(ECellDate *ecd,
+						 const gchar *fmt_component);
 
 G_END_DECLS
 
-#endif /* _E_CELL_DATE_H_ */
+#endif /* E_CELL_DATE_H */
diff --git a/widgets/table/e-cell-number.c b/widgets/table/e-cell-number.c
index 63f55eb..c28d5a4 100644
--- a/widgets/table/e-cell-number.c
+++ b/widgets/table/e-cell-number.c
@@ -30,7 +30,7 @@
 
 #include "e-cell-number.h"
 
-G_DEFINE_TYPE (ECellNumber, e_cell_number, E_CELL_TEXT_TYPE)
+G_DEFINE_TYPE (ECellNumber, e_cell_number, E_TYPE_CELL_TEXT)
 
 static gchar *
 ecn_get_text(ECellText *cell, ETableModel *model, gint col, gint row)
@@ -74,7 +74,7 @@ e_cell_number_init (ECellNumber *cell_number)
 ECell *
 e_cell_number_new (const gchar *fontname, GtkJustification justify)
 {
-	ECellNumber *ecn = g_object_new (E_CELL_NUMBER_TYPE, NULL);
+	ECellNumber *ecn = g_object_new (E_TYPE_CELL_NUMBER, NULL);
 
 	e_cell_text_construct(E_CELL_TEXT(ecn), fontname, justify);
 
diff --git a/widgets/table/e-cell-number.h b/widgets/table/e-cell-number.h
index fcba9f5..25e4d3a 100644
--- a/widgets/table/e-cell-number.h
+++ b/widgets/table/e-cell-number.h
@@ -21,30 +21,47 @@
  *
  */
 
-#ifndef _E_CELL_NUMBER_H_
-#define _E_CELL_NUMBER_H_
+#ifndef E_CELL_NUMBER_H
+#define E_CELL_NUMBER_H
 
 #include <table/e-cell-text.h>
 
+/* Standard GObject macros */
+#define E_TYPE_CELL_NUMBER \
+	(e_cell_number_get_type ())
+#define E_CELL_NUMBER(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_CELL_NUMBER, ECellNumber))
+#define E_CELL_NUMBER_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_CELL_NUMBER, ECellNumberClass))
+#define E_IS_CELL_NUMBER(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_CELL_NUMBER))
+#define E_IS_CELL_NUMBER_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_CELL_NUMBER))
+#define E_CELL_NUMBER_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_CELL_NUMBER, ECellNumberClass))
+
 G_BEGIN_DECLS
 
-#define E_CELL_NUMBER_TYPE        (e_cell_number_get_type ())
-#define E_CELL_NUMBER(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), E_CELL_NUMBER_TYPE, ECellNumber))
-#define E_CELL_NUMBER_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST((k), E_CELL_NUMBER_TYPE, ECellNumberClass))
-#define E_IS_CELL_NUMBER(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_CELL_NUMBER_TYPE))
-#define E_IS_CELL_NUMBER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_CELL_NUMBER_TYPE))
+typedef struct _ECellNumber ECellNumber;
+typedef struct _ECellNumberClass ECellNumberClass;
 
-typedef struct {
-	ECellText base;
-} ECellNumber;
+struct _ECellNumber {
+	ECellText parent;
+};
 
-typedef struct {
+struct _ECellNumberClass {
 	ECellTextClass parent_class;
-} ECellNumberClass;
+};
 
-GType      e_cell_number_get_type (void);
-ECell     *e_cell_number_new      (const gchar *fontname, GtkJustification justify);
+GType		e_cell_number_get_type		(void);
+ECell *		e_cell_number_new		(const gchar *fontname,
+						 GtkJustification justify);
 
 G_END_DECLS
 
-#endif /* _E_CELL_NUMBER_H_ */
+#endif /* E_CELL_NUMBER_H */
diff --git a/widgets/table/e-cell-percent.c b/widgets/table/e-cell-percent.c
index 3ed9954..83c60ce 100644
--- a/widgets/table/e-cell-percent.c
+++ b/widgets/table/e-cell-percent.c
@@ -38,7 +38,7 @@
 
 #include "e-cell-percent.h"
 
-G_DEFINE_TYPE (ECellPercent, e_cell_percent, E_CELL_TEXT_TYPE)
+G_DEFINE_TYPE (ECellPercent, e_cell_percent, E_TYPE_CELL_TEXT)
 
 static gchar *
 ecp_get_text (ECellText *cell, ETableModel *model, gint col, gint row)
@@ -143,7 +143,7 @@ e_cell_percent_init (ECellPercent *ecp)
 ECell *
 e_cell_percent_new (const gchar *fontname, GtkJustification justify)
 {
-	ECellPercent *ecn = g_object_new (E_CELL_PERCENT_TYPE, NULL);
+	ECellPercent *ecn = g_object_new (E_TYPE_CELL_PERCENT, NULL);
 
 	e_cell_text_construct (E_CELL_TEXT(ecn), fontname, justify);
 
diff --git a/widgets/table/e-cell-percent.h b/widgets/table/e-cell-percent.h
index 3ac15af..691c8bc 100644
--- a/widgets/table/e-cell-percent.h
+++ b/widgets/table/e-cell-percent.h
@@ -26,26 +26,47 @@
  * in an ETable.
  */
 
-#ifndef _E_CELL_PERCENT_H_
-#define _E_CELL_PERCENT_H_
+#ifndef E_CELL_PERCENT_H
+#define E_CELL_PERCENT_H
 
 #include <table/e-cell-text.h>
 
-#define E_CELL_PERCENT_TYPE        (e_cell_percent_get_type ())
-#define E_CELL_PERCENT(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), E_CELL_PERCENT_TYPE, ECellPercent))
-#define E_CELL_PERCENT_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST ((k), E_CELL_PERCENT_TYPE, ECellPercentClass))
-#define E_IS_CELL_NUMBER(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_CELL_PERCENT_TYPE))
-#define E_IS_CELL_NUMBER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_CELL_PERCENT_TYPE))
+/* Standard GObject macros */
+#define E_TYPE_CELL_PERCENT \
+	(e_cell_percent_get_type ())
+#define E_CELL_PERCENT(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_CELL_PERCENT, ECellPercent))
+#define E_CELL_PERCENT_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_CELL_PERCENT, ECellPercentClass))
+#define E_IS_CELL_NUMBER(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_CELL_PERCENT))
+#define E_IS_CELL_NUMBER_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_CELL_PERCENT))
+#define E_CELL_NUMBER_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_CELL_PERCENT, ECellPercentClass))
 
-typedef struct {
-	ECellText base;
-} ECellPercent;
+G_BEGIN_DECLS
 
-typedef struct {
+typedef struct _ECellPercent ECellPercent;
+typedef struct _ECellPercentClass ECellPercentClass;
+
+struct _ECellPercent {
+	ECellText parent;
+};
+
+struct _ECellPercentClass {
 	ECellTextClass parent_class;
-} ECellPercentClass;
+};
+
+GType		e_cell_percent_get_type		(void);
+ECell *		e_cell_percent_new		(const gchar *fontname,
+						 GtkJustification justify);
 
-GType      e_cell_percent_get_type (void);
-ECell     *e_cell_percent_new      (const gchar *fontname, GtkJustification justify);
+G_END_DECLS
 
-#endif /* _E_CELL_PERCENT_H_ */
+#endif /* E_CELL_PERCENT_H */
diff --git a/widgets/table/e-cell-size.c b/widgets/table/e-cell-size.c
index e2b379f..e44cc1e 100644
--- a/widgets/table/e-cell-size.c
+++ b/widgets/table/e-cell-size.c
@@ -29,7 +29,7 @@
 
 #include "e-cell-size.h"
 
-G_DEFINE_TYPE (ECellSize, e_cell_size, E_CELL_TEXT_TYPE)
+G_DEFINE_TYPE (ECellSize, e_cell_size, E_TYPE_CELL_TEXT)
 
 static gchar *
 ecd_get_text(ECellText *cell, ETableModel *model, gint col, gint row)
@@ -98,7 +98,7 @@ e_cell_size_init (ECellSize *e_cell_size)
 ECell *
 e_cell_size_new (const gchar *fontname, GtkJustification justify)
 {
-	ECellSize *ecd = g_object_new (E_CELL_SIZE_TYPE, NULL);
+	ECellSize *ecd = g_object_new (E_TYPE_CELL_SIZE, NULL);
 
 	e_cell_text_construct(E_CELL_TEXT(ecd), fontname, justify);
 
diff --git a/widgets/table/e-cell-size.h b/widgets/table/e-cell-size.h
index 2b335d7..de4b56b 100644
--- a/widgets/table/e-cell-size.h
+++ b/widgets/table/e-cell-size.h
@@ -22,30 +22,47 @@
  *
  */
 
-#ifndef _E_CELL_SIZE_H_
-#define _E_CELL_SIZE_H_
+#ifndef E_CELL_SIZE_H
+#define E_CELL_SIZE_H
 
 #include <table/e-cell-text.h>
 
+/* Standard GObject macros */
+#define E_TYPE_CELL_SIZE \
+	(e_cell_size_get_type ())
+#define E_CELL_SIZE(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_CELL_SIZE, ECellSize))
+#define E_CELL_SIZE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_CELL_SIZE, ECellSizeClass))
+#define E_IS_CELL_SIZE(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_CELL_SIZE))
+#define E_IS_CELL_SIZE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_CELL_SIZE))
+#define E_CELL_SIZE_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_CELL_SIZE, ECellSizeClass))
+
 G_BEGIN_DECLS
 
-#define E_CELL_SIZE_TYPE        (e_cell_size_get_type ())
-#define E_CELL_SIZE(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), E_CELL_SIZE_TYPE, ECellSize))
-#define E_CELL_SIZE_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST((k), E_CELL_SIZE_TYPE, ECellSizeClass))
-#define E_IS_CELL_SIZE(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_CELL_SIZE_TYPE))
-#define E_IS_CELL_SIZE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_CELL_SIZE_TYPE))
+typedef struct _ECellSize ECellSize;
+typedef struct _ECellSizeClass ECellSizeClass;
 
-typedef struct {
-	ECellText base;
-} ECellSize;
+struct _ECellSize {
+	ECellText parent;
+};
 
-typedef struct {
+struct _ECellSizeClass {
 	ECellTextClass parent_class;
-} ECellSizeClass;
+};
 
-GType      e_cell_size_get_type (void);
-ECell     *e_cell_size_new      (const gchar *fontname, GtkJustification justify);
+GType		e_cell_size_get_type		(void);
+ECell *		e_cell_size_new			(const gchar *fontname,
+						 GtkJustification justify);
 
 G_END_DECLS
 
-#endif /* _E_CELL_SIZE_H_ */
+#endif /* E_CELL_SIZE_H */
diff --git a/widgets/table/e-cell-text.c b/widgets/table/e-cell-text.c
index ae4b31d..3c9a2c7 100644
--- a/widgets/table/e-cell-text.c
+++ b/widgets/table/e-cell-text.c
@@ -69,8 +69,6 @@
 #define e_table_item_leave_edit_(x) (e_table_item_leave_edit((x)))
 #endif
 
-#define ECT_CLASS(c) (E_CELL_TEXT_CLASS(GTK_OBJECT_GET_CLASS ((c))))
-
 /* This defines a line of text */
 struct line {
 	gchar *text;	/* Line's text UTF-8, it is a pointer into the text->text string */
@@ -215,30 +213,6 @@ static void _delete_selection (ECellTextView *text_view);
 static PangoAttrList* build_attr_list (ECellTextView *text_view, gint row, gint text_length);
 static void update_im_cursor_location (ECellTextView *tv);
 
-gchar *
-e_cell_text_get_text (ECellText *cell, ETableModel *model, gint col, gint row)
-{
-	if (ECT_CLASS(cell)->get_text)
-		return ECT_CLASS(cell)->get_text (cell, model, col, row);
-	else
-		return NULL;
-}
-
-void
-e_cell_text_free_text (ECellText *cell, gchar *text)
-{
-	if (ECT_CLASS(cell)->free_text)
-		ECT_CLASS(cell)->free_text (cell, text);
-}
-
-void
-e_cell_text_set_value (ECellText *cell, ETableModel *model, gint col, gint row,
-		       const gchar *text)
-{
-	if (ECT_CLASS(cell)->set_value)
-		ECT_CLASS(cell)->set_value (cell, model, col, row, text);
-}
-
 static gchar *
 ect_real_get_text (ECellText *cell, ETableModel *model, gint col, gint row)
 {
@@ -1715,7 +1689,7 @@ e_cell_text_class_init (ECellTextClass *klass)
 		}
 	}
 
-	gal_a11y_e_cell_registry_add_cell_type (NULL, E_CELL_TEXT_TYPE, gal_a11y_e_cell_text_new);
+	gal_a11y_e_cell_registry_add_cell_type (NULL, E_TYPE_CELL_TEXT, gal_a11y_e_cell_text_new);
 }
 
 /* IM Context Callbacks */
@@ -1874,28 +1848,6 @@ e_cell_text_init (ECellText *ect)
 }
 
 /**
- * e_cell_text_construct:
- * @cell: The cell to construct
- * @fontname: this param is no longer used, but left here for api stability
- * @justify: Justification of the string in the cell
- *
- * constructs the ECellText.  To be used by subclasses and language
- * bindings.
- *
- * Returns: The ECellText.
- */
-ECell *
-e_cell_text_construct (ECellText *cell, const gchar *fontname, GtkJustification justify)
-{
-	if (!cell)
-		return E_CELL(NULL);
-	if (fontname)
-		cell->font_name = g_strdup (fontname);
-	cell->justify = justify;
-	return E_CELL(cell);
-}
-
-/**
  * e_cell_text_new:
  * @fontname: this param is no longer used, but left here for api stability
  * @justify: Justification of the string in the cell.
@@ -1923,13 +1875,87 @@ e_cell_text_construct (ECellText *cell, const gchar *fontname, GtkJustification
 ECell *
 e_cell_text_new (const gchar *fontname, GtkJustification justify)
 {
-	ECellText *ect = g_object_new (E_CELL_TEXT_TYPE, NULL);
+	ECellText *ect = g_object_new (E_TYPE_CELL_TEXT, NULL);
 
 	e_cell_text_construct(ect, fontname, justify);
 
 	return (ECell *) ect;
 }
 
+/**
+ * e_cell_text_construct:
+ * @cell: The cell to construct
+ * @fontname: this param is no longer used, but left here for api stability
+ * @justify: Justification of the string in the cell
+ *
+ * constructs the ECellText.  To be used by subclasses and language
+ * bindings.
+ *
+ * Returns: The ECellText.
+ */
+ECell *
+e_cell_text_construct (ECellText *cell,
+                       const gchar *fontname,
+                       GtkJustification justify)
+{
+	if (!cell)
+		return E_CELL(NULL);
+	if (fontname)
+		cell->font_name = g_strdup (fontname);
+	cell->justify = justify;
+	return E_CELL(cell);
+}
+
+gchar *
+e_cell_text_get_text (ECellText *cell,
+                      ETableModel *model,
+                      gint col,
+                      gint row)
+{
+	ECellTextClass *class;
+
+	g_return_val_if_fail (E_IS_CELL_TEXT (cell), NULL);
+
+	class = E_CELL_TEXT_GET_CLASS (cell);
+	if (class->get_text == NULL)
+		return NULL;
+
+	return class->get_text (cell, model, col, row);
+}
+
+void
+e_cell_text_free_text (ECellText *cell,
+                       gchar *text)
+{
+	ECellTextClass *class;
+
+	g_return_if_fail (E_IS_CELL_TEXT (cell));
+
+	class = E_CELL_TEXT_GET_CLASS (cell);
+	if (class->free_text == NULL)
+		return;
+
+	class->free_text (cell, text);
+}
+
+void
+e_cell_text_set_value (ECellText *cell,
+                       ETableModel *model,
+                       gint col,
+                       gint row,
+                       const gchar *text)
+{
+	ECellTextClass *class;
+
+	g_return_if_fail (E_IS_CELL_TEXT (cell));
+
+	class = E_CELL_TEXT_GET_CLASS (cell);
+	if (class->set_value == NULL)
+		return;
+
+	class->set_value (cell, model, col, row, text);
+}
+
 /* fixme: Handle Font attributes */
 /* position is in BYTES */
 
@@ -2565,15 +2591,17 @@ e_cell_text_get_color (ECellTextView *cell_view, gchar *color_spec)
  */
 gboolean
 e_cell_text_set_selection (ECellView *cell_view,
-			   gint col,
-			   gint row,
-			   gint start,
-			   gint end)
+                           gint col,
+                           gint row,
+                           gint start,
+                           gint end)
 {
 	ECellTextView *ectv;
 	CellEdit *edit;
 	ETextEventProcessorCommand command1, command2;
 
+	g_return_val_if_fail (cell_view != NULL, FALSE);
+
 	ectv = (ECellTextView *)cell_view;
 	edit = ectv->edit;
 	if (!edit)
@@ -2613,14 +2641,16 @@ e_cell_text_set_selection (ECellView *cell_view,
  */
 gboolean
 e_cell_text_get_selection (ECellView *cell_view,
-			   gint col,
-			   gint row,
-			   gint *start,
-			   gint *end)
+                           gint col,
+                           gint row,
+                           gint *start,
+                           gint *end)
 {
 	ECellTextView *ectv;
 	CellEdit *edit;
 
+	g_return_val_if_fail (cell_view != NULL, FALSE);
+
 	ectv = (ECellTextView *)cell_view;
 	edit = ectv->edit;
 	if (!edit)
@@ -2647,12 +2677,16 @@ e_cell_text_get_selection (ECellView *cell_view,
  * This API is most likely to be used by a11y implementations.
  */
 void
-e_cell_text_copy_clipboard (ECellView *cell_view, gint col, gint row)
+e_cell_text_copy_clipboard (ECellView *cell_view,
+                            gint col,
+                            gint row)
 {
 	ECellTextView *ectv;
 	CellEdit *edit;
 	ETextEventProcessorCommand command;
 
+	g_return_if_fail (cell_view != NULL);
+
 	ectv = (ECellTextView *)cell_view;
 	edit = ectv->edit;
 	if (!edit)
@@ -2677,12 +2711,16 @@ e_cell_text_copy_clipboard (ECellView *cell_view, gint col, gint row)
  * This API is most likely to be used by a11y implementations.
  */
 void
-e_cell_text_paste_clipboard (ECellView *cell_view, gint col, gint row)
+e_cell_text_paste_clipboard (ECellView *cell_view,
+                             gint col,
+                             gint row)
 {
 	ECellTextView *ectv;
 	CellEdit *edit;
 	ETextEventProcessorCommand command;
 
+	g_return_if_fail (cell_view != NULL);
+
 	ectv = (ECellTextView *)cell_view;
 	edit = ectv->edit;
 	if (!edit)
@@ -2707,12 +2745,16 @@ e_cell_text_paste_clipboard (ECellView *cell_view, gint col, gint row)
  * This API is most likely to be used by a11y implementations.
  */
 void
-e_cell_text_delete_selection (ECellView *cell_view, gint col, gint row)
+e_cell_text_delete_selection (ECellView *cell_view,
+                              gint col,
+                              gint row)
 {
 	ECellTextView *ectv;
 	CellEdit *edit;
 	ETextEventProcessorCommand command;
 
+	g_return_if_fail (cell_view != NULL);
+
 	ectv = (ECellTextView *)cell_view;
 	edit = ectv->edit;
 	if (!edit)
@@ -2740,12 +2782,16 @@ e_cell_text_delete_selection (ECellView *cell_view, gint col, gint row)
  * This API is most likely to be used by a11y implementations.
  */
 gchar *
-e_cell_text_get_text_by_view (ECellView *cell_view, gint col, gint row)
+e_cell_text_get_text_by_view (ECellView *cell_view,
+                              gint col,
+                              gint row)
 {
 	ECellTextView *ectv;
 	CellEdit *edit;
 	gchar	*ret, *model_text;
 
+	g_return_val_if_fail (cell_view != NULL, NULL);
+
 	ectv = (ECellTextView *)cell_view;
 	edit = ectv->edit;
 
diff --git a/widgets/table/e-cell-text.h b/widgets/table/e-cell-text.h
index 2cc23a3..c53a374 100644
--- a/widgets/table/e-cell-text.h
+++ b/widgets/table/e-cell-text.h
@@ -35,22 +35,38 @@
  *
  */
 
-#ifndef _E_CELL_TEXT_H_
-#define _E_CELL_TEXT_H_
+#ifndef E_CELL_TEXT_H
+#define E_CELL_TEXT_H
 
 #include <gtk/gtk.h>
 #include <libgnomecanvas/gnome-canvas.h>
 #include <table/e-cell.h>
 
+/* Standard GObject macros */
+#define E_TYPE_CELL_TEXT \
+	(e_cell_text_get_type ())
+#define E_CELL_TEXT(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_CELL_TEXT, ECellText))
+#define E_CELL_TEXT_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_CELL_TEXT, ECellTextClass))
+#define E_IS_CELL_TEXT(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_CELL_TEXT))
+#define E_IS_CELL_TEXT_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_CELL_TEXT))
+#define E_CELL_TEXT_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_CELL_TEXT, ECellTextClass))
+
 G_BEGIN_DECLS
 
-#define E_CELL_TEXT_TYPE        (e_cell_text_get_type ())
-#define E_CELL_TEXT(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), E_CELL_TEXT_TYPE, ECellText))
-#define E_CELL_TEXT_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST((k), E_CELL_TEXT_TYPE, ECellTextClass))
-#define E_IS_CELL_TEXT(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_CELL_TEXT_TYPE))
-#define E_IS_CELL_TEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_CELL_TEXT_TYPE))
+typedef struct _ECellText ECellText;
+typedef struct _ECellTextClass ECellTextClass;
 
-typedef struct {
+struct _ECellText {
 	ECell parent;
 
 	GtkJustification  justify;
@@ -78,53 +94,100 @@ typedef struct {
 
 	/* This stores the colors we have allocated. */
 	GHashTable *colors;
-} ECellText;
+};
 
-typedef struct {
+struct _ECellTextClass {
 	ECellClass parent_class;
 
-	gchar *(*get_text)  (ECellText *cell, ETableModel *model, gint col, gint row);
-	void  (*free_text) (ECellText *cell, gchar *text);
-	void  (*set_value) (ECellText *cell, ETableModel *model, gint col, gint row, const gchar *text);
-	/* signal handlers */
-	void (*text_inserted) (ECellText *cell, ECellView *cell_view, gint pos, gint len, gint row, gint model_col);
-	void (*text_deleted)  (ECellText *cell, ECellView *cell_view, gint pos, gint len, gint row, gint model_col);
-} ECellTextClass;
-
-GType      e_cell_text_get_type (void);
-ECell     *e_cell_text_new      (const gchar *fontname, GtkJustification justify);
-ECell     *e_cell_text_construct(ECellText *cell, const gchar *fontname, GtkJustification justify);
+	/* Methods */
+	gchar *		(*get_text)		(ECellText *cell,
+						 ETableModel *model,
+						 gint col,
+						 gint row);
+	void		(*free_text)		(ECellText *cell,
+						 gchar *text);
+	void		(*set_value)		(ECellText *cell,
+						 ETableModel *model,
+						 gint col,
+						 gint row,
+						 const gchar *text);
+
+	/* Signals */
+	void		(*text_inserted)	(ECellText *cell,
+						 ECellView *cell_view,
+						 gint pos,
+						 gint len,
+						 gint row,
+						 gint model_col);
+	void		(*text_deleted)		(ECellText *cell,
+						 ECellView *cell_view,
+						 gint pos,
+						 gint len,
+						 gint row,
+						 gint model_col);
+};
+
+GType		e_cell_text_get_type		(void);
+ECell *		e_cell_text_new			(const gchar *fontname,
+						 GtkJustification justify);
+ECell *		e_cell_text_construct		(ECellText *cell,
+						 const gchar *fontname,
+						 GtkJustification justify);
 
 /* Gets the value from the model and converts it into a string. In ECellText
    itself, the value is assumed to be a gchar * and so needs no conversion.
    In subclasses the ETableModel value may be a more complicated datatype. */
-gchar	  *e_cell_text_get_text (ECellText *cell, ETableModel *model, gint col, gint row);
+gchar *		e_cell_text_get_text		(ECellText *cell,
+						 ETableModel *model,
+						 gint col,
+						 gint row);
 
 /* Frees the value returned by e_cell_text_get_text(). */
-void	   e_cell_text_free_text (ECellText *cell, gchar *text);
+void		e_cell_text_free_text		(ECellText *cell,
+						 gchar *text);
 
 /* Sets the ETableModel value, based on the given string. */
-void	   e_cell_text_set_value (ECellText *cell, ETableModel *model, gint col, gint row, const gchar *text);
+void		e_cell_text_set_value		(ECellText *cell,
+						 ETableModel *model,
+						 gint col,
+						 gint row,
+						 const gchar *text);
 
 /* Sets the selection of given text cell */
-gboolean e_cell_text_set_selection (ECellView *cell_view, gint col, gint row, gint start, gint end);
+gboolean	e_cell_text_set_selection	(ECellView *cell_view,
+						 gint col,
+						 gint row,
+						 gint start,
+						 gint end);
 
 /* Gets the selection of given text cell */
-gboolean e_cell_text_get_selection (ECellView *cell_view, gint col, gint row, gint *start, gint *end);
+gboolean	e_cell_text_get_selection	(ECellView *cell_view,
+						 gint col,
+						 gint row,
+						 gint *start,
+						 gint *end);
 
 /* Copys the selected text to the clipboard */
-void e_cell_text_copy_clipboard (ECellView *cell_view, gint col, gint row);
+void		e_cell_text_copy_clipboard	(ECellView *cell_view,
+						 gint col,
+						 gint row);
 
 /* Pastes the text from the clipboard */
-void e_cell_text_paste_clipboard (ECellView *cell_view, gint col, gint row);
+void		e_cell_text_paste_clipboard	(ECellView *cell_view,
+						 gint col,
+						 gint row);
 
 /* Deletes selected text */
-void e_cell_text_delete_selection (ECellView *cell_view, gint col, gint row);
+void		e_cell_text_delete_selection	(ECellView *cell_view,
+						 gint col,
+						 gint row);
 
 /* get text directly from view, both col and row are model format */
-gchar *e_cell_text_get_text_by_view (ECellView *cell_view, gint col, gint row);
+gchar *		e_cell_text_get_text_by_view	(ECellView *cell_view,
+						 gint col,
+						 gint row);
 
 G_END_DECLS
 
-#endif /* _E_CELL_TEXT_H_ */
+#endif /* E_CELL_TEXT_H */
 



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