Gda.Holder¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
|
|
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w |
Holder’s description |
||
r/w |
Make value holder follow other |
||
r/w/c |
Holder’s |
||
r/w |
Holder’s ID |
||
r/w |
Holder’s name |
||
r/w |
Can the value holder be |
||
r/w |
Make value holder follow other |
||
r/w |
Column number to use in coordination with the source-model property |
||
r/w |
Data model among which the holder’s value should be |
||
r/w |
Defines if the validate-change signal is emitted on value change |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
Gets emitted when any holder's attribute has changed |
|
Gets emitted when holder's value has changed |
|
Gets emitted when the data model in which holder's values should be has changed |
|
Gets emitted when holder is going to change its value. |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
object |
r |
Class Details¶
- class Gda.Holder(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
- classmethod new(type)¶
- Parameters:
type (
GObject.GType
) – theGObject.GType
requested- Returns:
a new
Gda.Holder
object- Return type:
Creates a new holder of type type
- copy()¶
- Returns:
a new
Gda.Holder
object- Return type:
Copy constructor.
Note1: if self is set with a static value (see
Gda.Holder.take_static_value
()) its copy will have a fresh new allocatedGObject.Value
, so that user should free it when done.
- force_invalid()¶
Forces a holder to be invalid; to set it valid again, a new value must be assigned to it using
Gda.Holder.set_value
() orGda.Holder.take_value
().self's value is set to
None
.
- force_invalid_e(error)¶
- Parameters:
error (
GLib.Error
orNone
) – aGLib.Error
explaining why self is declared invalid, orNone
Forces a holder to be invalid; to set it valid again, a new value must be assigned to it using
Gda.Holder.set_value
() orGda.Holder.take_value
().self's value is set to
None
.New in version 4.2.10.
- get_alphanum_id()¶
- Returns:
a new string
- Return type:
Get an “encoded” version of self's name. The “encoding” consists in replacing non alphanumeric character with the string “__gdaXX” where XX is the hex. representation of the non alphanumeric
str
.This method is just a wrapper around the
Gda.text_to_alphanum
() function.
- get_attribute(attribute)¶
- Parameters:
attribute (
str
) – attribute name as a string- Returns:
a read-only
GObject.Value
, orNone
if not attribute named attribute has been set for self- Return type:
Get the value associated to a named attribute.
Attributes can have any name, but Libgda proposes some default names, see ‘this section [libgda-40-Attributes-manager.synopsis]’.
- get_bind()¶
- Returns:
the
Gda.Holder
orNone
- Return type:
Get the holder which makes self change its value when the holder’s value is changed.
- get_default_value()¶
- Returns:
the default value
- Return type:
Get the default value held into the holder. WARNING: the default value does not need to be of the same type as the one required by self.
- get_g_type()¶
- Return type:
- get_id()¶
- Returns:
the ID (don’t modify the string).
- Return type:
Get the ID of self. The ID can be set using self's “id” property
- get_source_model(col)¶
- Parameters:
col (
int
) – a place to store the column in the model sourcing the holder, orNone
- Returns:
a pointer to a
Gda.DataModel
, orNone
- Return type:
If
Gda.Holder.set_source_model
() has been used to provide a hint that self's value should be among the values contained in a column of a data model, then this method returns which data model, and if col is notNone
, then it is set to the restricting column as well.Otherwise, this method returns
None
, and if col is notNone
, then it is set to 0.
- get_value()¶
- Returns:
the value, or
None
- Return type:
Get the value held into the holder. If self is set to use its default value and that default value is not of the same type as self, then
None
is returned.If self is set to
None
, then the returned value is a #GDA_TYPE_NULLGObject.Value
.If self is invalid, then the returned value is
None
.
- get_value_str(dh)¶
- Parameters:
dh (
Gda.DataHandler
orNone
) – aGda.DataHandler
to use, orNone
- Returns:
the value, or
None
- Return type:
Same functionality as
Gda.Holder.get_value
() except that it returns the value as a string (the conversion is done using dh if notNone
, or the default data handler otherwise).
- is_valid()¶
-
Get the validity of self (that is, of the value held by self)
- is_valid_e()¶
- Raises:
- Returns:
True
if self's value can safely be used- Return type:
Get the validity of self (that is, of the value held by self)
New in version 4.2.10.
- set_attribute(attribute, value, destroy)¶
- Parameters:
attribute (
str
) – attribute namevalue (
GObject.Value
) – aGObject.Value
, orNone
destroy (
GLib.DestroyNotify
) – a function to be called when attribute is not needed anymore, orNone
Set the value associated to a named attribute. The attribute string is ‘stolen’ by this method, and the memory it uses will be freed using the destroy function when no longer needed (if destroy is
None
, then the string will not be freed at all).Attributes can have any name, but Libgda proposes some default names, see ‘this section [libgda-5.0-Attributes-manager.synopsis]’.
For example one would use it as:
Gda.Holder.set_attribute
(holder,GLib.strdup
(my_attribute), my_value,GLib.free
);Gda.Holder.set_attribute
(holder,Gda.ATTRIBUTE_NAME
, my_value,None
); If there is already an attribute named attribute set, then its value is replaced with the new value (value is copied), except if value isNone
, in which case the attribute is removed.
- set_bind(bind_to)¶
- Parameters:
bind_to (
Gda.Holder
) – aGda.Holder
orNone
- Raises:
- Returns:
True
if no error occurred- Return type:
Sets self to change when bind_to changes (and does not make bind_to change when self changes). For the operation to succeed, the
GObject.GType
of self and bind_to must be the same, with the exception that any of them can have a %GDA_TYPE_NULL type (in this situation, theGObject.GType
of the twoGda.Holder
objects involved is set to match the other when any of them sets its type to something different than GDA_TYPE_NULL).If bind_to is
None
, then self will not be bound anymore.
- set_default_value(value)¶
- Parameters:
value (
GObject.Value
) – a value to set the holder’s default value, orNone
Sets the default value within the holder. If value is
None
then self won’t have a default value anymore. To set a default value toNone
, then pass aGObject.Value
created using gda_value_new_null().NOTE: the default value does not need to be of the same type as the one required by self.
- set_not_null(not_null)¶
-
Sets if the holder can have a
None
value. If not_null isTrue
, then that won’t be allowed
- set_source_model(model, col)¶
- Parameters:
model (
Gda.DataModel
) – aGda.DataModel
object orNone
col (
int
) – the reference column in model
- Raises:
- Returns:
True
if no error occurred- Return type:
Sets an hint that self's values should be restricted among the values contained in the col column of the model data model. Note that this is just a hint, meaning this policy is not enforced by self's implementation.
If model is
None
, then the effect is to cancel ant previous call toGda.Holder.set_source_model
() where model was notNone
.
- set_value(value)¶
- Parameters:
value (
GObject.Value
orNone
) – a value to set the holder to, orNone
- Raises:
- Returns:
True
if value has been set- Return type:
Sets the value within the holder. If self is an alias for another holder, then the value is also set for that other holder.
On success, the action of any call to
Gda.Holder.force_invalid
() is cancelled as soon as this method is called (even if self's value does not actually change)If the value is not different from the one already contained within self, then self is not changed and no signal is emitted.
Note1: the value argument is treated the same way if it is
None
or if it is a #GDA_TYPE_NULL valueNote2: if self can’t accept the value value, then this method returns
False
, and self will be left in an invalid state.Note3: before the change is accepted by self, the “validate-change” signal will be emitted (the value of which can prevent the change from happening) which can be connected to to have a greater control of which values self can have, or implement some business rules.
- set_value_str(dh, value)¶
- Parameters:
dh (
Gda.DataHandler
) – aGda.DataHandler
to use, orNone
value (
str
) – a value to set the holder to, as a string
- Raises:
- Returns:
True
if value has been set- Return type:
Same functionality as
Gda.Holder.set_value
() except that it uses a string representation of the value to set, which will be converted into aGObject.Value
first (using default data handler if dh isNone
).Note1: if value is
None
or is the “None
" string, then self's value is set toNone
. Note2: if self can’t accept the value value, then this method returnsFalse
, and self will be left in an invalid state.
- set_value_to_default()¶
-
Set self's value to its default value.
- take_static_value(value, value_changed)¶
- Parameters:
value (
GObject.Value
) – a const value to set the holder tovalue_changed (
bool
) – a boolean set withTrue
if the value changes,False
elsewhere.
- Raises:
- Returns:
None
if an error occurred or if the previousGObject.Value
wasNone
itself. It returns the staticGObject.Value
user set previously, so that he can free it.- Return type:
Sets the const value within the holder. If self is an alias for another holder, then the value is also set for that other holder.
The value will not be freed, and user should take care of it, either for its freeing or for its correct value at the moment of query.
If the value is not different from the one already contained within self, then self is not changed and no signal is emitted.
Note1: if self can’t accept the value value, then this method returns
None
, and self will be left in an invalid state.Note2: before the change is accepted by self, the “validate-change” signal will be emitted (the value of which can prevent the change from happening) which can be connected to to have a greater control of which values self can have, or implement some business rules.
- take_value(value)¶
- Parameters:
value (
GObject.Value
) – a value to set the holder to- Raises:
- Returns:
True
if value has been set- Return type:
Sets the value within the holder. If self is an alias for another holder, then the value is also set for that other holder.
On success, the action of any call to
Gda.Holder.force_invalid
() is cancelled as soon as this method is called (even if self's value does not actually change).If the value is not different from the one already contained within self, then self is not changed and no signal is emitted.
Note1: if self can’t accept the value value, then this method returns
False
, and self will be left in an invalid state.Note2: before the change is accepted by self, the “validate-change” signal will be emitted (the value of which can prevent the change from happening) which can be connected to to have a greater control of which values self can have, or implement some business rules.
Note3: if user previously set this holder with
Gda.Holder.take_static_value
() theGObject.Value
stored internally will be forgiven and replaced by the value. User should then take care of the ‘old’ staticGObject.Value
.
- value_is_default()¶
-
Tells if self's current value is the default one.
- do_att_changed(att_name, att_value) virtual¶
- Parameters:
att_name (
str
) –att_value (
GObject.Value
) –
- do_changed() virtual¶
- do_source_changed() virtual¶
- do_validate_change(new_value) virtual¶
- Parameters:
new_value (
GObject.Value
) –- Return type:
Signal Details¶
- Gda.Holder.signals.attribute_changed(holder, att_name, att_value)¶
- Signal Name:
attribute-changed
- Flags:
- Parameters:
holder (
Gda.Holder
) – The object which received the signalatt_name (
str
) – attribute’s nameatt_value (
GObject.Value
) – attribute’s value
Gets emitted when any holder's attribute has changed
- Gda.Holder.signals.changed(holder)¶
- Signal Name:
changed
- Flags:
- Parameters:
holder (
Gda.Holder
) – The object which received the signal
Gets emitted when holder's value has changed
- Gda.Holder.signals.source_changed(holder)¶
- Signal Name:
source-changed
- Flags:
- Parameters:
holder (
Gda.Holder
) – The object which received the signal
Gets emitted when the data model in which holder's values should be has changed
- Gda.Holder.signals.validate_change(holder, new_value)¶
- Signal Name:
validate-change
- Flags:
- Parameters:
holder (
Gda.Holder
) – The object which received the signalnew_value (
GObject.Value
) – the proposed new value for holder
- Returns:
None
if holder is allowed to change its value to new_value, or aGLib.Error
otherwise.- Return type:
Gets emitted when holder is going to change its value. One can connect to this signal to control which values holder can have (for example to implement some business rules)
Property Details¶
- Gda.Holder.props.description¶
-
Holder’s description
- Gda.Holder.props.full_bind¶
- Name:
full-bind
- Type:
- Default Value:
- Flags:
Make value holder follow other
Gda.Holder
's changes and the other way around
- Gda.Holder.props.g_type¶
- Name:
g-type
- Type:
- Default Value:
<GType void>
- Flags:
Holder’s
GObject.GType
- Gda.Holder.props.name¶
-
Holder’s name
- Gda.Holder.props.simple_bind¶
- Name:
simple-bind
- Type:
- Default Value:
- Flags:
Make value holder follow other
Gda.Holder
's changes
- Gda.Holder.props.source_column¶
-
Column number to use in coordination with the source-model property
- Gda.Holder.props.source_model¶
- Name:
source-model
- Type:
- Default Value:
- Flags:
Data model among which the holder’s value should be