WIP: GtkWidget *my_list_view = gtk_list_view_new (my_string_list, my_factory);
This commit is contained in:
parent
05230b7a64
commit
f158aeb364
|
@ -42,31 +42,16 @@ static void just_use_gtk_application_window_new()
|
||||||
gtk_window_set_default_size (GTK_WINDOW(that_window), 300, 300);
|
gtk_window_set_default_size (GTK_WINDOW(that_window), 300, 300);
|
||||||
gtk_widget_show (that_window);
|
gtk_widget_show (that_window);
|
||||||
|
|
||||||
char *array[] = {"one", "two", "three", "four", NULL};
|
char *array[] = {"one", "two", "three", "four", NULL}; // https://toshiocp.github.io/Gtk4-tutorial/sec29.html
|
||||||
GtkStringList *my_string_list = gtk_string_list_new ((const char * const *) array);
|
GtkStringList *my_string_list = gtk_string_list_new ((const char * const *) array);
|
||||||
|
|
||||||
|
GtkSelectionModel *my_select_model = gtk_single_selection_new (my_string_list); // GtkSingleSelection
|
||||||
|
GtkListItemFactory *my_factory = gtk_signal_list_item_factory_new ();
|
||||||
|
GtkWidget *my_list_view = gtk_list_view_new (my_string_list, my_factory);
|
||||||
|
|
||||||
|
GtkWidget *my_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||||
/* model = GtkStringList(string.(names(Gtk4))) */
|
gtk_window_set_child(GTK_WINDOW(that_window), GTK_WIDGET(my_box));
|
||||||
/* selmodel = GtkSelectionModel(GtkSingleSelection(GListModel(model))) */
|
gtk_box_append(GTK_BOX (my_box), GTK_WIDGET(my_list_view));
|
||||||
|
|
||||||
/* function setup_cb(f, li) */
|
|
||||||
/* set_child(li,GtkLabel("")) */
|
|
||||||
/* end */
|
|
||||||
|
|
||||||
/* function bind_cb(f, li) */
|
|
||||||
/* text = li[].string */
|
|
||||||
/* label = get_child(li) */
|
|
||||||
/* label.label = text */
|
|
||||||
/* end */
|
|
||||||
|
|
||||||
/* factory = GtkSignalListItemFactory(setup_cb, bind_cb) */
|
|
||||||
/* list = GtkListView(selmodel, factory) */
|
|
||||||
|
|
||||||
/* win = GtkWindow("Listview demo", 250, 800) */
|
|
||||||
/* sw = GtkScrolledWindow() */
|
|
||||||
/* win[] = sw */
|
|
||||||
/* sw[] = list */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue