Documentation ¶
Index ¶
- func Append(parent Appender, widgets ...gtk.Widgetter)
- func FetchObjects(str any, builder string)
- func NewFactoryBind(f func(listitem ListItem, pos int)) func(*glib.Object)
- func NewFactorySetup(f func(listitem ListItem)) func(*glib.Object)
- func NewListModel[T any](items ...T) *gioutil.ListModel[T]
- func ToWidgetter[T gtk.Widgetter](items []T) []gtk.Widgetter
- type Appender
- type Factory
- func (f *Factory[T]) Bind() FactoryBind[T]
- func (f *Factory[T]) Modeller() Modeller[T]
- func (f *Factory[T]) SetBind(b FactoryBind[T])
- func (f *Factory[T]) SetModeller(m Modeller[T])
- func (f *Factory[T]) SetSetup(s FactorySetup)
- func (f *Factory[T]) SetSignalListItemFactory(fac *gtk.SignalListItemFactory)
- func (f *Factory[T]) Setup() FactorySetup
- func (f *Factory[T]) SignalListItemFactory() *gtk.SignalListItemFactory
- type FactoryBind
- type FactorySetup
- type Factoryer
- type ListItem
- type ListSelectionMode
- type Model
- func (m *Model[T]) Append(items ...T)
- func (m *Model[T]) At(index int) T
- func (m *Model[T]) Len() int
- func (m *Model[T]) ListModel() *gioutil.ListModel[T]
- func (m *Model[T]) Range(f func(i int, v T) bool)
- func (m *Model[T]) RefreshItems()
- func (m *Model[T]) RefreshModel()
- func (m *Model[T]) Remove(index int)
- func (m *Model[T]) S() []T
- func (m *Model[T]) SetItems(items []T)
- func (m *Model[T]) Splice(pos, rms int, values ...T)
- type ModelVar
- func (m *ModelVar[T]) Append(items ...T)
- func (m *ModelVar[T]) At(i int) T
- func (m *ModelVar[T]) Len() int
- func (m *ModelVar[T]) ListModel() *gioutil.ListModel[T]
- func (m *ModelVar[T]) Ptr() *[]T
- func (m *ModelVar[T]) Range(f func(int, T) bool)
- func (m *ModelVar[T]) RefreshItems()
- func (m *ModelVar[T]) RefreshModel()
- func (m *ModelVar[T]) Remove(i int)
- func (m *ModelVar[T]) S() []T
- func (m *ModelVar[T]) SetItems(items []T)
- func (m *ModelVar[T]) Splice(pos, rms int, appends ...T)
- type Modeller
- type Selection
- func (s *Selection) Autoselect() bool
- func (s *Selection) CanUnselect() bool
- func (s *Selection) ConnectMultipleSelected(f func([]int))
- func (s *Selection) ConnectSelected(f func(int))
- func (s *Selection) ListModeller() gio.ListModeller
- func (s *Selection) MultipleSelected() []int
- func (s *Selection) Select(index int)
- func (s *Selection) SelectAll()
- func (s *Selection) SelectMultiple(indexes ...int)
- func (s *Selection) SelectRange(pos, nItems int, unSelectRest bool)
- func (s *Selection) Selected() int
- func (s *Selection) SelectionMode() ListSelectionMode
- func (s *Selection) SelectionModeller() gtk.SelectionModeller
- func (s *Selection) SetAutoselect(b bool)
- func (s *Selection) SetCanUnselect(b bool)
- func (s *Selection) SetListModeller(m gio.ListModeller)
- func (s *Selection) SetSelectionMode(mode ListSelectionMode)
- func (s *Selection) SetSelectionModeller(m gtk.SelectionModeller)
- func (s *Selection) Unselect(index int)
- func (s *Selection) UnselectAll()
- func (s *Selection) UnselectRange(pos, nItems int)
- type Selectioner
- type SetModelFactoryer
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FetchObjects ¶
What this function does is to obtain the tags of the provided structure and with the content of the tag call gtk.Builder.GetObject and assign it to its corresponding field, if the field has no tag it will be skipped and if it is another sub struct it will continue until it reaches the end.
Example ¶
gtk.Init() const xml = `<?xml version="1.0" encoding="UTF-8"?> <interface> <requires lib="gtk" version="4.0"/> <object class="GtkWindow" id="window"> <property name="title">Hello World</property> </object> </interface>` type ui struct { Window *gtk.Window `gtk:"window"` } w := new(ui) gtools.FetchObjects(w, xml) fmt.Println(w.Window.Title()) // Hello World
Output:
func NewFactoryBind ¶
func NewFactorySetup ¶
func NewFactorySetup(f func(listitem ListItem)) func(*glib.Object)
func NewListModel ¶
func ToWidgetter ¶
func ToWidgetter[T gtk.Widgetter](items []T) []gtk.Widgetter
Converts the slice of the gtk.Widgetter types to a slice of gtk.Widgetter.
Types ¶
type Appender ¶
type Appender interface {
glib.Objector
Append(gtk.Widgetter)
}
It is simply an interface of a glib.Objector that has the append method.
type Factory ¶
type Factory[T any] struct { // contains filtered or unexported fields }
func NewFactory ¶
func NewFactory[T any]( model Modeller[T], setup FactorySetup, bind FactoryBind[T], ) *Factory[T]
func (*Factory[T]) Bind ¶
func (f *Factory[T]) Bind() FactoryBind[T]
func (*Factory[T]) SetBind ¶
func (f *Factory[T]) SetBind(b FactoryBind[T])
func (*Factory[T]) SetModeller ¶
func (*Factory[T]) SetSetup ¶
func (f *Factory[T]) SetSetup(s FactorySetup)
func (*Factory[T]) SetSignalListItemFactory ¶ added in v1.15.1
func (f *Factory[T]) SetSignalListItemFactory(fac *gtk.SignalListItemFactory)
func (*Factory[T]) Setup ¶
func (f *Factory[T]) Setup() FactorySetup
func (*Factory[T]) SignalListItemFactory ¶ added in v1.15.1
func (f *Factory[T]) SignalListItemFactory() *gtk.SignalListItemFactory
type FactoryBind ¶
type FactorySetup ¶
type FactorySetup func(ListItem)
type Factoryer ¶
type Factoryer[T any] interface { SetSignalListItemFactory(*gtk.SignalListItemFactory) SignalListItemFactory() *gtk.SignalListItemFactory Modeller() Modeller[T] SetModeller(Modeller[T]) SetSetup(FactorySetup) Setup() FactorySetup SetBind(FactoryBind[T]) Bind() FactoryBind[T] }
type ListItem ¶
type ListItem interface { glib.Objector AccessibleDescription() string AccessibleLabel() string Activatable() bool Child() gtk.Widgetter Focusable() bool Item() *glib.Object Position() uint Selectable() bool Selected() bool SetAccessibleDescription(description string) SetAccessibleLabel(label string) SetActivatable(activatable bool) SetChild(child gtk.Widgetter) SetFocusable(focusable bool) SetSelectable(selectable bool) }
type ListSelectionMode ¶
type ListSelectionMode int
const ( SelectionNone ListSelectionMode = iota SelectionSingle SelectionMultiple )
type Model ¶
type Model[T any] struct { // contains filtered or unexported fields }
func (*Model[T]) RefreshItems ¶
func (m *Model[T]) RefreshItems()
Regenerates the List.Items based on the model.
func (*Model[T]) RefreshModel ¶
func (m *Model[T]) RefreshModel()
type ModelVar ¶
type ModelVar[T any] struct { // contains filtered or unexported fields }
func NewModelVar ¶
func (*ModelVar[T]) RefreshItems ¶
func (m *ModelVar[T]) RefreshItems()
func (*ModelVar[T]) RefreshModel ¶
func (m *ModelVar[T]) RefreshModel()
type Selection ¶
type Selection struct {
// contains filtered or unexported fields
}
func NewSelection ¶
func NewSelection(mode ListSelectionMode, model gio.ListModeller) *Selection
func (*Selection) Autoselect ¶
If the assigned ListModeller is not compatible with this setting it will simply do nothing. This setting is only compatible with SelectionSingle.
func (*Selection) CanUnselect ¶
func (*Selection) ConnectMultipleSelected ¶
func (*Selection) ConnectSelected ¶
func (*Selection) ListModeller ¶
func (s *Selection) ListModeller() gio.ListModeller
func (*Selection) MultipleSelected ¶
This method iterates over each element in the list and returns the selected ones. It only does something if the ListModel is a MultipleSelection, otherwise it simply returns an empty list.
func (*Selection) Select ¶
The Select method behaves as expected when applied to a SingleSelection SelectionModel. It selects the item at the specified index. However, when applied to a MultipleSelection, it behaves differently. Instead of selecting only the item at the specified index, it deselects all other items and selects only the one at that index.
In the case of NoSelection, it simply does nothing.
func (*Selection) SelectAll ¶
func (s *Selection) SelectAll()
With SelectionNone and SelectionSingle it does nothing, and with SelectionMultiple, it does what it promises, i.e., select all items in the list.
func (*Selection) SelectMultiple ¶
This method only does something when the ListModel is of the MultiSelection type, and it requires you to pass the indexes that it will select. If any of the indexes cannot be converted to uint, it will simply iterate to the next element. However, if any of the indexes are not in the list, it will throw an error, i.e. it will crash.
If an element is already selected, deselects it.
func (*Selection) SelectRange ¶
Requests to select a range of items.
func (*Selection) Selected ¶
Returns the index of the selected item, or -1 if its index is null or the selection model does not allow it.
func (*Selection) SelectionMode ¶
func (s *Selection) SelectionMode() ListSelectionMode
func (*Selection) SelectionModeller ¶
func (s *Selection) SelectionModeller() gtk.SelectionModeller
func (*Selection) SetAutoselect ¶
If the assigned ListModeller is not compatible with this setting it will simply do nothing. This setting is only compatible with SelectionSingle.
func (*Selection) SetCanUnselect ¶
func (*Selection) SetListModeller ¶
func (s *Selection) SetListModeller(m gio.ListModeller)
func (*Selection) SetSelectionMode ¶
func (s *Selection) SetSelectionMode(mode ListSelectionMode)
func (*Selection) SetSelectionModeller ¶
func (s *Selection) SetSelectionModeller(m gtk.SelectionModeller)
func (*Selection) UnselectAll ¶
func (s *Selection) UnselectAll()
With SelectionSingle and SelectionMultiple it deselects the only element that can be selected, with SelectionNone it does nothing.
func (*Selection) UnselectRange ¶
Requests to unselect a range of items.
type Selectioner ¶
type Selectioner interface { ListModeller() gio.ListModeller SetListModeller(gio.ListModeller) Autoselect() bool SetAutoselect(bool) CanUnselect() bool SetCanUnselect(bool) SelectionModeller() gtk.SelectionModeller SetSelectionModeller(gtk.SelectionModeller) SelectionMode() ListSelectionMode SetSelectionMode(ListSelectionMode) ConnectSelected(func(int)) ConnectMultipleSelected(func([]int)) SelectRange(int, int, bool) SelectAll() Select(int) SelectMultiple(...int) UnselectAll() UnselectRange(int, int) Unselect(int) Selected() int MultipleSelected() []int }
type SetModelFactoryer ¶
type SetModelFactoryer interface { gtk.Widgetter SetModel(gtk.SelectionModeller) SetFactory(*gtk.ListItemFactory) }