aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-12-28 13:25:30 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-01-03 12:22:36 +0800
commit3cfd5d640908b6441769341c764de70006262c6e (patch)
tree2408c4dd513de0576a0daae9833aff7f740a52e7 /widgets
parent7a979aeb79ee095e2d002c240d17888618279e08 (diff)
downloadgsoc2013-evolution-3cfd5d640908b6441769341c764de70006262c6e.tar
gsoc2013-evolution-3cfd5d640908b6441769341c764de70006262c6e.tar.gz
gsoc2013-evolution-3cfd5d640908b6441769341c764de70006262c6e.tar.bz2
gsoc2013-evolution-3cfd5d640908b6441769341c764de70006262c6e.tar.lz
gsoc2013-evolution-3cfd5d640908b6441769341c764de70006262c6e.tar.xz
gsoc2013-evolution-3cfd5d640908b6441769341c764de70006262c6e.tar.zst
gsoc2013-evolution-3cfd5d640908b6441769341c764de70006262c6e.zip
ETableExtras cleanup.
Diffstat (limited to 'widgets')
-rw-r--r--widgets/table/e-table-extras.c136
-rw-r--r--widgets/table/e-table-extras.h94
2 files changed, 144 insertions, 86 deletions
diff --git a/widgets/table/e-table-extras.c b/widgets/table/e-table-extras.c
index 78513792f8..9d9b7ee65c 100644
--- a/widgets/table/e-table-extras.c
+++ b/widgets/table/e-table-extras.c
@@ -40,6 +40,17 @@
#include "e-cell-tree.h"
#include "e-table-extras.h"
+#define E_TABLE_EXTRAS_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_TABLE_EXTRAS, ETableExtrasPrivate))
+
+struct _ETableExtrasPrivate {
+ GHashTable *cells;
+ GHashTable *compares;
+ GHashTable *pixbufs;
+ GHashTable *searches;
+};
+
/* workaround for avoiding API breakage */
#define ete_get_type e_table_extras_get_type
G_DEFINE_TYPE (ETableExtras, ete, G_TYPE_OBJECT)
@@ -73,28 +84,32 @@ ete_finalize (GObject *object)
}
static void
-ete_class_init (ETableExtrasClass *klass)
+ete_class_init (ETableExtrasClass *class)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class;
+ g_type_class_add_private (class, sizeof (ETableExtrasPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
object_class->finalize = ete_finalize;
}
static gint
-e_strint_compare(gconstpointer data1, gconstpointer data2)
+e_strint_compare (gconstpointer data1,
+ gconstpointer data2)
{
gint int1 = atoi(data1);
gint int2 = atoi(data2);
- return e_int_compare(GINT_TO_POINTER(int1), GINT_TO_POINTER(int2));
+ return e_int_compare (GINT_TO_POINTER (int1), GINT_TO_POINTER (int2));
}
/* UTF-8 strncasecmp - not optimized */
static gint
g_utf8_strncasecmp (const gchar *s1,
- const gchar *s2,
- guint n)
+ const gchar *s2,
+ guint n)
{
gunichar c1, c2;
@@ -124,7 +139,8 @@ g_utf8_strncasecmp (const gchar *s1,
}
static gboolean
-e_string_search(gconstpointer haystack, const gchar *needle)
+e_string_search (gconstpointer haystack,
+ const gchar *needle)
{
gint length;
if (haystack == NULL)
@@ -147,22 +163,24 @@ safe_unref (gpointer object)
static void
ete_init (ETableExtras *extras)
{
- extras->cells = g_hash_table_new_full (
+ extras->priv = E_TABLE_EXTRAS_GET_PRIVATE (extras);
+
+ extras->priv->cells = g_hash_table_new_full (
g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
(GDestroyNotify) safe_unref);
- extras->compares = g_hash_table_new_full (
+ extras->priv->compares = g_hash_table_new_full (
g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
(GDestroyNotify) NULL);
- extras->searches = g_hash_table_new_full (
+ extras->priv->searches = g_hash_table_new_full (
g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
(GDestroyNotify) NULL);
- extras->pixbufs = g_hash_table_new_full (
+ extras->priv->pixbufs = g_hash_table_new_full (
g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
(GDestroyNotify) safe_unref);
@@ -187,71 +205,99 @@ ete_init (ETableExtras *extras)
ETableExtras *
e_table_extras_new (void)
{
- ETableExtras *ete = g_object_new (E_TABLE_EXTRAS_TYPE, NULL);
-
- return (ETableExtras *) ete;
+ return g_object_new (E_TYPE_TABLE_EXTRAS, NULL);
}
void
-e_table_extras_add_cell (ETableExtras *extras,
- const gchar *id,
- ECell *cell)
+e_table_extras_add_cell (ETableExtras *extras,
+ const gchar *id,
+ ECell *cell)
{
- if (cell)
+ g_return_if_fail (E_IS_TABLE_EXTRAS (extras));
+ g_return_if_fail (id != NULL);
+
+ if (cell != NULL)
g_object_ref_sink (cell);
- g_hash_table_insert (extras->cells, g_strdup(id), cell);
+
+ g_hash_table_insert (extras->priv->cells, g_strdup (id), cell);
}
ECell *
-e_table_extras_get_cell (ETableExtras *extras,
- const gchar *id)
+e_table_extras_get_cell (ETableExtras *extras,
+ const gchar *id)
{
- return g_hash_table_lookup(extras->cells, id);
+ g_return_val_if_fail (E_IS_TABLE_EXTRAS (extras), NULL);
+ g_return_val_if_fail (id != NULL, NULL);
+
+ return g_hash_table_lookup (extras->priv->cells, id);
}
void
-e_table_extras_add_compare (ETableExtras *extras,
- const gchar *id,
- GCompareFunc compare)
+e_table_extras_add_compare (ETableExtras *extras,
+ const gchar *id,
+ GCompareFunc compare)
{
- g_hash_table_insert(extras->compares, g_strdup(id), (gpointer) compare);
+ g_return_if_fail (E_IS_TABLE_EXTRAS (extras));
+ g_return_if_fail (id != NULL);
+
+ g_hash_table_insert (
+ extras->priv->compares,
+ g_strdup (id), (gpointer) compare);
}
GCompareFunc
-e_table_extras_get_compare (ETableExtras *extras,
- const gchar *id)
+e_table_extras_get_compare (ETableExtras *extras,
+ const gchar *id)
{
- return (GCompareFunc) g_hash_table_lookup(extras->compares, id);
+ g_return_val_if_fail (E_IS_TABLE_EXTRAS (extras), NULL);
+ g_return_val_if_fail (id != NULL, NULL);
+
+ return g_hash_table_lookup (extras->priv->compares, id);
}
void
-e_table_extras_add_search (ETableExtras *extras,
- const gchar *id,
- ETableSearchFunc search)
+e_table_extras_add_search (ETableExtras *extras,
+ const gchar *id,
+ ETableSearchFunc search)
{
- g_hash_table_insert(extras->searches, g_strdup(id), search);
+ g_return_if_fail (E_IS_TABLE_EXTRAS (extras));
+ g_return_if_fail (id != NULL);
+
+ g_hash_table_insert (
+ extras->priv->searches,
+ g_strdup (id), (gpointer) search);
}
ETableSearchFunc
-e_table_extras_get_search (ETableExtras *extras,
- const gchar *id)
+e_table_extras_get_search (ETableExtras *extras,
+ const gchar *id)
{
- return g_hash_table_lookup(extras->searches, id);
+ g_return_val_if_fail (E_IS_TABLE_EXTRAS (extras), NULL);
+ g_return_val_if_fail (id != NULL, NULL);
+
+ return g_hash_table_lookup (extras->priv->searches, id);
}
void
-e_table_extras_add_pixbuf (ETableExtras *extras,
- const gchar *id,
- GdkPixbuf *pixbuf)
+e_table_extras_add_pixbuf (ETableExtras *extras,
+ const gchar *id,
+ GdkPixbuf *pixbuf)
{
- if (pixbuf)
- g_object_ref(pixbuf);
- g_hash_table_insert (extras->pixbufs, g_strdup(id), pixbuf);
+ g_return_if_fail (E_IS_TABLE_EXTRAS (extras));
+ g_return_if_fail (id != NULL);
+
+ if (pixbuf != NULL)
+ g_object_ref (pixbuf);
+
+ g_hash_table_insert (extras->priv->pixbufs, g_strdup (id), pixbuf);
}
GdkPixbuf *
-e_table_extras_get_pixbuf (ETableExtras *extras,
- const gchar *id)
+e_table_extras_get_pixbuf (ETableExtras *extras,
+ const gchar *id)
{
- return g_hash_table_lookup(extras->pixbufs, id);
+ g_return_val_if_fail (E_IS_TABLE_EXTRAS (extras), NULL);
+ g_return_val_if_fail (id != NULL, NULL);
+
+ return g_hash_table_lookup (extras->priv->pixbufs, id);
}
diff --git a/widgets/table/e-table-extras.h b/widgets/table/e-table-extras.h
index 794cf4635e..b01af32b32 100644
--- a/widgets/table/e-table-extras.h
+++ b/widgets/table/e-table-extras.h
@@ -21,62 +21,74 @@
*
*/
-#ifndef _E_TABLE_EXTRAS_H_
-#define _E_TABLE_EXTRAS_H_
+#ifndef E_TABLE_EXTRAS_H
+#define E_TABLE_EXTRAS_H
-#include <glib-object.h>
#include <table/e-cell.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
+#define E_TYPE_TABLE_EXTRAS \
+ (e_table_extras_get_type ())
+#define E_TABLE_EXTRAS(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_TABLE_EXTRAS, ETableExtras))
+#define E_TABLE_EXTRAS_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_TABLE_EXTRAS, ETableExtrasClass))
+#define E_IS_TABLE_EXTRAS(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_TABLE_EXTRAS))
+#define E_IS_TABLE_EXTRAS_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_TABLE_EXTRAS))
+#define E_TABLE_EXTRAS_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_TABLE_EXTRAS, ETableExtrasClass))
+
G_BEGIN_DECLS
-#define E_TABLE_EXTRAS_TYPE (e_table_extras_get_type ())
-#define E_TABLE_EXTRAS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TABLE_EXTRAS_TYPE, ETableExtras))
-#define E_TABLE_EXTRAS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_TABLE_EXTRAS_TYPE, ETableExtrasClass))
-#define E_IS_TABLE_EXTRAS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TABLE_EXTRAS_TYPE))
-#define E_IS_TABLE_EXTRAS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_TABLE_EXTRAS_TYPE))
-#define E_TABLE_EXTRAS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), E_TABLE_EXTRAS_TYPE, ETableExtrasClass))
+typedef struct _ETableExtras ETableExtras;
+typedef struct _ETableExtrasClass ETableExtrasClass;
+typedef struct _ETableExtrasPrivate ETableExtrasPrivate;
-typedef struct {
- GObject base;
+struct _ETableExtras {
+ GObject parent;
+ ETableExtrasPrivate *priv;
GHashTable *cells;
GHashTable *compares;
GHashTable *pixbufs;
GHashTable *searches;
-} ETableExtras;
+};
-typedef struct {
+struct _ETableExtrasClass {
GObjectClass parent_class;
-} ETableExtrasClass;
-
-GType e_table_extras_get_type (void);
-ETableExtras *e_table_extras_new (void);
-
-void e_table_extras_add_cell (ETableExtras *extras,
- const gchar *id,
- ECell *cell);
-ECell *e_table_extras_get_cell (ETableExtras *extras,
- const gchar *id);
-
-void e_table_extras_add_compare (ETableExtras *extras,
- const gchar *id,
- GCompareFunc compare);
-GCompareFunc e_table_extras_get_compare (ETableExtras *extras,
- const gchar *id);
-
-void e_table_extras_add_search (ETableExtras *extras,
- const gchar *id,
- ETableSearchFunc search);
-ETableSearchFunc e_table_extras_get_search (ETableExtras *extras,
- const gchar *id);
+};
-void e_table_extras_add_pixbuf (ETableExtras *extras,
- const gchar *id,
- GdkPixbuf *pixbuf);
-GdkPixbuf *e_table_extras_get_pixbuf (ETableExtras *extras,
- const gchar *id);
+GType e_table_extras_get_type (void);
+ETableExtras * e_table_extras_new (void);
+void e_table_extras_add_cell (ETableExtras *extras,
+ const gchar *id,
+ ECell *cell);
+ECell * e_table_extras_get_cell (ETableExtras *extras,
+ const gchar *id);
+void e_table_extras_add_compare (ETableExtras *extras,
+ const gchar *id,
+ GCompareFunc compare);
+GCompareFunc e_table_extras_get_compare (ETableExtras *extras,
+ const gchar *id);
+void e_table_extras_add_search (ETableExtras *extras,
+ const gchar *id,
+ ETableSearchFunc search);
+ETableSearchFunc
+ e_table_extras_get_search (ETableExtras *extras,
+ const gchar *id);
+void e_table_extras_add_pixbuf (ETableExtras *extras,
+ const gchar *id,
+ GdkPixbuf *pixbuf);
+GdkPixbuf * e_table_extras_get_pixbuf (ETableExtras *extras,
+ const gchar *id);
G_END_DECLS
-#endif /* _E_TABLE_EXTRAS_H_ */
+#endif /* E_TABLE_EXTRAS_H */