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

GI.Gtk.Objects.StringList

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

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.

Constructors

StringList (ManagedPtr StringList) 

Instances

Instances details
Eq StringList Source # 
Instance details

Defined in GI.Gtk.Objects.StringList

GObject StringList Source # 
Instance details

Defined in GI.Gtk.Objects.StringList

ManagedPtrNewtype StringList Source # 
Instance details

Defined in GI.Gtk.Objects.StringList

Methods

toManagedPtr :: StringList -> ManagedPtr StringList

TypedObject StringList Source # 
Instance details

Defined in GI.Gtk.Objects.StringList

Methods

glibType :: IO GType

HasParentTypes StringList Source # 
Instance details

Defined in GI.Gtk.Objects.StringList

IsGValue (Maybe StringList) Source #

Convert StringList to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.Gtk.Objects.StringList

Methods

gvalueGType_ :: IO GType

gvalueSet_ :: Ptr GValue -> Maybe StringList -> IO ()

gvalueGet_ :: Ptr GValue -> IO (Maybe StringList)

type ParentTypes StringList Source # 
Instance details

Defined in GI.Gtk.Objects.StringList

type ParentTypes StringList = '[Object, ListModel, Buildable]

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));