diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2009-05-27 23:13:25 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2009-05-29 00:13:23 +0800 |
commit | fad4af8a3d4c6f50f7bcceca8d545eb17d6fd056 (patch) | |
tree | ae78be371695c3dc18847b87d3f014f985aa3a40 /widgets/table/e-table-example-2.c | |
parent | 6f5464f34ceec9e5701e3e3e651a40f9e6b3a072 (diff) | |
download | gsoc2013-evolution-fad4af8a3d4c6f50f7bcceca8d545eb17d6fd056.tar gsoc2013-evolution-fad4af8a3d4c6f50f7bcceca8d545eb17d6fd056.tar.gz gsoc2013-evolution-fad4af8a3d4c6f50f7bcceca8d545eb17d6fd056.tar.bz2 gsoc2013-evolution-fad4af8a3d4c6f50f7bcceca8d545eb17d6fd056.tar.lz gsoc2013-evolution-fad4af8a3d4c6f50f7bcceca8d545eb17d6fd056.tar.xz gsoc2013-evolution-fad4af8a3d4c6f50f7bcceca8d545eb17d6fd056.tar.zst gsoc2013-evolution-fad4af8a3d4c6f50f7bcceca8d545eb17d6fd056.zip |
Prefer GLib basic types over C types.
Diffstat (limited to 'widgets/table/e-table-example-2.c')
-rw-r--r-- | widgets/table/e-table-example-2.c | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/widgets/table/e-table-example-2.c b/widgets/table/e-table-example-2.c index ac12886813..ca4128590c 100644 --- a/widgets/table/e-table-example-2.c +++ b/widgets/table/e-table-example-2.c @@ -43,10 +43,10 @@ the ETableSimple class. Instead of creating your own ETableModel class, you simply create a new object of the ETableSimple class. You give it a bunch of functions that act as callbacks. -You also get to pass a void * to ETableSimple and it gets passed to +You also get to pass a gpointer to ETableSimple and it gets passed to your callbacks. This would be for having multiple models of the same type. This is just an example though, so we statically define all the -data and ignore the void *data parameter. +data and ignore the gpointer data parameter. In our example we will be creating a table model with 6 columns and 10 rows. This corresponds to having 6 different types of information and @@ -100,7 +100,7 @@ The headers will be hard coded, as will be the example data. <grouping> <leaf column=\"1\" ascending=\"true\"/> </grouping> \ </ETableSpecification>" -char *headers[VIEW_COLS] = { +gchar *headers[VIEW_COLS] = { "Email", "Full Name", "Address", @@ -119,7 +119,7 @@ char *headers[VIEW_COLS] = { Importance field. */ -char *table_data[ROWS][VIEW_COLS]; +gchar *table_data[ROWS][VIEW_COLS]; gboolean importance_data[ROWS]; /* @@ -134,19 +134,19 @@ static GdkColor *color1; static GdkColor *color2; static int -my_col_count (ETableModel *etc, void *data) +my_col_count (ETableModel *etc, gpointer data) { return VIRTUAL_COLS; } static int -my_row_count (ETableModel *etc, void *data) +my_row_count (ETableModel *etc, gpointer data) { return ROWS; } -static void * -my_value_at (ETableModel *etc, int col, int row, void *data) +static gpointer +my_value_at (ETableModel *etc, gint col, gint row, gpointer data) { if (col == COLOR_COLUMN){ if (importance_data[row]){ @@ -157,12 +157,12 @@ my_value_at (ETableModel *etc, int col, int row, void *data) } else if (col == IMPORTANCE_COLUMN){ return (gpointer) importance_data[row]; } else { - return (void *) table_data [row][col]; + return (gpointer) table_data [row][col]; } } static void -my_set_value_at (ETableModel *etc, int col, int row, const void *val, void *data) +my_set_value_at (ETableModel *etc, gint col, gint row, gconstpointer val, gpointer data) { if (col == COLOR_COLUMN){ } else if (col == IMPORTANCE_COLUMN){ @@ -174,7 +174,7 @@ my_set_value_at (ETableModel *etc, int col, int row, const void *val, void *data } static gboolean -my_is_cell_editable (ETableModel *etc, int col, int row, void *data) +my_is_cell_editable (ETableModel *etc, gint col, gint row, gpointer data) { if (col == IMPORTANCE_COLUMN) return FALSE; @@ -182,20 +182,20 @@ my_is_cell_editable (ETableModel *etc, int col, int row, void *data) return TRUE; } -static void * -my_duplicate_value (ETableModel *etc, int col, const void *value, void *data) +static gpointer +my_duplicate_value (ETableModel *etc, gint col, gconstpointer value, gpointer data) { if (col == COLOR_COLUMN){ - return (void *) value; + return (gpointer) value; } else if (col == IMPORTANCE_COLUMN){ - return (void *) value; + return (gpointer) value; } else { return g_strdup (value); } } static void -my_free_value (ETableModel *etc, int col, void *value, void *data) +my_free_value (ETableModel *etc, gint col, gpointer value, gpointer data) { if (col == COLOR_COLUMN){ } else if (col == IMPORTANCE_COLUMN){ @@ -204,8 +204,8 @@ my_free_value (ETableModel *etc, int col, void *value, void *data) } } -static void * -my_initialize_value (ETableModel *etc, int col, void *data) +static gpointer +my_initialize_value (ETableModel *etc, gint col, gpointer data) { if (col == COLOR_COLUMN){ return NULL; @@ -217,19 +217,19 @@ my_initialize_value (ETableModel *etc, int col, void *data) } static gboolean -my_value_is_empty (ETableModel *etc, int col, const void *value, void *data) +my_value_is_empty (ETableModel *etc, gint col, gconstpointer value, gpointer data) { if (col == COLOR_COLUMN){ return value == NULL; } else if (col == IMPORTANCE_COLUMN){ return value == NULL; } else { - return !(value && *(char *)value); + return !(value && *(gchar *)value); } } -static char * -my_value_to_string (ETableModel *etc, int col, const void *value, void *data) +static gchar * +my_value_to_string (ETableModel *etc, gint col, gconstpointer value, gpointer data) { if (col == COLOR_COLUMN){ return g_strdup_printf("%d", (int) value); @@ -248,7 +248,7 @@ create_table () ECell *cell_left_just; ECell *cell_checkbox; ETableHeader *e_table_header; - int i, j; + gint i, j; ETableModel *e_table_model = NULL; ETableCol *ecol; GdkPixbuf *pixbuf; @@ -333,8 +333,8 @@ create_table () -int -main (int argc, char *argv []) +gint +main (gint argc, gchar *argv []) { gnome_init ("TableExample", "TableExample", argc, argv); e_cursors_init (); |