profile/ivi/clutter.git
15 years ago[text] Use cached length when possible
Emmanuele Bassi [Tue, 6 Jan 2009 20:52:03 +0000 (20:52 +0000)]
[text] Use cached length when possible

Since clutter_text_set_text() measures the length of the text
each time, we should use the cached length instead of recomputing
the text length each time. This should save us some time when
dealing with long, multi-byte texts.

15 years ago[tests] Add unit for the ClutterText:password-char property
Emmanuele Bassi [Tue, 6 Jan 2009 15:30:31 +0000 (15:30 +0000)]
[tests] Add unit for the ClutterText:password-char property

Check that the contents of the Text actor are unaffected by the
:password-char property; that the accessors are correct; and finally
that the initial value for a newly constructed Text actor is valid.

15 years ago[docs] Update the Text section
Emmanuele Bassi [Tue, 6 Jan 2009 15:29:44 +0000 (15:29 +0000)]
[docs] Update the Text section

After the 979b6794 commit, the section for ClutterText needs
updating on the renamed and removed accessors.

15 years ago[text] Coalesce text visibility and password character
Emmanuele Bassi [Tue, 6 Jan 2009 15:22:31 +0000 (15:22 +0000)]
[text] Coalesce text visibility and password character

Using two properties to set a password entry can be construed as
both cumbersome and a gtk-ism. And rightly so on both counts.

The :text-visible property has also conflicting semantics with the
:cursor-visible one: while the latter hides the cursor, the former
changes the display of the contents of the Text actor. It is, thus,
not a matter of "visibility" but of "rendering".

Instead of setting the :text-visible and :invisible-char properties
to have a password text field, the Text actor should just have a
single :password-char property holding a Unicode character. If the
value of the :password-char is non-zero, the Text actor will use the
Unicode character to render the contents of the text entry.

This commit removes the following methods:

  clutter_text_set_text_visible()
  clutter_text_get_text_visible()
  clutter_text_set_invisible_char()
  clutter_text_get_invisible_char()

And the following properties:

  ClutterText:text-visible
  ClutterText:invisible-char

In favour of:

  clutter_text_set_password_char()
  clutter_text_get_password_char()

And:

  ClutterText:password-char

Thus making obvious what use the property and accessor methods are
for and simplifying the process of creating a simple password text
field to:

  text = clutter_text_new ();
  clutter_text_set_password_char (CLUTTER_TEXT (text), '*');

15 years agoAllow localizations to change the text direction
Emmanuele Bassi [Tue, 6 Jan 2009 12:35:19 +0000 (12:35 +0000)]
Allow localizations to change the text direction

The locale translators of Clutter are also the ones that should set
the default direction of the text in a Clutter user interface.

This commit adds a translatable string that defines the direction
of the text; the translation authors will change it to the correct
value and that will determine the default direction.

The default text direction can be overridden by using the
CLUTTER_TEXT_DIRECTION environment variable, or by using the
--clutter-text-direction command line switch. In any other case,
the locale will determine the text direction, as it should.

15 years agoClean up the update_pango_context() function
Emmanuele Bassi [Mon, 5 Jan 2009 16:48:46 +0000 (16:48 +0000)]
Clean up the update_pango_context() function

Logically split the various operations with whitespace so that
it's clear what does what.

15 years agoPass the PangoContext, not the MainContext
Emmanuele Bassi [Mon, 5 Jan 2009 16:45:59 +0000 (16:45 +0000)]
Pass the PangoContext, not the MainContext

When updating the PangoContext with the current options (font name,
options, resolution) pass the PangoContext instead of the Clutter
MainContext structure pointer.

15 years agoRevert the logic of the PangoContext check
Emmanuele Bassi [Mon, 5 Jan 2009 16:44:52 +0000 (16:44 +0000)]
Revert the logic of the PangoContext check

The branch that creates the global PangoContext should only run
if there is no global PangoContext already.

15 years agoRemove the binding pool entry from the list
Emmanuele Bassi [Mon, 5 Jan 2009 16:29:49 +0000 (16:29 +0000)]
Remove the binding pool entry from the list

When removing a binding entry from the binding pool we should not
only remove it from the hash table, but also from the linked list
we use to iterate over inside the block/unblock_action() pair.

15 years agoRemove BindingPool::list_actions()
Emmanuele Bassi [Mon, 5 Jan 2009 16:25:50 +0000 (16:25 +0000)]
Remove BindingPool::list_actions()

The clutter_binding_pool_list_actions() was not implemented. The
utility of a call listing all the action names is also debatable:
all the functions related to the key bindings take the key symbol
and modifiers -- except the block_action() and unblock_action()
pair.

15 years agoAdd ClutterActor::create_pango_context()
Emmanuele Bassi [Mon, 5 Jan 2009 15:29:10 +0000 (15:29 +0000)]
Add ClutterActor::create_pango_context()

Sometimes an actor needs to set specific font rendering options on
the PangoContext without changing settings for every other text-rendering
actor.

In order to do this, we need a new public method to create a Pango
context object -- preset with all the default settings -- owned by the
developer and not shared with the rest of Clutter.

This new method is called clutter_actor_create_pango_context(); while
it does not strictly depend on a ClutterActor, it is a good idea to
have it inside the ClutterActor API to map the current get_pango_context()
method and in case we start storing screen-specific data to the Actor
itself during the 1.x API cycle.

15 years agoRename the PangoContext creation functions
Emmanuele Bassi [Mon, 5 Jan 2009 15:27:33 +0000 (15:27 +0000)]
Rename the PangoContext creation functions

The _clutter_context_create_pango_context() should create a new
context; the function returning the PangoContext stored inside the
MainContext structure should be named _get_pango_context() instead.

15 years agoWhitespace fixes
Emmanuele Bassi [Mon, 5 Jan 2009 15:26:57 +0000 (15:26 +0000)]
Whitespace fixes

15 years ago[docs] Add the new API to the BindingPool section
Emmanuele Bassi [Mon, 5 Jan 2009 12:52:29 +0000 (12:52 +0000)]
[docs] Add the new API to the BindingPool section

Add the clutter_binding_pool_override_* family of functions to
the BindingPool section of the Clutter API reference.

15 years agoAllow overriding actions inside a BindingPool
Emmanuele Bassi [Mon, 5 Jan 2009 12:49:01 +0000 (12:49 +0000)]
Allow overriding actions inside a BindingPool

As of now, a key binding installed into a BindingPool is always there
and cannot be changed.

This is problematic for sub-classes trying to override the callback
or the action for a given key binding.

This commit adds the ability to override the closure for an existing
key binding inside a binding pool -- assumed the caller knows the
key symbol and modifiers used to install the key binding in the first
place.

15 years ago[text] Add select-all binding
Emmanuele Bassi [Mon, 5 Jan 2009 12:27:45 +0000 (12:27 +0000)]
[text] Add select-all binding

Bind Ctrl+A to the "select all" action.

15 years ago[docs] Add clutter_text_activate()
Emmanuele Bassi [Tue, 16 Dec 2008 17:44:13 +0000 (17:44 +0000)]
[docs] Add clutter_text_activate()

Add the last unused symbol to the ClutterText section.

15 years ago[docs] Remove ClutterLabel and ClutterEntry sections
Emmanuele Bassi [Tue, 16 Dec 2008 17:40:41 +0000 (17:40 +0000)]
[docs] Remove ClutterLabel and ClutterEntry sections

Remove the sections for the Label and the Entry actors, which
have been replaced by ClutterText.

15 years ago[docs] Document the newly added functions
Emmanuele Bassi [Tue, 23 Dec 2008 16:59:14 +0000 (16:59 +0000)]
[docs] Document the newly added functions

Document the ClutterBackend font name accessors, and the
clutter_actor_get_pango_context() getter method.

15 years agoAdd the ability to set the text direction
Emmanuele Bassi [Tue, 23 Dec 2008 16:40:26 +0000 (16:40 +0000)]
Add the ability to set the text direction

The direction of the text depends on the locale, and it is the
basic setting needed to enable internationalization of user
interfaces.

This commit allows setting the direction of the PangoContext instance
used by Clutter by using the CLUTTER_TEXT_DIRECTION environment
variable, or by passing the --clutter-text-direction command line
argument. Valid values are:

        ltr     - for left-to-right locales
        rtl     - for right-to-left locales

The default is LTR.

Ideally, this should be a value set by the localization teams on the
PO file, but this step requires some build system surgery to allow
the translation of the Clutter strings.

15 years agoReturn the default font name if no font name is set
Emmanuele Bassi [Tue, 23 Dec 2008 16:27:54 +0000 (16:27 +0000)]
Return the default font name if no font name is set

When calling clutter_backend_get_font_name(), if no default font
name has previously been set, we just set the default and return
a pointer to it - like we do for the font options.

15 years agoUse the default font from the Backend
Emmanuele Bassi [Tue, 23 Dec 2008 15:05:16 +0000 (15:05 +0000)]
Use the default font from the Backend

Instead of storing the default font name and size as a pre-processor
macro, use the newly added ClutterBackend API to retrieve the current
default font from the backend.

15 years agoStore the default font name inside ClutterBackend
Emmanuele Bassi [Tue, 23 Dec 2008 15:03:11 +0000 (15:03 +0000)]
Store the default font name inside ClutterBackend

