1
0
Fork 0
Commit graph

56 commits

Author SHA1 Message Date
Emmanuele Bassi
12370bd4f8 docs: Move to markdown
We're removing docbook tags in favour of the markdown syntax.
2014-03-17 23:07:58 +00:00
Emmanuele Bassi
41bb03da2d Use the new macros for adding private data 2013-07-03 18:04:32 +01:00
Emmanuele Bassi
b3b1994c13 Use G_VALUE_INIT instead of { 0, }
The macro avoids warnings from anal-retentive compilers.
2012-03-17 16:40:55 +00:00
Emmanuele Bassi
910b09d70a Mark internal symbol as private
A bunch of private symbols have escaped into the SO; let's rectify this
situation by using the '_' private prefix, or making them static as they
should have been.
2012-02-09 18:40:03 +00:00
Emmanuele Bassi
ce9564e558 model: Drop GValueArray usage
We can use a plain C array of GValues when deserializing a ClutterModel
implementation from a ClutterScript description.
2012-02-06 15:34:13 +00:00
Emmanuele Bassi
193b345786 Remove some compiler warnings
Some issues found using clang as the compiler.
2011-10-11 23:42:23 +01:00
Emmanuele Bassi
bcd37e2e3d script: Hide private symbols
A bunch of private functions we use when parsing got exposed accidentaly
to the list of public symbols by virtue of not having the leading '_'
that we use to filter them out of the shared object — all the while the
header that declares them is a private, non installed one.

Let's rectify this situation with a bit of minor surgery on the code.
2011-09-07 16:14:10 +01:00
Emmanuele Bassi
7139ada809 model: Remove an unused variable 2011-07-29 13:17:11 +01:00
Emmanuele Bassi
473f3817d4 model: Clean up ModelIter vfunc wrappers
All ClutterModelIter virtual functions have a default implementation,
and G_TYPE_INSTANCE_GET_CLASS cannot return NULL unless in case of a
catastrophic event in the type system - which will most likely blow up
any application code way before you could call a ModelIter method.

Thus, the idiom:

  klass = CLUTTER_MODEL_ITER_GET_CLASS (instance);
  if (klass && klass->vfunc)
    klass->vfunc (instance);

is utterly useless complication, and it can be perfectly replaced by:

  CLUTTER_MODEL_ITER_GET_CLASS (instance)->vfunc (instance);

without any loss of safety.
2011-07-29 11:29:51 +01:00
Emmanuele Bassi
e470fd7d82 model: Make sure to emit ::row-changed
Currently, only clutter_model_iter_set_valist() is in charge of emitting
the ClutterModel::row-changed signal. Both the set() and the
set_valist() functions can be called with multiple columns, so we
coalesce the signal emission at the end of the set_valist(), to have a
single ::row-changed emission per change.

The clutter_model_iter_set_value() function is just a thin wrapper
around the set_value() virtual function, but since it's called
internally we cannot add the signal emission there as well, as we'd
break the signal coalescing.

For this reason, we need some code refactoring inside the various set()
variants of ClutterModelIter:

  - we only use the internal va_arg variant for both the set() and
    set_valist() public functions, to avoid multiple type checks;
  - the internal set_valist() calls an internal set_value() method
    which calls the virtual function from the iterator vtable;
  - a new internal emit_row_changed() method is needed to retrieve
    the ClutterModel from the iterator, and emit the signal;

Now, all three variants of the value setter will call an internal
ClutterModelIter::set_value() wrapper, and emit the ::row-changed
signal.

To check that the intended behaviour has been implemented, and it's not
going to be broken, the test suite has grown a new unit which populates
a model and changes a random row.
2011-07-28 15:00:18 +01:00
Emmanuele Bassi
78049c38bf docs: Fixes for building the API reference 2011-07-26 13:44:12 +01:00
Emmanuele Bassi
2b81d90dd7 Eliminate G_CONST_RETURN
The G_CONST_RETURN define in GLib is, and has always been, a bit fuzzy.

We always used it to conform to the platform, at least for public-facing
API.

At first I assumed it has something to do with brain-damaged compilers
or with weird platforms where const was not really supported; sadly,
it's something much, much worse: it's a define that can be toggled at
compile-time to remove const from the signature of public API. This is a
truly terrifying feature that I assume was added in the past century,
and whose inception clearly had something to do with massive doses of
absynthe and opium — because any other explanation would make the
existence of such a feature even worse than assuming drugs had anything
to do with it.

Anyway, and pleasing the gods, this dubious feature is being
removed/deprecated in GLib; see bug:

  https://bugzilla.gnome.org/show_bug.cgi?id=644611

