gi-gtk-4.0.11: Gtk bindings
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellNone
LanguageHaskell2010

GI.Gtk.Objects.StringList

Description

GtkStringList is a list model that wraps an array of strings.

The objects in the model are of type StringObject and have a "string" property that can be used inside expressions.

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

xml code

<object class="GtkStringList">
  <items>
    <item translatable="yes">Factory</item>
    <item translatable="yes">Home</item>
    <item translatable="yes">Subway</item>
  </items>
</object>
Synopsis

Exported types

newtype StringList Source #

Memory-managed wrapper type.

class (GObject o, IsDescendantOf StringList o) => IsStringList o Source #

Type class for types which can be safely cast to StringList, for instance with toStringList.

Instances

Instances details
(GObject o, IsDescendantOf StringList o) => IsStringList o Source # 
Instance details

Defined in GI.Gtk.Objects.StringList

toStringList :: (MonadIO m, IsStringList o) => o -> m StringList Source #

Cast to StringList, for types for which this is known to be safe. For general casts, use castTo.

Methods

append

stringListAppend Source #

Arguments

:: (HasCallStack, MonadIO m, IsStringList a) 
=> a

self: a GtkStringList

-> Text

string: the string to insert

-> m () 

Appends string to self.

The string will be copied. See stringListTake for a way to avoid that.

getString

stringListGetString Source #

Arguments

:: (HasCallStack, MonadIO m, IsStringList a) 
=> a

self: a GtkStringList

-> Word32

position: the position to get the string for

-> m (Maybe Text)

Returns: the string at the given position

Gets the string that is at position in self.

If self does not contain position items, Nothing is returned.

This function returns the const char *. To get the object wrapping it, use g_list_model_get_item().

new

stringListNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Maybe [Text]

strings: The strings to put in the model

-> m StringList

Returns: a new GtkStringList

Creates a new GtkStringList with the given strings.

remove

stringListRemove Source #

Arguments

:: (HasCallStack, MonadIO m, IsStringList a) 
=> a

self: a GtkStringList

-> Word32

position: the position of the string that is to be removed

-> m () 

Removes the string at position from self.

position must be smaller than the current length of the list.

splice

stringListSplice Source #

Arguments

:: (HasCallStack, MonadIO m, IsStringList a) 
=> a

self: a GtkStringList

-> Word32

position: the position at which to make the change

-> Word32

nRemovals: the number of strings to remove

-> Maybe [Text]

additions: The strings to add

-> m () 

Changes self by removing nRemovals strings and adding additions to it.

This function is more efficient than stringListAppend and stringListRemove, because it only emits the itemsChanged signal once for the change.

This function copies the strings in additions.

The parameters position and nRemovals must be correct (ie: position + nRemovals must be less than or equal to the length of the list at the time this function is called).

take

stringListTake Source #

Arguments

:: (HasCallStack, MonadIO m, IsStringList a) 
=> a

self: a GtkStringList

-> Text

string: the string to insert

-> m () 

Adds string to self at the end, and takes ownership of it.

This variant of stringListAppend is convenient for formatting strings:

c code

gtk_string_list_take (self, g_strdup_print ("%d dollars", lots));

Properties

itemType

The type of items. See listModelGetItemType.

Since: 4.14

getStringListItemType :: (MonadIO m, IsStringList o) => o -> m GType Source #

Get the value of the “item-type” property. When overloading is enabled, this is equivalent to

get stringList #itemType

nItems

The number of items. See listModelGetNItems.

Since: 4.14

getStringListNItems :: (MonadIO m, IsStringList o) => o -> m Word32 Source #

Get the value of the “n-items” property. When overloading is enabled, this is equivalent to

get stringList #nItems

strings

The strings in the model.

Since: 4.10

constructStringListStrings :: (IsStringList o, MonadIO m) => [Text] -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “strings” property. This is rarely needed directly, but it is used by new.