The default backend stores some of the global defaults, like the
font options, text resolution, double click settings. It should also
store the default font name, to allow various text-based actors to
share the same settings.

When the font name changes, the ::font-changed signal is emitted,
to allow actors to pick up the change.

15 years agoUpdate the PangoContext on backend changes
Emmanuele Bassi [Tue, 23 Dec 2008 14:34:16 +0000 (14:34 +0000)]
Update the PangoContext on backend changes

When the ClutterBackend notifies of changes in the resolution or
font options, update the PangoContext stored by Clutter's main
context. This allows changing the backend font-related settings at
runtime.

15 years agoStore the PangoContext inside the main context
Emmanuele Bassi [Tue, 23 Dec 2008 14:27:41 +0000 (14:27 +0000)]
Store the PangoContext inside the main context

The PangoContext should be stored once, and inside the main
Clutter context. Each actor for which clutter_actor_get_pango_context()
has been called will hold a reference on the Pango context as well.

This makes it possible to update the text rendering for Clutter
by using only public API.

15 years agoDo not leak the PangoContext
Emmanuele Bassi [Tue, 23 Dec 2008 14:15:10 +0000 (14:15 +0000)]
Do not leak the PangoContext

We hold a reference on the PangoContext we use for an actor, so
we should remove the reference inside the dispose implementation.

15 years agoCreate the PangoContext of the Text actor
Emmanuele Bassi [Tue, 23 Dec 2008 14:11:27 +0000 (14:11 +0000)]
Create the PangoContext of the Text actor

Instead of creating a single, private PangoContext for every
Text actor, use the newly added clutter_actor_get_pango_context()
function.

15 years agoAdd a per-actor PangoContext
Emmanuele Bassi [Tue, 23 Dec 2008 14:06:55 +0000 (14:06 +0000)]
Add a per-actor PangoContext

Rendering text inside an actor is pretty much impossible without
using internal API to create the various pieces like the PangoContext
and the font map.

Each actor should have the ability to create a PangoContext, which
is the only object needed to generate layouts and change the various
Pango settings.

This commit adds a clutter_actor_get_pango_context() function that
creates a PangoContext inside the ClutterActor private data and allows
the creation of PangoLayouts when needed. If the actor already
has a PangoContext, the same instance is returned.

The PangoContext is created only on demand.

15 years agoAdd signals for Backend options
Emmanuele Bassi [Tue, 23 Dec 2008 13:55:51 +0000 (13:55 +0000)]
Add signals for Backend options

The ClutterBackend instance at the moment lacks the ability to
notify runtime changes of the font options and the resolution.

For this reason, this commit adds a ::resolution-changed and a
::font-changed signals to the Backend class.

The ::resolution-changed signal is emitted when set_resolution()
is called with a different DPI; ::font-changed is emitted when the
cairo_font_options_t* changes from the default.

15 years agoUse "" as the default value for the :text property
Emmanuele Bassi [Mon, 22 Dec 2008 13:29:10 +0000 (13:29 +0000)]
Use "" as the default value for the :text property

This follows the convention of GtkLabel/GtkEntry in GTK+ and the old
ClutterEntry.

It makes it easier to use strlen/strcmp etc on the output, since we can
assume that it is always a string.

This commit also updates the test unit for ClutterText to verify that
the clutter_text_get_text() function also returns an empty string when
a ClutterText actor has been created.

15 years agoDo not include cogl-pango.h multiple times
Emmanuele Bassi [Mon, 22 Dec 2008 13:24:52 +0000 (13:24 +0000)]
Do not include cogl-pango.h multiple times

The clutter-private.h header already includes cogl-pango.h with
the correct inclusion path, because the main context stores a
pointer to the font map.

There is no need for clutter-text.c to include cogl-pango.h
again since it already includes clutter-private.h.

15 years agoFix the selection behaviour around the 0th glyph
Emmanuele Bassi [Tue, 16 Dec 2008 15:53:57 +0000 (15:53 +0000)]
Fix the selection behaviour around the 0th glyph

After fixing the cursor position issues around the initial
glyph of the layout, the selection position needs fixing as
well.

The fix is similar: check if the position of the selection
is 0 and provide a fast path by setting the offset to 0.

15 years ago[tests] Make the layout cache fail at the right place
Emmanuele Bassi [Tue, 16 Dec 2008 13:58:54 +0000 (13:58 +0000)]
[tests] Make the layout cache fail at the right place

The GTest report output allows the developer to know where exactly
a test unit failure happened. The test-text-cache unit makes it
very hard to pinpoint the exact failure location because it relies
on the output to be printed out - which is not the case when the
tests are run as part of a make check.

This commit makes each sub-test inside the unit fail exactly where
the check function fails, which makes it easier to know which sub-test
did actually fail.

