2008-01-09 Emmanuele Bassi <ebassi@openedhand.com>
authorEmmanuele Bassi <ebassi@openedhand.com>
Wed, 9 Jan 2008 14:18:53 +0000 (14:18 +0000)
committerEmmanuele Bassi <ebassi@openedhand.com>
Wed, 9 Jan 2008 14:18:53 +0000 (14:18 +0000)
* clutter/clutter-model-default.c:
(clutter_model_default_new),
(clutter_model_default_newv): Move the constructors in the
right file

* clutter/clutter-model-private.h: Add a private header for
the ClutterModel implementations

* clutter/clutter-model.c:
(clutter_model_check_type),
(clutter_model_set_n_columns),
(clutter_model_set_column_type): Mark as private to Clutter,
not static to ClutterModel

* clutter/Makefile.am: Add clutter-model-private.h

ChangeLog
clutter/Makefile.am
clutter/clutter-model-default.c
clutter/clutter-model-private.h [new file with mode: 0644]
clutter/clutter-model.c
doc/reference/Makefile.am

index 7478ab8..5c67388 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
 2008-01-09  Emmanuele Bassi  <ebassi@openedhand.com>
 
+       * clutter/clutter-model-default.c:
+       (clutter_model_default_new),
+       (clutter_model_default_newv): Move the constructors in the
+       right file
+
+       * clutter/clutter-model-private.h: Add a private header for
+       the ClutterModel implementations
+
+       * clutter/clutter-model.c:
+       (clutter_model_check_type),
+       (clutter_model_set_n_columns),
+       (clutter_model_set_column_type): Mark as private to Clutter,
+       not static to ClutterModel
+
+       * clutter/Makefile.am: Add clutter-model-private.h
+
+2008-01-09  Emmanuele Bassi  <ebassi@openedhand.com>
+
        * clutter/clutter-label.c:
        (clutter_label_ensure_layout): Fix the ClutterUnits to Pango
        scale conversion.
index 0314215..11c9f9c 100644 (file)
@@ -167,6 +167,7 @@ source_c = \
 source_h_priv = \
        clutter-debug.h                 \
        clutter-keysyms-table.h         \
+       clutter-model-private.h         \
        clutter-private.h               \
        clutter-script-private.h        \
        $(NULL)
index bbe7455..4185d2e 100644 (file)
@@ -50,6 +50,7 @@
 #include <glib-object.h>
 
 #include "clutter-model.h"
+#include "clutter-model-private.h"
 #include "clutter-model-default.h"
 #include "clutter-private.h"
 #include "clutter-debug.h"
@@ -658,3 +659,109 @@ clutter_model_default_init (ClutterModelDefault *model)
 {
   model->sequence = g_sequence_new (NULL);
 }
+
+/**
+ * clutter_model_default_new:
+ * @n_columns: number of columns in the model
+ * @Varargs: @n_columns number of #GType and string pairs
+ *
+ * Creates a new default model with @n_columns columns with the types 
+ * and names passed in.
+ *
+ * For example:
+ * 
+ * <informalexample><programlisting>
+ * model = clutter_model_default_new (3,
+ *                                    G_TYPE_INT,      "Score",
+ *                                    G_TYPE_STRING,   "Team",
+ *                                    GDK_TYPE_PIXBUF, "Logo");
+ * </programlisting></informalexample>
+ *
+ * will create a new #ClutterModel with three columns of type int,
+ * string and #GdkPixbuf respectively.
+ *
+ * Note that the name of the column can be set to %NULL, in which case
+ * the canonical name of the type held by the column will be used as
+ * the title.
+ *
+ * Return value: a new default #ClutterModel
+ *
+ * Since: 0.6
+ */
+ClutterModel *
+clutter_model_default_new (guint n_columns,
+                           ...)
+{
+  ClutterModel *model;
+  va_list args;
+  gint i;
+
+  g_return_val_if_fail (n_columns > 0, NULL);
+
+  model = g_object_new (CLUTTER_TYPE_MODEL_DEFAULT, NULL);
+  clutter_model_set_n_columns (model, n_columns, TRUE, TRUE);
+
+  va_start (args, n_columns);
+
+  for (i = 0; i < n_columns; i++)
+    { 
+      GType type = va_arg (args, GType);
+      const gchar *name = va_arg (args, gchar*);
+
+      if (!clutter_model_check_type (type))
+        {
+          g_warning ("%s: Invalid type %s\n", G_STRLOC, g_type_name (type));
+          g_object_unref (model);
+          return NULL;
+        }
+
+      clutter_model_set_column_type (model, i, type);
+      clutter_model_set_column_name (model, i, name);
+    }
+
+  va_end (args);
+
+  return model;
+}
+
+/**
+ * clutter_model_default_newv:
+ * @n_columns: number of columns in the model
+ * @types: an array of #GType types for the columns, from first to last
+ * @names: an array of names for the columns, from first to last
+ *
+ * Non-vararg version of clutter_model_default_new(). This function is
+ * useful for language bindings.
+ *
+ * Return value: a new default #ClutterModel
+ *
+ * Since: 0.6
+ */
+ClutterModel *
+clutter_model_default_newv (guint                n_columns,
+                            GType               *types,
+                            const gchar * const  names[])
+{
+  ClutterModel *model;
+  gint i;
+
+  g_return_val_if_fail (n_columns > 0, NULL);
+
+  model = g_object_new (CLUTTER_TYPE_MODEL_DEFAULT, NULL);
+  clutter_model_set_n_columns (model, n_columns, TRUE, TRUE);
+
+  for (i = 0; i < n_columns; i++)
+    {
+      if (!clutter_model_check_type (types[i]))
+        {
+          g_warning ("%s: Invalid type %s\n", G_STRLOC, g_type_name (types[i]));
+          g_object_unref (model);
+          return NULL;
+        }
+
+      clutter_model_set_column_type (model, i, types[i]);
+      clutter_model_set_column_name (model, i, names[i]);
+    }
+
+  return model;
+}
diff --git a/clutter/clutter-model-private.h b/clutter/clutter-model-private.h
new file mode 100644 (file)
index 0000000..051ca15
--- /dev/null
@@ -0,0 +1,24 @@
+#ifndef __CLUTTER_MODEL_PRIVATE_H__
+#define __CLUTTER_MODEL_PRIVATE_H__
+
+#include <glib.h>
+#include "clutter-model.h"
+
+G_BEGIN_DECLS
+
+void     clutter_model_set_n_columns   (ClutterModel *model,
+                                        gint          n_columns,
+                                        gboolean      set_types,
+                                        gboolean      set_names);
+gboolean clutter_model_check_type      (GType         gtype);
+
+void     clutter_model_set_column_type (ClutterModel *model,
+                                        gint          column,
+                                        GType         gtype);
+void     clutter_model_set_column_name (ClutterModel *model,
+                                        gint          column,
+                                        const gchar  *name);
+
+G_END_DECLS
+
+#endif /* __CLUTTER_MODEL_PRIVATE_H__ */
index 262fea8..2c327b4 100644 (file)
 #include <gobject/gvaluecollector.h>
 
 #include "clutter-model.h"
-#include "clutter-model-default.h"
+#include "clutter-model-private.h"
 
 #include "clutter-marshal.h"
 #include "clutter-private.h"
@@ -381,8 +381,8 @@ clutter_model_init (ClutterModel *self)
 /* XXX - is this whitelist really necessary? we accept every fundamental
  * type.
  */
-static gboolean
-clutter_model_check_type (type)
+gboolean
+clutter_model_check_type (GType gtype)
 {
   gint i = 0;
   static const GType type_list[] =
@@ -407,12 +407,12 @@ clutter_model_check_type (type)
       G_TYPE_INVALID
     };
 
-  if (! G_TYPE_IS_VALUE_TYPE (type))
+  if (! G_TYPE_IS_VALUE_TYPE (gtype))
     return FALSE;
 
   while (type_list[i] != G_TYPE_INVALID)
     {
-      if (g_type_is_a (type, type_list[i]))
+      if (g_type_is_a (gtype, type_list[i]))
        return TRUE;
       i++;
     }
@@ -519,7 +519,20 @@ clutter_model_filter_iter (ClutterModel     *model,
   return priv->filter_func (model, iter, priv->filter_data);
 }
 
-static void
+/*
+ * clutter_model_set_n_columns:
+ * @model: a #ClutterModel
+ * @n_columns: number of columns
+ * @set_types: set the columns type
+ * @set_names: set the columns name
+ *
+ * Sets the number of columns in @model to @n_columns. If @set_types
+ * or @set_names are %TRUE, initialises the columns type and name
+ * arrays as well.
+ *
+ * This function can only be called once.
+ */
+void
 clutter_model_set_n_columns (ClutterModel *model,
                              gint          n_columns,
                              gboolean      set_types,
@@ -540,20 +553,36 @@ clutter_model_set_n_columns (ClutterModel *model,
     priv->column_types = g_new0 (GType,  n_columns);
 
   if (set_names && !priv->column_names)
-    priv->column_names = g_new0 (gchar*, n_columns + 1);
+    priv->column_names = g_new0 (gchar*, n_columns);
 }
 
-static inline void
+/*
+ * clutter_model_set_column_type:
+ * @model: a #ClutterModel
+ * @column: column index
+ * @gtype: type of the column
+ *
+ * Sets the type of @column inside @model
+ */
+void
 clutter_model_set_column_type (ClutterModel *model,
                                gint          column,
-                               GType         type)
+                               GType         gtype)
 {
   ClutterModelPrivate *priv = model->priv;
 
-  priv->column_types[column] = type;
+  priv->column_types[column] = gtype;
 }
 
