Beispiel #1
0
// SelectedValue returns the liststore row value for the selected line as converter.
//
func SelectedValue(model *gtk.ListStore, selection *gtk.TreeSelection, row int) Conv {
	iter, e := SelectedIter(model, selection)
	if e != nil {
		return Conv{err: e}
	}
	return New(model.GetValue(iter, row))
}
// Append a row to the list store for the tree view
func addRow(listStore *gtk.ListStore, version, feature string) {
	// Get an iterator for a new row at the end of the list store
	iter := listStore.Append()

	// Set the contents of the list store row that the iterator represents
	err := listStore.Set(iter,
		[]int{COLUMN_VERSION, COLUMN_FEATURE},
		[]interface{}{version, feature})

	if err != nil {
		log.Fatal("Unable to add row:", err)
	}
}
Beispiel #3
0
// getActiveRowInCombo gets the value of the current RowKey in the store.
//
func getActiveRowInCombo(model *gtk.ListStore, iter *gtk.TreeIter) (string, error) {
	if iter == nil {
		return "", errors.New("getActiveRowInCombo: no selection")
	}
	str, e := gunvalue.New(model.GetValue(iter, RowKey)).String()
	if e != nil {
		return "", e
	}

	// if (cValue == NULL && GTK_IS_COMBO_BOX (pOneWidget) && gtk_combo_box_get_has_entry (GTK_COMBO_BOX (pOneWidget)))
	// {
	// 	GtkWidget *pEntry = gtk_bin_get_child (GTK_BIN (pOneWidget));
	// 	cValue = g_strdup (gtk_entry_get_text (GTK_ENTRY (pEntry)));
	// }
	return str, nil
}
Beispiel #4
0
// modelAddField adds one field to the model and can save reference of fields+iter.
//
func modelAddField(key *cftype.Key, model *gtk.ListStore, field datatype.Field, ro indexiter.ByString) *gtk.TreeIter {
	iter := model.Append()
	model.SetCols(iter, gtk.Cols{
		RowKey:  field.Key,
		RowName: field.Name,
		RowDesc: "none",
	})
	if field.Icon != "" {
		pix, e := common.PixbufNewFromFile(field.Icon, iconSizeCombo)
		if !key.Log().Err(e, "Load icon") {
			model.SetValue(iter, RowIcon, pix)
		}
	}

	if ro != nil {
		ro.Append(iter, field.Key)
	}
	return iter
}
Beispiel #5
0
func valAt(s *gtk.ListStore, iter *gtk.TreeIter, col int) interface{} {
	gv, _ := s.GetValue(iter, col)
	vv, _ := gv.GoValue()
	return vv
}