15 years ago[docs] Add clutter_text_set_selection to gtk-doc
Emmanuele Bassi [Tue, 16 Dec 2008 12:42:44 +0000 (12:42 +0000)]
[docs] Add clutter_text_set_selection to gtk-doc

Insert the newly added symbol to the ClutterText section in
the API reference.

15 years agoAdd ClutterText::set_selection()
Emmanuele Bassi [Tue, 16 Dec 2008 12:41:20 +0000 (12:41 +0000)]
Add ClutterText::set_selection()

The clutter_text_set_selection() function is a convenience
method for setting the cursor position and the selection
boundary to a given position in a single call, with sanity
checks for the positions.

15 years agoFix ClutterText::get_selection()
Emmanuele Bassi [Tue, 16 Dec 2008 12:25:45 +0000 (12:25 +0000)]
Fix ClutterText::get_selection()

The clutter_text_get_selection() function was not checking the
passed argument, and was still accessing the contents of the
Text actor using clutter_text_get_text().

This commit also adds the last few gtk-doc annotations missing
from ClutterText.

15 years ago[docs] Add more gtk-doc annotations
Emmanuele Bassi [Tue, 16 Dec 2008 12:25:15 +0000 (12:25 +0000)]
[docs] Add more gtk-doc annotations

Almost reaching full documentation.

15 years agoUse clutter_text_activate()
Emmanuele Bassi [Tue, 16 Dec 2008 12:05:10 +0000 (12:05 +0000)]
Use clutter_text_activate()

Instead of repeating the same code for the ::activate signal
emission, use the clutter_text_activate() function inside the
'activate' key binding handler.

15 years agoAdd ClutterText::activate()
Emmanuele Bassi [Tue, 16 Dec 2008 12:02:58 +0000 (12:02 +0000)]
Add ClutterText::activate()

The clutter_text_activate() function will emit the ::activate
signal if the :activatable property is set.

This function is useful for subclasses or application code, for
example if we are going to use ::captured-event or ::key-press-event
signal handlers to intercept the Return key and emit the ::activate
signal ourselves.

15 years ago[docs] Add more gtk-doc annotations for ClutterText
Emmanuele Bassi [Tue, 16 Dec 2008 11:52:57 +0000 (11:52 +0000)]
[docs] Add more gtk-doc annotations for ClutterText

Document the ClutterText constructors and the :editable, :selectable
and :activatable properties accessors.

15 years ago[docs] Annotate properties and fix signals docs
Emmanuele Bassi [Tue, 16 Dec 2008 11:30:47 +0000 (11:30 +0000)]
[docs] Annotate properties and fix signals docs

Annotate the properties without gtk-doc description, to get the
"Since" attribute.

Also, fix the ::cursor-event and ::activate signals documentation.

15 years ago[docs] Add :cursor-size property accessors
Emmanuele Bassi [Tue, 16 Dec 2008 10:43:05 +0000 (10:43 +0000)]
[docs] Add :cursor-size property accessors

Add the ClutterText:cursor-size property accessors to the
known gtk-doc symbols for the ClutterText section.

15 years agoAllow selecting with line-start and line-end bindings
Emmanuele Bassi [Tue, 16 Dec 2008 10:39:52 +0000 (10:39 +0000)]
Allow selecting with line-start and line-end bindings

Instead of installing the line-start and line-end key bindings
using the bare ClutterBindingPool API, we can use the internal
clutter_text_add_move_binding(), which automatically installs
the same key binding with the Shift modifier mask.

This allows selecting when pressing Shift+Home or Shift+End.

The selection behaviour is still incorrect around the zeroeth
position, with all the text after the first line being selected.

15 years agoAdd :cursor-size property to ClutterText
Emmanuele Bassi [Tue, 16 Dec 2008 10:37:45 +0000 (10:37 +0000)]
Add :cursor-size property to ClutterText

We can control the width of the cursor when painting by using
a simple property.

The magic -1 number passed to the setter method will reset the
cursor size to the default one of 2px.

The getter method will return an unsigned integer with the
current size.

15 years agoRemove unused page up/down key bindings
Emmanuele Bassi [Tue, 16 Dec 2008 10:19:56 +0000 (10:19 +0000)]
Remove unused page up/down key bindings

Moving the text by a "page" depends on being able to define a
"page size" in terms of lines of text. Since we don't define
something similar to an Adjustment that allows us to handle this
behaviour, we should defer the paging implementation to a higher
level class based on ClutterText.

15 years agoFix line start and line end key binding behaviour
Emmanuele Bassi [Tue, 16 Dec 2008 10:15:57 +0000 (10:15 +0000)]
Fix line start and line end key binding behaviour

Another fix for the key navigation behaviour around the zeroeth
glyph in the layout.

This commit adds a fast path for for the zero index when the
cursor position is set as zero, in case we are using the line-start
or line-end key bindings, similarly to what we did in commit
be64cbcdc22952ce2fa9f902e153e3bd9f4a08c9 for the move-up and
move-down bindings.

15 years agoFix up/down key navigation
Emmanuele Bassi [Mon, 15 Dec 2008 18:46:08 +0000 (18:46 +0000)]
Fix up/down key navigation

The behaviour of ClutterText around the initial position is still
a little bit erratic.

This commit fixes the key navigation with Up and Down arrows around
the first line of text.

15 years agoUse units in position_to_coords()
Emmanuele Bassi [Mon, 15 Dec 2008 18:24:42 +0000 (18:24 +0000)]
Use units in position_to_coords()

We loose precision with a direct conversion for PangoUnits to
pixels, so we should do the conversion as needed, inside the
callers of clutter_text_position_to_coords().

15 years agoConstify the cursor geometry in ::cursor-event
Emmanuele Bassi [Mon, 15 Dec 2008 18:23:25 +0000 (18:23 +0000)]
Constify the cursor geometry in ::cursor-event

We don't allow changing the cursor geometry inside the ::cursor-event
signal handlers; for starters, it would make binding the signal a
huge mess, and it would also potentially break the whole actor.

15 years ago[docs] Add annotations for ClutterText structures
Emmanuele Bassi [Mon, 15 Dec 2008 15:10:55 +0000 (15:10 +0000)]
[docs] Add annotations for ClutterText structures

ClutterText and ClutterTextClass were missing annotations for
gtk-doc to pick up.

15 years agoRemove ClutterLabel and ClutterEntry
Emmanuele Bassi [Mon, 15 Dec 2008 15:08:12 +0000 (15:08 +0000)]
Remove ClutterLabel and ClutterEntry

Both ClutterLabel and ClutterEntry have been deprecated by
ClutterText.

15 years ago[docs] Update the API reference
Emmanuele Bassi [Thu, 11 Dec 2008 15:01:28 +0000 (15:01 +0000)]
[docs] Update the API reference

Add all the unused API to the sections file; there are still
some undocumented bits, but clutter-unused.txt is empty for
the time being.

Also, add ClutterText to the main XML document and remove
ClutterLabel and ClutterEntry.

15 years agoFix documentation issues
Emmanuele Bassi [Thu, 11 Dec 2008 15:00:22 +0000 (15:00 +0000)]
Fix documentation issues

Provide a description for the ClutterText section, and fix some
misnamed arguments inside the header file.

15 years agoLazily create the PangoContext on Text::init
Emmanuele Bassi [Thu, 11 Dec 2008 14:57:46 +0000 (14:57 +0000)]
Lazily create the PangoContext on Text::init

If we create the PangoContext for ClutterText inside the class
initialization we might not have a Clutter main context yet.

Ideally, we should store the Pango context inside the main context
and create it on clutter_init(), but for now we can lazily create
the PangoContext when we initialize a ClutterText instance for the
first time.

15 years agoRemove ClutterEntry and ClutterLabel from the build
Emmanuele Bassi [Thu, 11 Dec 2008 13:49:39 +0000 (13:49 +0000)]
Remove ClutterEntry and ClutterLabel from the build

For the time being, just don't include them or compile them; the
files will be removed from the repository as soon as all the
documentation annotations have been ported over to ClutterText.

15 years agoUpdate the micro-bench tests to ClutterText
Emmanuele Bassi [Thu, 11 Dec 2008 13:48:45 +0000 (13:48 +0000)]
Update the micro-bench tests to ClutterText

Test the ClutterText rendering speed instead of ClutterLabel's.

15 years agoUpdate the interactive tests to ClutterText
Emmanuele Bassi [Thu, 11 Dec 2008 13:48:01 +0000 (13:48 +0000)]
Update the interactive tests to ClutterText

Instead of using ClutterLabel, use ClutterText to display some
text where needed.

15 years agoDo not compile the opacity and entry interactive tests
Emmanuele Bassi [Thu, 11 Dec 2008 13:45:22 +0000 (13:45 +0000)]
Do not compile the opacity and entry interactive tests

The test-opacity interactive test is superceded by the equivalent
units inside the conformance test suite.

The test-entry interactive test is superceded by the test-text one.

15 years agoUpdate ignore file
Emmanuele Bassi [Thu, 11 Dec 2008 13:39:35 +0000 (13:39 +0000)]
Update ignore file

Add the conformance test units for ClutterText.

15 years agoUpdate the paint opacity unit test
Emmanuele Bassi [Thu, 11 Dec 2008 12:26:47 +0000 (12:26 +0000)]
Update the paint opacity unit test