-static inline void
+/*
+ * clutter_model_set_column_name:
+ * @model: a #ClutterModel
+ * @column: column index
+ * @name: name of the column, or %NULL
+ *
+ * Sets the name of @column inside @model
+ */
+void
 clutter_model_set_column_name (ClutterModel *model,
                                gint          column,
                                const gchar  *name)
@@ -563,119 +592,6 @@ clutter_model_set_column_name (ClutterModel *model,
   priv->column_names[column] = g_strdup (name);
 }
 
-/* we implement the constructors of the default model here because
- * we need the private accessors to the column names and types
- * vectors inside ClutterModelPrivate, to avoid having them inside
- * a private header; the ClutterModelDefault ctors are declared inside
- * clutter-model-default.h
- */
-
-/**
- * clutter_model_default_new:
- * @n_columns: number of columns in the model
- * @Varargs: @n_columns number of #GType and string pairs
- *
- * Creates a new default model with @n_columns columns with the types 
- * and names passed in.
- *
- * For example:
- * 
- * <informalexample><programlisting>
- * model = clutter_model_default_new (3,
- *                                    G_TYPE_INT,      "Score",
- *                                    G_TYPE_STRING,   "Team",
- *                                    GDK_TYPE_PIXBUF, "Logo");
- * </programlisting></informalexample>
- *
- * will create a new #ClutterModel with three columns of type int,
- * string and #GdkPixbuf respectively.
- *
- * Note that the name of the column can be set to %NULL, in which case
- * the canonical name of the type held by the column will be used as
- * the title.
- *
- * Return value: a new default #ClutterModel
- *
- * Since: 0.6
- */
-ClutterModel *
-clutter_model_default_new (guint n_columns,
-                           ...)
-{
-  ClutterModel *model;
-  va_list args;
-  gint i;
-
-  g_return_val_if_fail (n_columns > 0, NULL);
-
-  model = g_object_new (CLUTTER_TYPE_MODEL_DEFAULT, NULL);
-  clutter_model_set_n_columns (model, n_columns, TRUE, TRUE);
-
-  va_start (args, n_columns);
-
-  for (i = 0; i < n_columns; i++)
-    { 
-      GType type = va_arg (args, GType);
-      const gchar *name = va_arg (args, gchar*);
-
-      if (!clutter_model_check_type (type))
-        {
-          g_warning ("%s: Invalid type %s\n", G_STRLOC, g_type_name (type));
-          g_object_unref (model);
-          return NULL;
-        }
-
-      clutter_model_set_column_type (model, i, type);
-      clutter_model_set_column_name (model, i, name);
-    }
-
-  va_end (args);
-
-  return model;
-}
-
-/**
- * clutter_model_default_newv:
- * @n_columns: number of columns in the model
- * @types: an array of #GType types for the columns, from first to last
- * @names: an array of names for the columns, from first to last
- *
- * Non-vararg version of clutter_model_default_new(). This function is
- * useful for language bindings.
- *
- * Return value: a new default #ClutterModel
- *
- * Since: 0.6
- */
-ClutterModel *
-clutter_model_default_newv (guint                n_columns,
-                            GType               *types,
-                            const gchar * const  names[])
-{
-  ClutterModel *model;
-  gint i;
-
-  g_return_val_if_fail (n_columns > 0, NULL);
-
-  model = g_object_new (CLUTTER_TYPE_MODEL_DEFAULT, NULL);
-  clutter_model_set_n_columns (model, n_columns, TRUE, TRUE);
-
-  for (i = 0; i < n_columns; i++)
-    {
-      if (!clutter_model_check_type (types[i]))
-        {
-          g_warning ("%s: Invalid type %s\n", G_STRLOC, g_type_name (types[i]));
-          g_object_unref (model);
-          return NULL;
-        }
-
-      clutter_model_set_column_type (model, i, types[i]);
-      clutter_model_set_column_name (model, i, names[i]);
-    }
-
-  return model;
-}
-
 /**
  * clutter_model_set_types:
  * @model: a #ClutterModel
index beda449..307a37e 100644 (file)
@@ -57,6 +57,7 @@ IGNORE_HFILES=\
        clutter-keysyms.h \
        clutter-keysyms-table.h \
        clutter-marshal.h \
+       clutter-model-private.h \
        clutter-private.h \
        clutter-script-private.h \
        stamp-clutter-enum-types.h \