Skip to content

How can I get the GDK_TYPE_PIXBUF constant? #2

@jasaldivara

Description

@jasaldivara

I want to create a GtkIconView using SwiftGtk.

For the Icon View I need a ListStore in which one of the columns is of the GdkPixbuf type.

This is a C example from the official Gtk documentation:

gtk_list_store_new (3, G_TYPE_INT, G_TYPE_STRING, GDK_TYPE_PIXBUF)

Another example in Python, from the Python Gtk 3 documenation:

liststore = Gtk.ListStore(Pixbuf, str)

I couldn't find an example of GtkIconView on the SwiftGtk examples, but I find the SwiftGtkListViewDemo which does something similar, creates a ListStore with two string columns and one boolean column using the .string and .boolean values, which are members of GType:

store = ListStore(.string, .string, .boolean)

If I try to do something like that using .pixbuf, swift compiler gives me an error message:

ls = ListStore(.pixbuf, .string)
error: type 'GType' (aka 'UInt') has no member 'pixbuf'
        ls = ListStore(.pixbuf, .string)
                       ~^~~~~~

I'm importing both Gdk and GdkPixbuf in my source code:

import Gtk
import Gdk
import GdkPixbuf

If I try to use the Pixbuf class as a type value, it gives me another error message:

ls = ListStore(Pixbuf, .string)
error: cannot convert value of type 'Pixbuf.Type' to expected argument type 'GType' (aka 'UInt')
        ls = ListStore(Pixbuf, .string)
                       ^

How can I create a ListStore in which one of the columns is of the Pixbuf type?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions