本文整理汇总了Golang中github.com/mattn/go-gtk/glib.GValue.GetString方法的典型用法代码示例。如果您正苦于以下问题:Golang GValue.GetString方法的具体用法?Golang GValue.GetString怎么用?Golang GValue.GetString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/mattn/go-gtk/glib.GValue
的用法示例。
在下文中一共展示了GValue.GetString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: tree_view_set_cur_iter
// 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: tree_view_set_cur_iter
// Sets cur_iter pointing to tree_store node corresponding to current file.
// Requires properly set cur_file. As a side effect it also assigns correct
// capitalization for first letters of strings kept in nodes according to @mark
// which denotes if current file is active or not.
func tree_view_set_cur_iter(mark bool) {
if "" == cur_file {
return
}
var parent gtk.TreeIter
cur_file_suffix := cur_file
tree_model.GetIterFirst(&cur_iter)
for {
var gval glib.GValue
tree_model.GetValue(&cur_iter, 0, &gval)
gval_string := gval.GetString()
icon := gval_string[0]
node_path := gval_string[1:]
if pos := slashed_prefix(cur_file_suffix, node_path); pos > 0 {
if mark {
tree_store.Set(&cur_iter, strings.ToUpper(string(icon))+node_path)
} else {
tree_store.Set(&cur_iter, strings.ToLower(string(icon))+node_path)
}
if pos == len(cur_file_suffix) {
break
}
parent.Assign(&cur_iter)
tree_model.IterChildren(&cur_iter, &parent)
cur_file_suffix = cur_file_suffix[pos:]
} else {
tree_model.IterNext(&cur_iter)
}
}
}
示例3: tree_view_get_selected_path
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
}
示例4: refresh_title
func refresh_title() {
if "" == cur_file {
main_window.SetTitle("*")
return
}
var icon byte
if source_buf.GetModified() {
main_window.SetTitle("* " + cur_file)
icon = 'C'
} else {
main_window.SetTitle(cur_file)
icon = 'B'
}
var val glib.GValue
tree_model.GetValue(&cur_iter, 0, &val)
tree_store.Set(&cur_iter, string(icon)+val.GetString()[1:])
}
示例5: buildList
func (g *Gui) buildList(vbox *gtk.VBox) {
frame := gtk.NewFrame("Device List")
framebox := gtk.NewVBox(false, 1)
frame.Add(framebox)
vbox.Add(frame)
g.Status = gtk.NewStatusbar()
vbox.PackStart(g.Status, false, false, 0)
g.Store = gtk.NewListStore(glib.G_TYPE_STRING, glib.G_TYPE_STRING)
treeview := gtk.NewTreeView()
framebox.Add(treeview)
treeview.SetModel(g.Store)
treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("Device", gtk.NewCellRendererText(), "text", 0))
treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("Name", gtk.NewCellRendererText(), "text", 1))
treeview.GetSelection().SetMode(gtk.SELECTION_SINGLE)
controls := gtk.NewHBox(true, 0)
g.Start = gtk.NewButtonWithLabel("Start Sync")
g.Start.Clicked(func() {
var iter gtk.TreeIter
var device glib.GValue
selection := treeview.GetSelection()
if selection.CountSelectedRows() > 0 {
selection.GetSelected(&iter)
g.Store.GetValue(&iter, 0, &device)
MainGui.notify("Start Writing On: " + device.GetString())
doWrite(device.GetString())
} else {
MainGui.notify("No Active Selection")
}
})
controls.Add(g.Start)
g.Recheck = gtk.NewButtonWithLabel("Rescan")
g.Recheck.Clicked(func() {
devices := SearchValid()
MainGui.Store.Clear()
for _, x := range devices {
MainGui.appendItem("/dev/hidraw"+strconv.FormatUint(x.SeqNum(), 10), x.SysAttrValue("product"))
}
MainGui.notify("Scanning Done")
})
controls.Add(g.Recheck)
framebox.PackStart(controls, false, false, 0)
}