0

I'm trying to make a GridView of images which may or may not be draggable based on context

But I'm unable to even make the object as the parameters for the constructor don't make sense to me

How do I make this object or is there some example that I can follow? The Documentation makes no sense to me. I do not want to use a ui file.

I don't mind if I can find help for it in C as well

pp2yttD
  • 1
  • 1

1 Answers1

0

Well, I don't know Vala, but I can try to explain how to create the object through concepts. After you manage to create the object we can discuss the drag and drop issue. To create a GridView you will need:

Data Object: an object to hold the data to be displayed (a string that will be displayed like an item, for example).

List: A Gio.ListStore or other list object that will contain the data objects.

Selection: the type of Gtk.Selection that can be made in the component (none, single…), a List needs to be set as the model of the Gtk.Selection.

ItemFactory: an ItemFactory will create a widget to be displayed in the GridView (a Gtk.Label to display a string like an item, for example), and will add to it the object’s information in the List (the string that goes in the Gtk.Label). The ItemFactory can do this via signals or through the Builder. Gtk.SignalListItemFactory is easier to understand and creates the widgets through a “setup” function, and connects the data object information to the widget through a “bind” function. Both are connected to ItemFactory through its “bind” and “setup” signals.

Lastly, you need Gtk.GridView to display the widget created by the ItemFactory. Once all this is created, when you insert a Data Object into the List, the ItemFactory will call the “setup” function, then the “bind” function, and the Gtk.GridView will display the widget for that item.

Kripto
  • 46
  • 1
  • 3