ClutterText behaviour with regards to the paint opacity has been
changed by commit 07e19fff5ffa9617413fa6c3715914513fec3793.

We need to update the test suite for the paint opacity to reflect
that change as well.

15 years agoAllow only synthetic events with keyval 0
Emmanuele Bassi [Thu, 11 Dec 2008 12:24:45 +0000 (12:24 +0000)]
Allow only synthetic events with keyval 0

We allow KeyEvents with a key symbol of '0' to fall through only
if they are marked as synthetic. Otherwise we discard them without
mercy.

Synthetic events are useful to test ClutterText behaviour; in fact,
we do use them inside the test suite exactly for that reason.

15 years agoDo not use contractions when not needed
Emmanuele Bassi [Thu, 11 Dec 2008 12:21:57 +0000 (12:21 +0000)]
Do not use contractions when not needed

I understand we are not Pascal developers, and we don't have to
use cute and cuddly names like "i_am_an_integer_counter", but
a ClutterButtonEvent should be stored inside an "event" variable.
Using "bev" instead? Mmmh, not so much.

15 years agoUse the paint opacity when painting a ClutterText
Emmanuele Bassi [Thu, 11 Dec 2008 12:18:26 +0000 (12:18 +0000)]
Use the paint opacity when painting a ClutterText

ClutterText should use the paint opacity for both text and
cursor.

ClutterLabel had the wrong behaviour, as it set the actor's
opacity using the text color's alpha channel, and ClutterEntry
completely disregarded the actor's opacity when painting the
cursor.

This commit harmonizes the ClutterText behaviour to always
use a composition of the actor's paint opacity and the text
and cursor alpha channel values, thus behaving more
consistently with the rest of Clutter.

15 years agoAdd documentation annotations
Emmanuele Bassi [Thu, 11 Dec 2008 12:17:11 +0000 (12:17 +0000)]
Add documentation annotations

ClutterText is heavily under-documented. This commit ports most of
the API documentation from ClutterLabel and ClutterEntry to
ClutterText.

15 years agoCode style fixes
Emmanuele Bassi [Thu, 11 Dec 2008 12:15:49 +0000 (12:15 +0000)]
Code style fixes

Fix the arguments alignment whenever not consistent with the
coding style rules.

15 years agoRemove unused types
Emmanuele Bassi [Thu, 11 Dec 2008 12:14:53 +0000 (12:14 +0000)]
Remove unused types

Since ClutterText now uses ClutterBindingPool there is no more
need for the internal key mapping types.

15 years agoRemove units for Entry and Label
Emmanuele Bassi [Thu, 11 Dec 2008 12:13:26 +0000 (12:13 +0000)]
Remove units for Entry and Label

ClutterText should supercede all unit tests for ClutterLabel and
ClutterEntry.

15 years agoTruncate selections on text insertion
Emmanuele Bassi [Thu, 11 Dec 2008 12:10:46 +0000 (12:10 +0000)]
Truncate selections on text insertion

When inserting text on a key press event we should also truncate
the selection.

We should not truncate the selection when inserting any Unicode
character, since changing the selection also changes the cursor
position - and one of the invariants we inherited from ClutterEntry
is that inserting characters programmatically does not change the
cursor position.

15 years agoChange the binding propagation when truncating a selection
Emmanuele Bassi [Thu, 11 Dec 2008 12:08:20 +0000 (12:08 +0000)]
Change the binding propagation when truncating a selection

If a selection has been truncated inside a key binding handler,
we should just return and let the usual key event handler continue.

This fixes the case where we deleted a selection using the Delete
or the Backspace keys.

15 years agoComment out the mapping API
Emmanuele Bassi [Thu, 11 Dec 2008 12:07:20 +0000 (12:07 +0000)]
Comment out the mapping API

The test-text interactive test for ClutterText should not use
the mapping API, since ClutterText does not have it anymore.

15 years agoUse ClutterBindPool inside ClutterText
Emmanuele Bassi [Thu, 11 Dec 2008 12:03:17 +0000 (12:03 +0000)]
Use ClutterBindPool inside ClutterText

ClutterText should use the newly added ClutterBindingPool API to
handle key events, instead of its homegrown code.

This commit removes the action/mapping code and defers the entire
key binding matching to a ClutterBindingPool created inside the
Text class initialization function.

15 years agoAdd Text::get_chars() implementation and tests
Emmanuele Bassi [Thu, 11 Dec 2008 11:59:50 +0000 (11:59 +0000)]
Add Text::get_chars() implementation and tests

The clutter_text_get_chars() function returns a section of the
contents of the Text actor, delimited by a start and an end position.

This commit adds the implementation for that function and a test
unit that guarantees the offset-to-bytes computations are correct.

15 years agoDo not namespace internal data structures
Emmanuele Bassi [Thu, 11 Dec 2008 11:57:46 +0000 (11:57 +0000)]
Do not namespace internal data structures

Since the internal data structures are not exported (duh!), we
can eschew the namespacing and save us some characters.

15 years agoAdd comments in the test suite
Emmanuele Bassi [Thu, 11 Dec 2008 11:56:44 +0000 (11:56 +0000)]
Add comments in the test suite

Comment why we need to enable the editability of the Text actor
inside the test suite.

This should clarify commit ea508ea528d61ae478d8bc4c88f54a89304f18e8

15 years agoMove internal data structures on top
Emmanuele Bassi [Thu, 11 Dec 2008 11:55:39 +0000 (11:55 +0000)]
Move internal data structures on top

Try to keep the declarations section of the source files clean and
possibly consistent.

15 years agoCoding style consistency
Emmanuele Bassi [Thu, 11 Dec 2008 11:54:32 +0000 (11:54 +0000)]
Coding style consistency

Channel mitch's spirit.

This is also how I get to have the highest commit count on Clutter's
repository.

15 years agoImplement Text:max-length
Emmanuele Bassi [Thu, 11 Dec 2008 11:54:07 +0000 (11:54 +0000)]
Implement Text:max-length

The :max-length property establishes the maximum available
length for the Text actor's contents, in characters.

15 years agoUpdate the ClutterText test unit
Emmanuele Bassi [Thu, 11 Dec 2008 11:51:28 +0000 (11:51 +0000)]
Update the ClutterText test unit

Whenever we are sending specially crafted KeyEvents to a ClutterText
we also need to set it editable, since the event handling code depends
on the editability setting.

15 years agoUse the stored contents length in ::delete_chars()
Emmanuele Bassi [Thu, 11 Dec 2008 11:50:02 +0000 (11:50 +0000)]
Use the stored contents length in ::delete_chars()

Instead of recomputing it, we can reuse the contents length we
compute and store inside clutter_text_set_text().

15 years agoImprove the safety checks inside the text setters
Emmanuele Bassi [Thu, 11 Dec 2008 11:49:45 +0000 (11:49 +0000)]
Improve the safety checks inside the text setters

We should check that the contents of the Text actor are
not NULL when computing the offsets in bytes.

15 years agoAdd :cursor-color-set property declaration
Emmanuele Bassi [Thu, 11 Dec 2008 11:49:14 +0000 (11:49 +0000)]
Add :cursor-color-set property declaration

The :cursor-color-set property is a read-only property that
reflects whether the ClutterText actor is going to use the
color set inside the :cursor-color property when painting
the cursor.

15 years agoGeneral whitespace fixes in ClutterText
Emmanuele Bassi [Thu, 11 Dec 2008 11:48:17 +0000 (11:48 +0000)]
General whitespace fixes in ClutterText

Let's keep whitespace fixes to their own commit to avoid
polluting git-blame.

15 years agoReplace offset_to_bytes() implementation
Emmanuele Bassi [Thu, 11 Dec 2008 11:47:06 +0000 (11:47 +0000)]
Replace offset_to_bytes() implementation

We should re-use the offset_to_bytes() implementation from ClutterEntry
as it guaranteed some behaviour and sanity checks that we want to keep
inside ClutterText.

15 years agoAdd a separate test unit for ClutterText
Emmanuele Bassi [Thu, 11 Dec 2008 11:45:37 +0000 (11:45 +0000)]
Add a separate test unit for ClutterText

Instead of changing the unit for ClutterEntry, we add a new
test unit specifically for ClutterText so that we can later tweak
it specifically for the behaviour changes needed to make ClutterText
work better.

15 years agoAdd text editing methods
Emmanuele Bassi [Thu, 11 Dec 2008 11:43:56 +0000 (11:43 +0000)]
Add text editing methods

Port the text editing methods from ClutterEntry, so that
ClutterText exposes the same API.

15 years agoAdd missing basic constructor
Emmanuele Bassi [Thu, 11 Dec 2008 11:43:37 +0000 (11:43 +0000)]
Add missing basic constructor

ClutterText should have an empty constructor, mostly for
bindings to use, that just proxies call to g_object_new()
without setting any property.

15 years agoInitialize the cursor position
Emmanuele Bassi [Thu, 11 Dec 2008 11:42:33 +0000 (11:42 +0000)]
Initialize the cursor position

By default, the cursor position is initialized to -1, meaning
"place the cursor always at the end of the text".

15 years agoAdd text-visibility accessors for ClutterText
Emmanuele Bassi [Thu, 11 Dec 2008 11:40:55 +0000 (11:40 +0000)]
Add text-visibility accessors for ClutterText

