{"id":23804005,"url":"https://github.com/phastmike/vala-liststore-object-example","last_synced_at":"2026-02-28T01:04:30.143Z","repository":{"id":119349645,"uuid":"119270471","full_name":"phastmike/vala-liststore-object-example","owner":"phastmike","description":"A simple treeview example","archived":false,"fork":false,"pushed_at":"2020-07-04T21:02:23.000Z","size":3,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-11T01:31:47.271Z","etag":null,"topics":["example","gobject","treeview","vala"],"latest_commit_sha":null,"homepage":"","language":"Vala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phastmike.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-01-28T15:28:30.000Z","updated_at":"2022-11-27T20:26:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"ef3a40f2-850b-4b4b-9f5e-fdfe7c4bab75","html_url":"https://github.com/phastmike/vala-liststore-object-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/phastmike/vala-liststore-object-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phastmike%2Fvala-liststore-object-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phastmike%2Fvala-liststore-object-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phastmike%2Fvala-liststore-object-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phastmike%2Fvala-liststore-object-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phastmike","download_url":"https://codeload.github.com/phastmike/vala-liststore-object-example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phastmike%2Fvala-liststore-object-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29922071,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-27T19:37:42.220Z","status":"ssl_error","status_checked_at":"2026-02-27T19:37:41.463Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["example","gobject","treeview","vala"],"created_at":"2025-01-01T22:37:04.596Z","updated_at":"2026-02-28T01:04:30.130Z","avatar_url":"https://github.com/phastmike.png","language":"Vala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A simple liststore example\n\nThe goal behind this example was to show the use of a Treeview with Objects in the model and how to avoid data replication by using the ListStore (could be a treestore) as the only container of references to the data objects. \n\nAs using objects is vague and generic we must map the object fields and/or properties to the treeview columns.\n\n## The Model (ListStore)\n\nThe model is prepared to contain Objects of type SomeObject:\n\n```Vala\nGtk.ListStore list_store = new Gtk.ListStore (1, typeof (SomeObject));\n```\n\nAnd we add a few example instances of SomeObjects:\n\n```Vala\nlist_store.append (out iter);\nlist_store.set (iter, 0, new SomeObject.with_name (\"Joe\"));\nlist_store.append (out iter);\nlist_store.set (iter, 0, new SomeObject.with_name (\"Jane\"));\nlist_store.append (out iter);\nlist_store.set (iter, 0, new SomeObject.with_name (\"Ada\"));\nlist_store.append (out iter);\nlist_store.set (iter, 0, new SomeObject.with_name (\"Jarvis\"));\n```\n\n## Changes to objects in the model\n\nTo change an object, we should retrieve it from the model, do some changes and set the object to the model. To exemplify, we added a toggle button that will change the name of the object, at row 3, from Ada to Megatron and vice versa:\n\n```Vala\nGtk.ToggleButton button = new Gtk.ToggleButton.with_label (\"Change obj at row 3\");\nbutton.toggled.connect (() =\u003e {\n   Gtk.TreeIter niter;\n   SomeObject obj;\n   list_store.get_iter_from_string (out niter, \"2\");\n   list_store.@get (niter, 0, out obj);\n   if (button.active) {\n      obj.name = \"Megatron\";\n   } else {\n      obj.name = \"Ada\";\n   }\n   list_store.@set (niter, 0, obj);\n});\n```\n\n## Map data between the model and the view\n\nTo map data from the object we'll use *data_functions* which allow us to \"bind\" or adapt these fields into the cell renderers:\n\n```Vala\nGtk.CellRendererText cell = new Gtk.CellRendererText ();\nview.insert_column_with_data_func (-1, \"Name\", cell, (column, cell, model, iter) =\u003e { \n   SomeObject obj;\n   model.@get (iter, 0, out obj);\n   (cell as Gtk.CellRendererText).text = obj.name;\n});\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphastmike%2Fvala-liststore-object-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphastmike%2Fvala-liststore-object-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphastmike%2Fvala-liststore-object-example/lists"}