コード例 #1
0
ファイル: tree_view.go プロジェクト: mattn/tabby
// Sets cur_iter pointing to tree_store node corresponding to current file.
// Requires properly set cur_file.
func tree_view_set_cur_iter(mark bool) {
	if "" == cur_file {
		return
	}
	var parent gtk.GtkTreeIter
	name := cur_file
	tree_model.GetIterFirst(&cur_iter)
	for {
		var val glib.GValue
		tree_model.GetValue(&cur_iter, 0, &val)
		whole_string := val.GetString()
		cur_str := whole_string[1:]
		pos := slashed_prefix(name, cur_str)
		if pos > 0 {
			if mark {
				tree_store.Set(&cur_iter, strings.ToUpper(whole_string[:1])+cur_str)
			} else {
				tree_store.Set(&cur_iter, strings.ToLower(whole_string[:1])+cur_str)
			}
			if pos == len(name) {
				break
			}
			parent.Assign(&cur_iter)
			tree_model.IterChildren(&cur_iter, &parent)
			name = name[pos:]
		} else {
			tree_model.IterNext(&cur_iter)
		}
	}
}
コード例 #2
0
ファイル: tree_view.go プロジェクト: mattn/tabby
func tree_view_get_selected_path(tree_view *gtk.GtkTreeView, tree_model *gtk.GtkTreeModel, col int, shift bool) string {
	var path *gtk.GtkTreePath
	var column *gtk.GtkTreeViewColumn
	tree_view.GetCursor(&path, &column)
	if nil == path.TreePath {
		return ""
	}
	var iter gtk.GtkTreeIter
	tree_model.GetIterFromString(&iter, path.String())
	var ans string
	ans = ""
	for {
		var val glib.GValue
		var next gtk.GtkTreeIter
		tree_model.GetValue(&iter, col, &val)
		if shift {
			ans = val.GetString()[1:] + ans
		} else {
			ans = val.GetString() + ans
		}
		if false == tree_model.IterParent(&next, &iter) {
			break
		}
		iter.Assign(&next)
	}
	return ans
}