A ClutterText can be put in "password mode" by setting the
text as "invisible": every character inside the Text actor's
contents will be replaced when building the Pango layout with
a specific Unicode character.

The Unicode character is set to '*' by default, but the user
can be changed using the provided API.

15 years agoMove test-threads to ClutterText
Emmanuele Bassi [Thu, 11 Dec 2008 11:37:46 +0000 (11:37 +0000)]
Move test-threads to ClutterText

The test-threads interactive test is a good candidate for the
switch from ClutterLabel to ClutterText to verify that the
behaviour of the two classes is the same.

15 years agoCorrectly initialize the initial state of ClutterText
Emmanuele Bassi [Thu, 11 Dec 2008 11:35:52 +0000 (11:35 +0000)]
Correctly initialize the initial state of ClutterText

Some of the values in ClutterText have an initial state that
does not match a zero-ed out ClutterTextPrivate structure.

15 years agoMerge the ClutterLabel properties into ClutterText
Emmanuele Bassi [Thu, 11 Dec 2008 11:33:10 +0000 (11:33 +0000)]
Merge the ClutterLabel properties into ClutterText

ClutterText should have the same properties as ClutterLabel.

While at it, we can finally fix the disconnect between the wrap
and wrap-mode properties and its accessors, that we perpetuated
from GtkLabel.

The ClutterText:line-wrap property and ClutterText:line-wrap-mode
are mapped to the set_line_wrap(), get_line_wrap() and
set_line_wrap_mode(), get_line_wrap_mode() accessor functions
respectively. This should simplify bindings the Vala ones that
map a property into a method.

15 years agoAdd Text::get_chars() method declaration
Emmanuele Bassi [Thu, 11 Dec 2008 11:31:48 +0000 (11:31 +0000)]
Add Text::get_chars() method declaration

Add the declaration for a clutter_text_get_chars() function that
returns a portion of the contents of a Text actor.

15 years agoAdd Actor::grab_key_focus() method
Emmanuele Bassi [Thu, 11 Dec 2008 11:22:46 +0000 (11:22 +0000)]
Add Actor::grab_key_focus() method

Bug 1003 - Add clutter_actor_take_key_focus()

The grab_key_focus() method is just a simple wrapper around
clutter_stage_take_key_focus() that removes the need to get
the ClutterStage of an actor in order to set the key focus.

Based on a patch by Xan López.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
Signed-off-by: Øyvind Kolås <pippin@linux.intel.com>
15 years agoMerge Label and Entry API into ClutterText
Emmanuele Bassi [Thu, 11 Dec 2008 11:21:39 +0000 (11:21 +0000)]
Merge Label and Entry API into ClutterText

ClutterText should expose both ClutterLabel and ClutterEntry
functionality using an API that matches the one provided by
those two classes.

15 years agoExpose the Text accessors as public API
Emmanuele Bassi [Thu, 11 Dec 2008 11:20:14 +0000 (11:20 +0000)]
Expose the Text accessors as public API

Fix up the header to expose ClutterText accessors for the main
properties, matching ClutterLabel.

15 years agoUpdate the ClutterText interactive test
Emmanuele Bassi [Thu, 11 Dec 2008 11:18:05 +0000 (11:18 +0000)]
Update the ClutterText interactive test

Use ClutterText's own API instead of relying on the Label's API.

ClutterText is not meant to be a subclass of ClutterLabel.

15 years agoCoalesce ClutterLabel API usage
Emmanuele Bassi [Thu, 11 Dec 2008 11:17:26 +0000 (11:17 +0000)]
Coalesce ClutterLabel API usage

ClutterText replaces ClutterLabel, so it should expose the same
kind of API - ideally with the minimal amount of changes, so that
the porting is trivial.

15 years agoGroup all the integer private fields
Emmanuele Bassi [Thu, 11 Dec 2008 11:15:56 +0000 (11:15 +0000)]
Group all the integer private fields

Integer fields using the ": <bits>" notation should be packed
together so that the compiler can optimize the structure size
correctly.

15 years agoUse internal headers
Emmanuele Bassi [Thu, 11 Dec 2008 11:15:11 +0000 (11:15 +0000)]
Use internal headers

Since ClutterText is part of Clutter, it can use the internal
and private headers instead of the catch-all clutter.h.

15 years agoInitial import of the Text actor from Tidy
Emmanuele Bassi [Thu, 11 Dec 2008 11:12:48 +0000 (11:12 +0000)]
Initial import of the Text actor from Tidy

The TidyText actor is meant as a replacement for both ClutterLabel
and ClutterText.

Any text-displaying and editing actor should derive from ClutterText
and implement the various visual cues to differentiate the editable
from the non-editable state. Those visual cues usually belong to
a high-level toolkit, especially if themeing is involved.