aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorMiguel de Icaza <miguel@ximian.com>2001-01-12 15:53:15 +0800
committerMiguel de Icaza <miguel@src.gnome.org>2001-01-12 15:53:15 +0800
commit0db9dfca79bc3292c6459e5fef8603b83128427d (patch)
tree2fe5daecfb7061266f496a05f1699a5595b86b18 /widgets
parent07340ec35b86cff39708d16c24f3e6478a4d35c1 (diff)
downloadgsoc2013-evolution-0db9dfca79bc3292c6459e5fef8603b83128427d.tar.gz
gsoc2013-evolution-0db9dfca79bc3292c6459e5fef8603b83128427d.tar.zst
gsoc2013-evolution-0db9dfca79bc3292c6459e5fef8603b83128427d.zip
Implement new function API. Remove Gtk arguments for this. (ect_height):
2001-01-12 Miguel de Icaza <miguel@ximian.com> * e-cell-text.c (e_cell_text_set_filter): Implement new function API. Remove Gtk arguments for this. (ect_height): Pass all the extra information Dan requested. (ect_print): Pass all the extra information Dan requested. (build_current_cell): ditto. svn path=/trunk/; revision=7444
Diffstat (limited to 'widgets')
-rw-r--r--widgets/table/e-cell-text.c40
-rw-r--r--widgets/table/e-cell-text.h14
2 files changed, 32 insertions, 22 deletions
diff --git a/widgets/table/e-cell-text.c b/widgets/table/e-cell-text.c
index f16cfe7954..8d7d94deac 100644
--- a/widgets/table/e-cell-text.c
+++ b/widgets/table/e-cell-text.c
@@ -63,8 +63,7 @@ enum {
ARG_STRIKEOUT_COLUMN,
ARG_BOLD_COLUMN,
- ARG_TEXT_FILTER,
- ARG_COLOR_COLUMN,
+ ARG_COLOR_COLUMN
};
@@ -894,7 +893,9 @@ ect_height (ECellView *ecell_view, int model_col, int view_col, int row)
gchar *string;
gint value;
- string = (*ect->filter)(e_table_model_value_at (ecell_view->e_table_model, model_col, row));
+ string = (*ect->filter)(
+ ecell_view->e_table_model,
+ model_col, row, ect->filter_closure);
value = e_font_height (font) * number_of_lines(string) + TEXT_PAD;
g_free(string);
@@ -963,7 +964,8 @@ ect_enter_edit (ECellView *ecell_view, int model_col, int view_col, int row)
edit->default_cursor_shown = TRUE;
if (ect->filter) {
- edit->old_text = (*ect->filter)(e_table_model_value_at (ecell_view->e_table_model, model_col, row));
+ edit->old_text = (*ect->filter)(
+ ecell_view->e_table_model, model_col, row, ect->filter_closure);
} else {
edit->old_text = g_strdup (e_table_model_value_at (ecell_view->e_table_model, model_col, row));
}
@@ -1014,7 +1016,8 @@ ect_print (ECellView *ecell_view, GnomePrintContext *context,
char *string;
ECellText *ect = E_CELL_TEXT(ecell_view->ecell);
if (ect->filter) {
- string = (*ect->filter)(e_table_model_value_at (ecell_view->e_table_model, model_col, row));
+ string = (*ect->filter)(
+ ecell_view->e_table_model, model_col, row, ect->filter_closure);
} else {
string = e_table_model_value_at (ecell_view->e_table_model, model_col, row);
}
@@ -1036,7 +1039,7 @@ ect_print (ECellView *ecell_view, GnomePrintContext *context,
gnome_print_show(context, string);
gnome_print_grestore(context);
if (ect->filter) {
- g_free(string);
+ g_free (string);
}
}
@@ -1302,9 +1305,6 @@ ect_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
text->color_column = GTK_VALUE_INT (*arg);
break;
- case ARG_TEXT_FILTER:
- text->filter = GTK_VALUE_POINTER (*arg);
- break;
default:
return;
}
@@ -1331,10 +1331,6 @@ ect_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
GTK_VALUE_INT (*arg) = text->color_column;
break;
- case ARG_TEXT_FILTER:
- GTK_VALUE_POINTER (*arg) = text->filter;
- break;
-
default:
arg->type = GTK_TYPE_INVALID;
break;
@@ -1373,13 +1369,24 @@ e_cell_text_class_init (GtkObjectClass *object_class)
GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_BOLD_COLUMN);
gtk_object_add_arg_type ("ECellText::color_column",
GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_COLOR_COLUMN);
- gtk_object_add_arg_type ("ECellText::text_filter",
- GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_TEXT_FILTER);
if (!clipboard_atom)
clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE);
}
+void
+e_cell_text_set_filter (ECell *ecell, ECellTextFilter filter, void *closure)
+{
+ ECellText *ect;
+
+ g_return_if_fail (ecell != NULL);
+ g_return_if_fail (E_IS_CELL_TEXT (ecell));
+
+ ect = E_CELL_TEXT (ecell);
+ ect->filter = filter;
+ ect->filter_closure = closure;
+}
+
static void
e_cell_text_init (ECellText *ect)
{
@@ -2326,7 +2333,8 @@ build_current_cell (CurrentCell *cell, ECellTextView *text_view, int model_col,
cell->breaks = NULL;
if (ect->filter) {
- cell->text = (*ect->filter)(e_table_model_value_at (ecell_view->e_table_model, model_col, row));
+ cell->text = (*ect->filter)(
+ ecell_view->e_table_model, model_col, row, ect->filter_closure);
} else {
cell->text = g_strdup (e_table_model_value_at (ecell_view->e_table_model, model_col, row));
}
diff --git a/widgets/table/e-cell-text.h b/widgets/table/e-cell-text.h
index ef3ffeab35..c3a8dd546b 100644
--- a/widgets/table/e-cell-text.h
+++ b/widgets/table/e-cell-text.h
@@ -28,7 +28,7 @@
#include <gal/e-table/e-cell.h>
/* Should return a malloced object. */
-typedef char *(*ECellTextFilter) (const void *);
+typedef char *(*ECellTextFilter) (ETableModel *table_model, int model_col, int row, void *closure);
#define E_CELL_TEXT_TYPE (e_cell_text_get_type ())
#define E_CELL_TEXT(o) (GTK_CHECK_CAST ((o), E_CELL_TEXT_TYPE, ECellText))
@@ -59,8 +59,9 @@ typedef struct {
See the XParseColor man page for the formats available. */
int color_column;
- ECellTextFilter filter;
-
+ ECellTextFilter filter;
+ void *filter_closure;
+
/* This stores the colors we have allocated. */
GHashTable *colors;
} ECellText;
@@ -69,9 +70,10 @@ typedef struct {
ECellClass parent_class;
} ECellTextClass;
-GtkType e_cell_text_get_type (void);
-ECell *e_cell_text_new (const char *fontname, GtkJustification justify);
-
+GtkType e_cell_text_get_type (void);
+ECell *e_cell_text_new (const char *fontname, GtkJustification justify);
+void e_cell_text_set_filter (ECell *ecell_text, ECellTextFilter filter, void *closure);
+
#endif /* _E_CELL_TEXT_H_ */