Before deprecation, though, we should just remove its usage from the
whole API. We should especially remove its usage from Cally's internals,
since there it never made sense in the first place.
2011-06-07 16:06:24 +01:00
Bastian Winkler
6bffd407fd model: Add support to define rows in ClutterScript
This adds a custom "rows" property, that allows to define the rows of a
ClutterModel. A single row can either an array of all columns or an
object with column-name : column-value pairs.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2528
2011-01-21 20:44:17 +00:00
Bastian Winkler
8e1c1909f8 model: Change the column argument type to gint for clutter_model_set_sort
Like in clutter_model_set_sorting_column this function should take a
gint column, otherwise GObject-Introspection won't allow to pass a NULL
sorting function.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2527
2011-01-21 20:42:52 +00:00
Bastian Winkler
8a6986089b model: Fix some GObject-Introspection annotations
http://bugzilla.clutter-project.org/show_bug.cgi?id=2526
2011-01-21 20:40:51 +00:00
Tomeu Vizoso
3625adb9d8 ClutterListModel: Implement get_n_rows for improved performance
The default implementation in ClutterModel iterates through all
the elements.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2511
2011-01-10 21:22:22 +00:00
Emmanuele Bassi
8a5686d835 Further annotation fixes 2010-09-08 16:41:47 +01:00
Emmanuele Bassi
b2c905ff50 Hide the marshallers
The marshallers we use for the signals are declared in a private header,
and it stands to reason that they should also be hidden in the shared
object by using the common '_' prefix. We are also using some direct
g_cclosure_marshal_* symbol from GLib, instead of consistently use the
clutter_marshal_* symbol.
2010-06-11 16:09:36 +01:00
Emmanuele Bassi
d735ac4807 model: Let get_n_columns() return a sane value
If you call get_n_columns() during the instance initialization phase but
before set_name()/set_types() have been called, you'll get a (guint) -1.
This is less than ideal.

If columns haven't been initialized we should just return 0, which was
the intent of the API since the beginning.

Based on a patch by: Bastian Winkler <buz@netbuz.org>

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-03-17 17:14:08 +00:00
Emmanuele Bassi
0a6497a3b6 model: Add a comment on the n_columns field type
To avoid another bug report like:

  http://bugzilla.openedhand.com/show_bug.cgi?id=2017

with a patch that gets applied without a proper review, resulting in a
bug like:

  http://bugzilla.openedhand.com/show_bug.cgi?id=2032

I should probably add a comment on why on earth we're using an integer
as the n_columns member of the ClutterModelPrivate structure, and why it
is important that it is initialized as -1.
2010-03-16 18:57:28 +00:00
Emmanuele Bassi
de4abfac95 Revert "model: Use guint for the n_columns field"
The int storage, and the initial value of -1, is used as a guard when
subclassing ClutterListModel to allow the sub-class to call
clutter_model_set_names() and clutter_model_set_types().

This reverts commit c274118a8f.
2010-03-16 18:53:24 +00:00
Bastian Winkler
c274118a8f model: Use guint for the n_columns field
clutter_model_get_n_columns is supposed to return a guint, so the
n_columns field needs to be a guint with the initial value set to 0.

http://bugzilla.openedhand.com/show_bug.cgi?id=2017

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-03-15 16:22:20 +00:00
Emmanuele Bassi
1d9ddad9a3 docs: Fix syntax error in Model's documentation
A missing opening quote sign is breaking gtk-doc for ClutterModel.
2010-03-01 17:45:00 +00:00
Emmanuele Bassi
79acb088e7 Remove mentions of the FSF address
Since using addresses that might change is something that finally
the FSF acknowledge as a plausible scenario (after changing address
twice), the license blurb in the source files should use the URI
for getting the license in case the library did not come with it.

Not that URIs cannot possibly change, but at least it's easier to
set up a redirection at the same place.

As a side note: this commit closes the oldes bug in Clutter's bug
report tool.

http://bugzilla.openedhand.com/show_bug.cgi?id=521
2010-03-01 12:56:10 +00:00
Emmanuele Bassi
67d9d92814 docs: Document the "columns" syntax for ClutterModel
Like we do for other classes implementing custom properties, we should
document the syntax of the "columns" scriptable property of ClutterModel.
2010-02-25 23:23:53 +00:00
Bastian Winkler
96c31bbf0e model: Implement ClutterScriptable interface
Allow a ClutterModel to be constructed through the ClutterScript API.
Currently this allows a model to be generated like like this:

{
  "id" : "test-model",
  "type" : "ClutterListModel",
  "columns" : [
    [ "text-column", "gchararray" ],
    [ "int-column", "gint" ],
    [ "actor-column", "ClutterRectangle" ]
  ]
}

where 'columns' is an array containing arrays of column-name,
column-type pairs.

