gi-gtk4-4.0.12: Gtk 4.x bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | None
Language | Haskell2010

GI.Gtk.Objects.StringList

Contents

- Exported types
- Methods
  - append
  - find
  - getString
  - new
  - remove
  - splice
  - take
- Properties
  - itemType
  - nItems
  - strings

Description

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

- newtype StringList = StringList (ManagedPtr StringList)
- class (GObject o, IsDescendantOf StringList o) => IsStringList o
- toStringList :: (MonadIO m, IsStringList o) => o -> m StringList
- stringListAppend :: (HasCallStack, MonadIO m, IsStringList a) => a -> Text -> m ()
- stringListFind :: (HasCallStack, MonadIO m, IsStringList a) => a -> Text -> m Word32
- stringListGetString :: (HasCallStack, MonadIO m, IsStringList a) => a -> Word32 -> m (Maybe Text)
- stringListNew :: (HasCallStack, MonadIO m) => Maybe [Text] -> m StringList
- stringListRemove :: (HasCallStack, MonadIO m, IsStringList a) => a -> Word32 -> m ()
- stringListSplice :: (HasCallStack, MonadIO m, IsStringList a) => a -> Word32 -> Word32 -> Maybe [Text] -> m ()
- stringListTake :: (HasCallStack, MonadIO m, IsStringList a) => a -> Text -> m ()
- getStringListItemType :: (MonadIO m, IsStringList o) => o -> m GType
- getStringListNItems :: (MonadIO m, IsStringList o) => o -> m Word32
- constructStringListStrings :: (IsStringList o, MonadIO m) => [Text] -> m (GValueConstruct o)

# 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 Methods (==) :: StringList -> StringList -> Bool Source # (/=) :: StringList -> StringList -> Bool Source #
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 Source #
TypedObject StringList Source # |
Instance details Defined in GI.Gtk.Objects.StringList Methods glibType :: IO GType Source #
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 Source # gvalueSet_ :: Ptr GValue -> Maybe StringList -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe StringList) Source #
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

### Click to display all available methods, including inherited ones

Expand

#### Methods

append, bindProperty, bindPropertyFull, find, forceFloating, freezeNotify, getv, isFloating, itemsChanged, notify, notifyByPspec, ref, refSink, remove, runDispose, splice, stealData, stealQdata, take, thawNotify, unref, watchClosure.

#### Getters

getBuildableId, getData, getItem, getItemType, getNItems, getProperty, getQdata, getString.

#### Setters

setData, setDataFull, setProperty.

## 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.

## find

stringListFind Source #

Arguments

:: (HasCallStack, MonadIO m, IsStringList a) |
=> a | `self`: a `GtkStringList`
-> Text | `string`: the string to find
-> m Word32 | Returns: the position of the string

Gets the position of the `string` in `self`.

If `self` does not contain `string` item, `G_MAXUINT` is returned.

Since: 4.18

## 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`.