aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Toshok <toshok@ximian.com>2002-11-15 10:47:18 +0800
committerChris Toshok <toshok@src.gnome.org>2002-11-15 10:47:18 +0800
commitb39be5377514b9bc3c43b7f5172645edd683e683 (patch)
tree0d55ddbc296c5451fb0af8ca4ffd5295963375a3
parentb9b2089527b62590f70625208d7d68579a51124d (diff)
downloadgsoc2013-evolution-b39be5377514b9bc3c43b7f5172645edd683e683.tar.gz
gsoc2013-evolution-b39be5377514b9bc3c43b7f5172645edd683e683.tar.zst
gsoc2013-evolution-b39be5377514b9bc3c43b7f5172645edd683e683.zip
deal with EBitArray/ESorter being a GObject now.
2002-11-14 Chris Toshok <toshok@ximian.com> * gal/widgets/e-selection-model-array.c: deal with EBitArray/ESorter being a GObject now. * gal/widgets/e-selection-model-simple.c: same. * gal/util/e-bit-array.[ch]: this derives from GObject now. * gal/util/e-sorter.[ch]: same. * gal/util/e-sorter-array.[ch]: same. svn path=/trunk/; revision=18774
-rw-r--r--e-util/e-bit-array.c27
-rw-r--r--e-util/e-bit-array.h16
-rw-r--r--e-util/e-sorter-array.c39
-rw-r--r--e-util/e-sorter-array.h14
-rw-r--r--e-util/e-sorter.c31
-rw-r--r--e-util/e-sorter.h17
-rw-r--r--widgets/misc/e-selection-model-array.c2
-rw-r--r--widgets/misc/e-selection-model-simple.c2
8 files changed, 55 insertions, 93 deletions
diff --git a/e-util/e-bit-array.c b/e-util/e-bit-array.c
index 66a7c38af2..2a79e1bab2 100644
--- a/e-util/e-bit-array.c
+++ b/e-util/e-bit-array.c
@@ -26,9 +26,7 @@
#include "e-bit-array.h"
#include "gal/util/e-util.h"
-#define EBA_CLASS(e) ((EBitArrayClass *)((GtkObject *)e)->klass)
-
-#define PARENT_TYPE (gtk_object_get_type ())
+#define PARENT_TYPE G_TYPE_OBJECT
#define ONES ((guint32) 0xffffffff)
@@ -38,7 +36,7 @@
#define BITMASK_LEFT(n) ((((n) % 32) == 0) ? 0 : (ONES << (32 - ((n) % 32))))
#define BITMASK_RIGHT(n) ((guint32)(((guint32) ONES) >> ((n) % 32)))
-static GtkObjectClass *parent_class;
+static GObjectClass *parent_class;
static void
e_bit_array_insert_real(EBitArray *eba, int row)
@@ -141,17 +139,18 @@ e_bit_array_move_row(EBitArray *eba, int old_row, int new_row)
}
static void
-eba_destroy (GtkObject *object)
+eba_dispose (GObject *object)
{
EBitArray *eba;
eba = E_BIT_ARRAY (object);
- g_free(eba->data);
+ if (eba->data)
+ g_free(eba->data);
eba->data = NULL;
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+ if (G_OBJECT_CLASS (parent_class)->dispose)
+ (* G_OBJECT_CLASS (parent_class)->dispose) (object);
}
/**
@@ -408,13 +407,13 @@ e_bit_array_init (EBitArray *eba)
static void
e_bit_array_class_init (EBitArrayClass *klass)
{
- GtkObjectClass *object_class;
+ GObjectClass *object_class;
- parent_class = gtk_type_class (PARENT_TYPE);
+ parent_class = g_type_class_ref (PARENT_TYPE);
- object_class = GTK_OBJECT_CLASS(klass);
+ object_class = G_OBJECT_CLASS(klass);
- object_class->destroy = eba_destroy;
+ object_class->dispose = eba_dispose;
}
E_MAKE_TYPE(e_bit_array, "EBitArray", EBitArray,
@@ -423,10 +422,8 @@ E_MAKE_TYPE(e_bit_array, "EBitArray", EBitArray,
EBitArray *
e_bit_array_new (int count)
{
- EBitArray *eba = gtk_type_new (e_bit_array_get_type ());
+ EBitArray *eba = g_object_new (E_BIT_ARRAY_TYPE, NULL);
eba->bit_count = count;
eba->data = g_new0(guint32, (eba->bit_count + 31) / 32);
- gtk_object_ref (GTK_OBJECT (eba));
- gtk_object_sink (GTK_OBJECT (eba));
return eba;
}
diff --git a/e-util/e-bit-array.h b/e-util/e-bit-array.h
index c06f405ede..ebfe644da6 100644
--- a/e-util/e-bit-array.h
+++ b/e-util/e-bit-array.h
@@ -24,17 +24,17 @@
#ifndef _E_BIT_ARRAY_H_
#define _E_BIT_ARRAY_H_
-#include <gtk/gtkobject.h>
+#include <glib-object.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define E_BIT_ARRAY_TYPE (e_bit_array_get_type ())
-#define E_BIT_ARRAY(o) (GTK_CHECK_CAST ((o), E_BIT_ARRAY_TYPE, EBitArray))
-#define E_BIT_ARRAY_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_BIT_ARRAY_TYPE, EBitArrayClass))
-#define E_IS_BIT_ARRAY(o) (GTK_CHECK_TYPE ((o), E_BIT_ARRAY_TYPE))
-#define E_IS_BIT_ARRAY_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_BIT_ARRAY_TYPE))
+#define E_BIT_ARRAY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_BIT_ARRAY_TYPE, EBitArray))
+#define E_BIT_ARRAY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_BIT_ARRAY_TYPE, EBitArrayClass))
+#define E_IS_BIT_ARRAY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_BIT_ARRAY_TYPE))
+#define E_IS_BIT_ARRAY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_BIT_ARRAY_TYPE))
#ifndef _E_FOREACH_FUNC_H_
#define _E_FOREACH_FUNC_H_
@@ -43,18 +43,18 @@ typedef void (*EForeachFunc) (int model_row,
#endif
typedef struct {
- GtkObject base;
+ GObject base;
gint bit_count;
guint32 *data;
} EBitArray;
typedef struct {
- GtkObjectClass parent_class;
+ GObjectClass parent_class;
} EBitArrayClass;
-GtkType e_bit_array_get_type (void);
+GType e_bit_array_get_type (void);
EBitArray *e_bit_array_new (int count);
gboolean e_bit_array_value_at (EBitArray *selection,
diff --git a/e-util/e-sorter-array.c b/e-util/e-sorter-array.c
index ffc4d355df..ab1e748d9a 100644
--- a/e-util/e-sorter-array.c
+++ b/e-util/e-sorter-array.c
@@ -24,18 +24,12 @@
#include <config.h>
#include <stdlib.h>
#include <string.h>
-#include <gtk/gtksignal.h>
#include "gal/util/e-util.h"
#include "e-sorter-array.h"
#define d(x)
-/* The arguments we take */
-enum {
- ARG_0
-};
-
-#define PARENT_TYPE e_sorter_get_type()
+#define PARENT_TYPE E_SORTER_TYPE
#define INCREMENT_AMOUNT 100
@@ -233,44 +227,17 @@ e_sorter_array_construct (ESorterArray *esa,
ESorterArray *
e_sorter_array_new (ECompareRowsFunc compare, gpointer closure)
{
- ESorterArray *esa = gtk_type_new (E_SORTER_ARRAY_TYPE);
+ ESorterArray *esa = g_object_new (E_SORTER_ARRAY_TYPE, NULL);
return e_sorter_array_construct (esa, compare, closure);
}
static void
-esa_destroy (GtkObject *object)
-{
- GTK_OBJECT_CLASS (parent_class)->destroy (object);
-}
-
-static void
-esa_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
-{
- switch (arg_id) {
- default:
- break;
- }
-}
-
-static void
-esa_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
-{
- switch (arg_id) {
- }
-}
-
-static void
esa_class_init (ESorterArrayClass *klass)
{
- GtkObjectClass *object_class = GTK_OBJECT_CLASS(klass);
ESorterClass *sorter_class = E_SORTER_CLASS(klass);
- parent_class = gtk_type_class (PARENT_TYPE);
-
- object_class->destroy = esa_destroy;
- object_class->set_arg = esa_set_arg;
- object_class->get_arg = esa_get_arg;
+ parent_class = g_type_class_ref (PARENT_TYPE);
sorter_class->model_to_sorted = esa_model_to_sorted ;
sorter_class->sorted_to_model = esa_sorted_to_model ;
diff --git a/e-util/e-sorter-array.h b/e-util/e-sorter-array.h
index 803b67052a..227e437443 100644
--- a/e-util/e-sorter-array.h
+++ b/e-util/e-sorter-array.h
@@ -24,17 +24,17 @@
#ifndef _E_SORTER_ARRAY_H_
#define _E_SORTER_ARRAY_H_
-#include <gtk/gtkobject.h>
-#include <gal/util/e-sorter.h>
#include <glib.h>
+#include <glib-object.h>
+#include <gal/util/e-sorter.h>
G_BEGIN_DECLS
#define E_SORTER_ARRAY_TYPE (e_sorter_array_get_type ())
-#define E_SORTER_ARRAY(o) (GTK_CHECK_CAST ((o), E_SORTER_ARRAY_TYPE, ESorterArray))
-#define E_SORTER_ARRAY_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_SORTER_ARRAY_TYPE, ESorterArrayClass))
-#define E_IS_SORTER_ARRAY(o) (GTK_CHECK_TYPE ((o), E_SORTER_ARRAY_TYPE))
-#define E_IS_SORTER_ARRAY_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_SORTER_ARRAY_TYPE))
+#define E_SORTER_ARRAY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_SORTER_ARRAY_TYPE, ESorterArray))
+#define E_SORTER_ARRAY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_SORTER_ARRAY_TYPE, ESorterArrayClass))
+#define E_IS_SORTER_ARRAY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_SORTER_ARRAY_TYPE))
+#define E_IS_SORTER_ARRAY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_SORTER_ARRAY_TYPE))
#ifndef _E_COMPARE_ROWS_FUNC_H_
#define _E_COMPARE_ROWS_FUNC_H_
@@ -60,7 +60,7 @@ typedef struct {
ESorterClass parent_class;
} ESorterArrayClass;
-GtkType e_sorter_array_get_type (void);
+GType e_sorter_array_get_type (void);
ESorterArray *e_sorter_array_construct (ESorterArray *sorter,
ECompareRowsFunc compare,
gpointer closure);
diff --git a/e-util/e-sorter.c b/e-util/e-sorter.c
index 2040241abe..adee6d0d98 100644
--- a/e-util/e-sorter.c
+++ b/e-util/e-sorter.c
@@ -23,18 +23,15 @@
#include <config.h>
#include <stdlib.h>
-#include <gtk/gtksignal.h>
#include <string.h>
#include "gal/util/e-util.h"
#include "e-sorter.h"
#define d(x)
-#define PARENT_TYPE gtk_object_get_type()
+#define PARENT_TYPE G_TYPE_OBJECT
-static GtkObjectClass *parent_class;
-
-#define ES_CLASS(es) ((ESorterClass *)((GTypeInstance *)(es))->g_class)
+static GObjectClass *parent_class;
static gint es_model_to_sorted (ESorter *es, int row);
static gint es_sorted_to_model (ESorter *es, int row);
@@ -45,7 +42,7 @@ static gboolean es_needs_sorting(ESorter *es);
static void
es_class_init (ESorterClass *klass)
{
- parent_class = gtk_type_class (PARENT_TYPE);
+ parent_class = g_type_class_ref (PARENT_TYPE);
klass->model_to_sorted = es_model_to_sorted;
klass->sorted_to_model = es_sorted_to_model;
@@ -64,7 +61,7 @@ E_MAKE_TYPE(e_sorter, "ESorter", ESorter, es_class_init, es_init, PARENT_TYPE)
ESorter *
e_sorter_new (void)
{
- ESorter *es = gtk_type_new (E_SORTER_TYPE);
+ ESorter *es = g_object_new (E_SORTER_TYPE, NULL);
return es;
}
@@ -106,8 +103,8 @@ e_sorter_model_to_sorted (ESorter *es, int row)
g_return_val_if_fail(es != NULL, -1);
g_return_val_if_fail(row >= 0, -1);
- if (ES_CLASS(es)->model_to_sorted)
- return ES_CLASS(es)->model_to_sorted (es, row);
+ if (E_SORTER_GET_CLASS(es)->model_to_sorted)
+ return E_SORTER_GET_CLASS(es)->model_to_sorted (es, row);
else
return -1;
}
@@ -118,8 +115,8 @@ e_sorter_sorted_to_model (ESorter *es, int row)
g_return_val_if_fail(es != NULL, -1);
g_return_val_if_fail(row >= 0, -1);
- if (ES_CLASS(es)->sorted_to_model)
- return ES_CLASS(es)->sorted_to_model (es, row);
+ if (E_SORTER_GET_CLASS(es)->sorted_to_model)
+ return E_SORTER_GET_CLASS(es)->sorted_to_model (es, row);
else
return -1;
}
@@ -130,8 +127,8 @@ e_sorter_get_model_to_sorted_array (ESorter *es, int **array, int *count)
{
g_return_if_fail(es != NULL);
- if (ES_CLASS(es)->get_model_to_sorted_array)
- ES_CLASS(es)->get_model_to_sorted_array (es, array, count);
+ if (E_SORTER_GET_CLASS(es)->get_model_to_sorted_array)
+ E_SORTER_GET_CLASS(es)->get_model_to_sorted_array (es, array, count);
}
void
@@ -139,8 +136,8 @@ e_sorter_get_sorted_to_model_array (ESorter *es, int **array, int *count)
{
g_return_if_fail(es != NULL);
- if (ES_CLASS(es)->get_sorted_to_model_array)
- ES_CLASS(es)->get_sorted_to_model_array (es, array, count);
+ if (E_SORTER_GET_CLASS(es)->get_sorted_to_model_array)
+ E_SORTER_GET_CLASS(es)->get_sorted_to_model_array (es, array, count);
}
@@ -149,8 +146,8 @@ e_sorter_needs_sorting(ESorter *es)
{
g_return_val_if_fail (es != NULL, FALSE);
- if (ES_CLASS(es)->needs_sorting)
- return ES_CLASS(es)->needs_sorting (es);
+ if (E_SORTER_GET_CLASS(es)->needs_sorting)
+ return E_SORTER_GET_CLASS(es)->needs_sorting (es);
else
return FALSE;
}
diff --git a/e-util/e-sorter.h b/e-util/e-sorter.h
index 5a89fa4c59..a70c2bd2d7 100644
--- a/e-util/e-sorter.h
+++ b/e-util/e-sorter.h
@@ -24,24 +24,25 @@
#ifndef _E_SORTER_H_
#define _E_SORTER_H_
-#include <gtk/gtkobject.h>
+#include <glib-object.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define E_SORTER_TYPE (e_sorter_get_type ())
-#define E_SORTER(o) (GTK_CHECK_CAST ((o), E_SORTER_TYPE, ESorter))
-#define E_SORTER_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_SORTER_TYPE, ESorterClass))
-#define E_IS_SORTER(o) (GTK_CHECK_TYPE ((o), E_SORTER_TYPE))
-#define E_IS_SORTER_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_SORTER_TYPE))
+#define E_SORTER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_SORTER_TYPE, ESorter))
+#define E_SORTER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_SORTER_TYPE, ESorterClass))
+#define E_IS_SORTER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_SORTER_TYPE))
+#define E_IS_SORTER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_SORTER_TYPE))
+#define E_SORTER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), E_SORTER_TYPE, ESorterClass))
typedef struct {
- GtkObject base;
+ GObject base;
} ESorter;
typedef struct {
- GtkObjectClass parent_class;
+ GObjectClass parent_class;
gint (*model_to_sorted) (ESorter *sorter,
int row);
gint (*sorted_to_model) (ESorter *sorter,
@@ -57,7 +58,7 @@ typedef struct {
gboolean (*needs_sorting) (ESorter *sorter);
} ESorterClass;
-GtkType e_sorter_get_type (void);
+GType e_sorter_get_type (void);
ESorter *e_sorter_new (void);
gint e_sorter_model_to_sorted (ESorter *sorter,
diff --git a/widgets/misc/e-selection-model-array.c b/widgets/misc/e-selection-model-array.c
index 42d7da90e4..473f005dd4 100644
--- a/widgets/misc/e-selection-model-array.c
+++ b/widgets/misc/e-selection-model-array.c
@@ -225,7 +225,7 @@ esma_clear(ESelectionModel *selection)
{
ESelectionModelArray *esma = E_SELECTION_MODEL_ARRAY(selection);
if (esma->eba) {
- gtk_object_unref(GTK_OBJECT(esma->eba));
+ g_object_unref(esma->eba);
esma->eba = NULL;
}
esma->cursor_row = -1;
diff --git a/widgets/misc/e-selection-model-simple.c b/widgets/misc/e-selection-model-simple.c
index da232d9f8c..51a0d86623 100644
--- a/widgets/misc/e-selection-model-simple.c
+++ b/widgets/misc/e-selection-model-simple.c
@@ -73,7 +73,7 @@ e_selection_model_simple_set_row_count (ESelectionModelSimple *esms,
if (esms->row_count != row_count) {
ESelectionModelArray *esma = E_SELECTION_MODEL_ARRAY(esms);
if (esma->eba)
- gtk_object_unref(GTK_OBJECT(esma->eba));
+ g_object_unref(esma->eba);
esma->eba = NULL;
esma->selected_row = -1;
esma->selected_range_end = -1;