Commit Graph

1794 Commits

Author SHA1 Message Date
Emmanuele Bassi
1892f8cb1d 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.
2009-01-06 12:35:19 +00:00
Emmanuele Bassi
1187004099 Clean up the update_pango_context() function
Logically split the various operations with whitespace so that
it's clear what does what.
2009-01-05 16:48:46 +00:00
Emmanuele Bassi
a5f9c72694 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.
2009-01-05 16:45:59 +00:00
Emmanuele Bassi
c79112bd3c Revert the logic of the PangoContext check
The branch that creates the global PangoContext should only run
if there is no global PangoContext already.
2009-01-05 16:44:52 +00:00
Emmanuele Bassi
700b34148b 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.
2009-01-05 16:29:49 +00:00
Emmanuele Bassi
c988b7b736 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.
2009-01-05 16:25:50 +00:00
Emmanuele Bassi
982a678053 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.
2009-01-05 15:29:10 +00:00
Emmanuele Bassi
d622a4dd89 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.
2009-01-05 15:27:33 +00:00
Emmanuele Bassi
33459f63d6 Whitespace fixes 2009-01-05 15:26:57 +00:00
Emmanuele Bassi
fa431f6492 [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.
2009-01-05 12:52:29 +00:00
Emmanuele Bassi
e56fe478ef 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.
2009-01-05 12:49:01 +00:00
Emmanuele Bassi
55a22d5750 [text] Add select-all binding
Bind Ctrl+A to the "select all" action.
2009-01-05 12:27:45 +00:00
Emmanuele Bassi
92e8b886d2 [docs] Add clutter_text_activate()
Add the last unused symbol to the ClutterText section.
2009-01-05 12:07:19 +00:00
Emmanuele Bassi
605ec10c32 [docs] Remove ClutterLabel and ClutterEntry sections
Remove the sections for the Label and the Entry actors, which
have been replaced by ClutterText.
2009-01-05 12:07:19 +00:00
Emmanuele Bassi
f777bc629a [docs] Document the newly added functions
Document the ClutterBackend font name accessors, and the
clutter_actor_get_pango_context() getter method.
2008-12-23 16:59:14 +00:00
Emmanuele Bassi
9389d9755d 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.
2008-12-23 16:40:26 +00:00
Emmanuele Bassi
b4a3944b2b 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.
2008-12-23 16:27:54 +00:00
Emmanuele Bassi
e3785f4f45 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.
2008-12-23 15:05:16 +00:00
Emmanuele Bassi
7262542155 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.
2008-12-23 15:03:11 +00:00
Emmanuele Bassi
977bdcf89b 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.
2008-12-23 14:34:16 +00:00
Emmanuele Bassi
213d8f0e4e 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.
2008-12-23 14:27:41 +00:00
Emmanuele Bassi
61d47ee301 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.
2008-12-23 14:15:10 +00:00
Emmanuele Bassi
a865a5d4ea 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.
2008-12-23 14:11:27 +00:00
Emmanuele Bassi
78628edf2f 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.
2008-12-23 14:06:55 +00:00
Emmanuele Bassi
b8b8b155c4 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.
2008-12-23 13:55:51 +00:00
Emmanuele Bassi
b021f518c1 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.
2008-12-22 13:43:41 +00:00
Emmanuele Bassi
4a934c363c 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.
2008-12-22 13:24:52 +00:00
Emmanuele Bassi
6b782ce4e7 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.
2008-12-16 15:53:57 +00:00
Emmanuele Bassi
ba586b46b3 [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.
2008-12-16 13:58:54 +00:00
Emmanuele Bassi
d85a1cb5a1 [docs] Add clutter_text_set_selection to gtk-doc
Insert the newly added symbol to the ClutterText section in
the API reference.
2008-12-16 12:42:44 +00:00
Emmanuele Bassi
a3fbdb5949 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.
2008-12-16 12:41:20 +00:00
Emmanuele Bassi
2209e17432 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.
2008-12-16 12:25:45 +00:00
Emmanuele Bassi
e28fb9ae10 [docs] Add more gtk-doc annotations
Almost reaching full documentation.
2008-12-16 12:25:15 +00:00
Emmanuele Bassi
4a43b582ac 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.
2008-12-16 12:05:10 +00:00
Emmanuele Bassi
93d96dca52 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.
2008-12-16 12:02:58 +00:00
Emmanuele Bassi
87f38475ae [docs] Add more gtk-doc annotations for ClutterText
Document the ClutterText constructors and the :editable, :selectable
and :activatable properties accessors.
2008-12-16 11:52:57 +00:00
Emmanuele Bassi
e3ba2ddf0a [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.
2008-12-16 11:30:47 +00:00
Emmanuele Bassi
32896d9aee [docs] Add :cursor-size property accessors
Add the ClutterText:cursor-size property accessors to the
known gtk-doc symbols for the ClutterText section.
2008-12-16 10:43:05 +00:00
Emmanuele Bassi
7ebb9ff6b7 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.
2008-12-16 10:39:52 +00:00
Emmanuele Bassi
ea5a6abd9d 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.
2008-12-16 10:37:45 +00:00
Emmanuele Bassi
ffb500d3a6 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.
2008-12-16 10:19:56 +00:00
Emmanuele Bassi
dc49dab350 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
be64cbcdc2 for the move-up and
move-down bindings.
2008-12-16 10:15:57 +00:00
Emmanuele Bassi
be64cbcdc2 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.
2008-12-15 18:46:08 +00:00
Emmanuele Bassi
e615b8cc6b 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().
2008-12-15 18:24:42 +00:00
Emmanuele Bassi
2714397fd5 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.
2008-12-15 18:23:25 +00:00
Emmanuele Bassi
2d166b250c [docs] Add annotations for ClutterText structures
ClutterText and ClutterTextClass were missing annotations for
gtk-doc to pick up.
2008-12-15 15:10:55 +00:00
Emmanuele Bassi
39b575e6b4 Remove ClutterLabel and ClutterEntry
Both ClutterLabel and ClutterEntry have been deprecated by
ClutterText.
2008-12-15 15:08:12 +00:00
Emmanuele Bassi
c8dbbfaacf [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.
2008-12-11 15:01:28 +00:00
Emmanuele Bassi
a50dfefbc3 Fix documentation issues
Provide a description for the ClutterText section, and fix some
misnamed arguments inside the header file.
2008-12-11 15:00:22 +00:00
Emmanuele Bassi
0ac1590378 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.
2008-12-11 14:57:46 +00:00