Top |
Functions
GtkStringList * | gtk_string_list_new () |
void | gtk_string_list_append () |
void | gtk_string_list_take () |
void | gtk_string_list_remove () |
void | gtk_string_list_splice () |
const char * | gtk_string_list_get_string () |
GtkStringObject * | gtk_string_object_new () |
const char * | gtk_string_object_get_string () |
Description
GtkStringList is a list model that wraps an array of strings.
The objects in the model have a "string" property.
GtkStringList is well-suited for any place where you would
typically use a char*[]
, but need a list model.
GtkStringList as GtkBuildable
The GtkStringList implementation of the GtkBuildable interface supports adding items directly using the <items> element and specifying <item> elements for each item. Each <item> element supports the regular translation attributes “translatable”, “context” and “comments”.
Here is a UI definition fragment specifying a GtkStringList
1 2 3 4 5 6 7 |
<object class="GtkStringList"> <items> <item translatable="yes">Factory</item> <item translatable="yes">Home</item> <item translatable="yes">Subway</item> </items> </object> |
Functions
gtk_string_list_new ()
GtkStringList *
gtk_string_list_new (const char * const *strings
);
Creates a new GtkStringList with the given strings
.
gtk_string_list_append ()
void gtk_string_list_append (GtkStringList *self
,const char *string
);
Appends string
to self
.
The string
will be copied. See gtk_string_list_take()
for a way to avoid that.
gtk_string_list_take ()
void gtk_string_list_take (GtkStringList *self
,char *string
);
Adds string
to self at the end, and takes
ownership of it.
This variant of gtk_string_list_append()
is
convenient for formatting strings:
1 |
gtk_string_list_take (self, g_strdup_print ("%d dollars", lots)); |
gtk_string_list_remove ()
void gtk_string_list_remove (GtkStringList *self
,guint position
);
Removes the string at position
from self
. position
must
be smaller than the current length of the list.
gtk_string_list_splice ()
void gtk_string_list_splice (GtkStringList *self
,guint position
,guint n_removals
,const char * const *additions
);
Changes self
by removing n_removals
strings and adding additions
to it.
This function is more efficient than gtk_string_list_append()
and
gtk_string_list_remove()
, because it only emits
“items-changed” once for the change.
This function copies the strings in additions
.
The parameters position
and n_removals
must be correct (ie:
position
+ n_removals
must be less than or equal to the length
of the list at the time this function is called).
gtk_string_list_get_string ()
const char * gtk_string_list_get_string (GtkStringList *self
,guint position
);
Gets the string that is at position
in self
. If self
does not contain position
items, NULL
is returned.
This function returns the const char *. To get the
object wrapping it, use g_list_model_get_item()
.
gtk_string_object_new ()
GtkStringObject *
gtk_string_object_new (const char *string
);
Wraps a string in an object for use with GListModel
gtk_string_object_get_string ()
const char *
gtk_string_object_get_string (GtkStringObject *self
);
Returns the string contained in a GtkStringObject.