http://bugzilla.openedhand.com/show_bug.cgi?id=2007
2010-02-25 23:09:11 +00:00
Emmanuele Bassi
8ba65cfd4a analysis: ClutterModel
Remove unused variables.
2010-02-12 14:50:11 +00:00
Damien Lespiau
6e3afa4ebe [docs] Clutter's model implementation is called ClutterListModel
It was renamed from ClutterModelDefault to ClutterListModel a while
back. Update the reference to this class in ClutterModel documentation.
2009-09-10 13:28:54 +01:00
Emmanuele Bassi
a5e081dc9c [model] Do not attempt to free empty column names
The column names are optional - ClutterModel will use the GType name
if there is no user-specified column name. Hence, the ::finalize vfunc
should not try to free an empty column names vector.

Fixes bug:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1790
2009-09-02 15:30:45 +01:00
Rob Bradford
41bb885486 [model] Add a private row mutator to ClutterModelIter
When calling clutter_model_iter_next () / clutter_model_iter_prev () we need
to update the row for the iterator. In order to improve the peformance of
iterating this change adds a private row mutator and switches ClutterListModel
to use it.
2009-05-05 20:18:28 +01:00
Emmanuele Bassi
01d172293c [model] Rework Model behaviour with a filter
Currently ClutterModel::get_iter_at_row() ignores whether we have
a filter in place. This also extends to the get_n_rows() method.

The more consistent, more intuitive and surely more correct way to
handle a Model with a filter in place is to take into account the
presence of the filter itself -- that is:

  - get_n_rows() should take into account the filter and return the
    number of *filtered* rows

  - get_iter_at_row() should also take the filter into account and
    get the first non-filtered row

These two changes make the ClutterModel with a filter function
behave like a subset of the original Model without a filter in
place.

For instance, given a model with three rows:

  - [row 0]     <does not match filter>
  - [row 1]     <matches filter>
  - [row 2]     <matches filter>
  - [row 3]     <does not match filter>

The get_n_rows() method will return "2", since only two rows will
match the filter; the get_first_iter() method will ask for the
zero-eth row, which will return an iterator pointing to the contents
of row 1 (but the :row property of the iterator will be set to 0);
the get_last_iter() method will ask for the last row, which will
return an iterator pointing to the contents of row 2 (but the :row
property of the iterator will be set to 1).

This changes will hopefully make the Model API more consistent
in its usage whether there is a filter in place or not.
2009-04-29 15:26:05 +01:00
Emmanuele Bassi
44fefa2afe [model] Add :filter-set
Currently, there is no way for implementations of the ClutterModel
abstract class to know whether there is a filter in place. Since
subclasses might implement some optimization in case there is no
filter present, we need a simple (and public) API to ask the model
itself.
2009-04-29 15:14:40 +01:00
Emmanuele Bassi
ccca24ab76 Remove usage of the grave accent as quotation mark
See:

  http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html

This should make Thomas happy.
2009-03-17 14:13:31 +00:00
Owen W. Taylor
c5afd98416 Add gobject-introspection annotations
Add annotations such as (transfer-none) (out) (element-type ClutterActor),
and so forth to the doc comments as appropriate.

The annotations added here are a combination of the annotations previously
in gir-repository for Clutter and annotations found in a review of all
return values with that were being parsed with a transfer of "full".

http://bugzilla.openedhand.com/show_bug.cgi?id=1452

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-02-20 12:09:07 +00:00
Neil Roberts
d6496254d6 * clutter/clutter-model.c (clutter_model_set_sorting_column): This
function is supposed to accept -1 to disable sorting. However it
	checks for whether the column is >= the number of columns, but
	clutter_model_get_n_columns() returns an unsigned int so the
	column number also gets promoted to unsigned for the
	comparison. Therefore -1 is always greater than the number of
	columns so it wouldn't let you set it.
2008-07-30 10:32:25 +00:00
Emmanuele Bassi
3ab2ff9846 2008-06-01 Emmanuele Bassi <ebassi@openedhand.com>
Merge from clutter-0-6:

	* clutter/clutter-model.c:
	(clutter_model_iter_set_internal_valist): Add an internal function
	wrapping ClutterModelIter::set_value that does not emit the
	::row-changed signal. Emitting this signal before the ::row-added
	one is wrong: a row cannot change before being inserted.

	(clutter_model_append), (clutter_model_prepend),
	(clutter_model_insert): Use the non-signal emitting variant of
	clutter_model_iter_set_valist().

	(clutter_model_iter_set_valist): Use the internal version and emit
	the ::row-changed signal at the end.
2008-06-01 19:57:42 +00:00
Emmanuele Bassi
7c05499865 2008-03-19 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-model.[ch]: Add a ::copy() virtual function
	for copying iterators.

	* clutter/clutter-list-model.c:
	(clutter_list_model_iter_copy),
	(clutter_list_model_iter_class_init): Implement the ::copy()
	function inside the ListModel iterator subclass.
2008-03-19 18:33:33 +00:00
Chris Lord
781661e9c3 * clutter/clutter-model.c: (clutter_model_set_sorting_column):
Don't disable sorting on column 0
2008-03-06 11:44:37 +00:00
Chris Lord
015eba286f * clutter/clutter-model.c: (clutter_model_resort):
Don't return when there's no sort function set, leave that to the
        model sub-class
2008-02-19 12:31:50 +00:00
Emmanuele Bassi
ccc4ad400b 2008-01-14 Emmanuele Bassi <ebassi@openedhand.com>
* clutter.symbols: Add clutter_model_insertv()

	* clutter/clutter-model.[ch] (clutter_model_insertv): Add a vector
	based insertion API, for language bindings
2008-01-14 10:13:35 +00:00
Emmanuele Bassi
e85d5eab84 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 14:18:53 +00:00
Emmanuele Bassi
6fdeda0e8f 2008-01-08 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-model.c:
	(clutter_model_appendv),
	(clutter_model_prependv): Fix the columns length pre-condition
2008-01-08 14:12:11 +00:00
Emmanuele Bassi
09263f94b0 2008-01-07 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-model.h:
	* clutter/clutter-model.c:
	(clutter_model_appendv),
	(clutter_model_prependv): Add vector based API for bindings.
	
	(clutter_model_get_column_name),
	(clutter_model_get_column_type),
	(clutter_model_set_sorting_column): Fix the check in the condition
	on the column index.

	* tests/test-scale.c (on_timeline_completed), (main): Fix spelling

	* clutter.symbols: Update public symbols
2008-01-07 17:17:43 +00:00
Emmanuele Bassi
9becd34a37 2007-12-28 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-model.c:
	(clutter_model_real_get_n_rows), (clutter_model_class_init),
	(clutter_model_get_n_rows): Provide a default implementation of
	the get_n_rows() method, so that subclasses do not strictly need
	to override it
2007-12-28 15:33:20 +00:00
Emmanuele Bassi
afaa4fe26f 2007-12-15 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-model-default.c:
	(clutter_model_default_iter_next),
	(clutter_model_default_iter_prev): Do not instantiate a new
	iterator, and update the passed one instead, as we say we do
	in the documentation. This avoid leaking tons of iterators.

	* clutter/clutter-model.[ch]: Update the documentation.

	* tests/test-model.c: Prettify some output.
2007-12-15 13:02:06 +00:00
Emmanuele Bassi
6193beb8be 2007-12-14 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-behaviour.c:
	(clutter_knot_get_type): Use the I_() macro.

	* clutter/clutter-model.[ch]: Make ClutterModel and ClutterModelIter
	abstract classes; also, provide more virtual functions inside the
	ClutterModel vtable, to allow subclasses and language bindings to
	override the entire ClutterModel using other/native data types
	to store the rows.
	
	* clutter/clutter-model-default.[ch]: ClutterModelDefault is a
	default implementation of ClutterModel and ClutterModelIter using
	GSequence.

	* clutter/Makefile.am:
	* clutter/clutter.h: Build glue for ClutterModelDefault.

	* tests/test-model.c: Update for constructor changes.

	* tests/test-shader.c: Fix a typo.
2007-12-14 17:25:55 +00:00
Emmanuele Bassi
6e61c0a999 2007-12-10 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-model.c:
	(clutter_model_get_sorting_column): Fix wrong type check.
2007-12-10 16:42:21 +00:00
Emmanuele Bassi
81e908f9fb 2007-12-10 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-model.[ch]: Allow unsorting the model (passing
	-1 as the sorting column)

	(clutter_model_iter_get_valist): Do not initialise twice che
	return value.
2007-12-10 16:22:05 +00:00
Emmanuele Bassi
002adaf305 2007-12-10 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-model.c (clutter_model_iter_get_value): Initialise
	the passed GValue like the other getters do.
2007-12-10 16:02:46 +00:00
Emmanuele Bassi
be8fdbe5c1 2007-12-10 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-model.h:
	* clutter/clutter-model.c:
	(clutter_model_append_value),
	(clutter_model_prepend_value),
	(clutter_model_insert_value): Add a _value() variant for the
	insertion methods, for use of the language bindings.

	(clutter_model_append), 
	(clutter_model_prepend),
	(clutter_model_insert): Do not return a boolean: insertion should
	never fail unless for a programming error, in which case we have
	plenty of warnings.
2007-12-10 15:08:53 +00:00