func newBiomeList() *biomeList { bl := &biomeList{ HBox: gtk.NewHBox(false, 0), treeview: gtk.NewTreeView(), lStore: gtk.NewListStore(glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_STRING), addBtn: gtk.NewButton(), delBtn: gtk.NewButton(), upBtn: gtk.NewButton(), downBtn: gtk.NewButton(), } scroll := gtk.NewScrolledWindow(nil, nil) scroll.SetPolicy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) scroll.Add(bl.treeview) bl.PackStart(scroll, true, true, 3) bl.treeview.SetModel(bl.lStore) bl.treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("Color", gtk.NewCellRendererText(), "background", 0)) bl.treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("ID", gtk.NewCellRendererText(), "text", 1)) bl.treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("Snowline", gtk.NewCellRendererText(), "text", 2)) bl.treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("Name", gtk.NewCellRendererText(), "text", 3)) bl.treeview.GetSelection().SetMode(gtk.SELECTION_SINGLE) bl.treeview.Connect("cursor-changed", bl.onCursorChanged) vbox := gtk.NewVBox(false, 0) bl.addBtn.Add(gtk.NewImageFromStock(gtk.STOCK_ADD, gtk.ICON_SIZE_SMALL_TOOLBAR)) bl.delBtn.Add(gtk.NewImageFromStock(gtk.STOCK_DELETE, gtk.ICON_SIZE_SMALL_TOOLBAR)) bl.upBtn.Add(gtk.NewImageFromStock(gtk.STOCK_GO_UP, gtk.ICON_SIZE_SMALL_TOOLBAR)) bl.downBtn.Add(gtk.NewImageFromStock(gtk.STOCK_GO_DOWN, gtk.ICON_SIZE_SMALL_TOOLBAR)) bl.addBtn.Connect("clicked", bl.onAdd) bl.delBtn.Connect("clicked", bl.onDel) bl.upBtn.Connect("clicked", bl.onUp) bl.downBtn.Connect("clicked", bl.onDown) bl.delBtn.SetSensitive(false) bl.upBtn.SetSensitive(false) bl.downBtn.SetSensitive(false) vbox.PackStart(bl.addBtn, false, false, 3) vbox.PackStart(bl.delBtn, false, false, 3) vbox.PackStart(bl.upBtn, false, false, 3) vbox.PackStart(bl.downBtn, false, false, 3) bl.PackStart(vbox, false, false, 0) return bl }
func main() { gtk.Init(&os.Args) window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL) window.SetTitle("GTK Stock Icons") window.Connect("destroy", gtk.MainQuit) swin := gtk.NewScrolledWindow(nil, nil) store := gtk.NewListStore(glib.G_TYPE_STRING, glib.G_TYPE_BOOL, gdkpixbuf.GetGdkPixbufType()) treeview := gtk.NewTreeView() swin.Add(treeview) treeview.SetModel(store) treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("name", gtk.NewCellRendererText(), "text", 0)) treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("check", gtk.NewCellRendererToggle(), "active", 1)) treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("icon", gtk.NewCellRendererPixbuf(), "pixbuf", 2)) n := 0 gtk.StockListIDs().ForEach(func(d interface{}, v interface{}) { id := glib.GPtrToString(d) var iter gtk.TreeIter store.Append(&iter) store.Set(&iter, id, (n == 1), gtk.NewImage().RenderIcon(id, gtk.ICON_SIZE_SMALL_TOOLBAR, "").Pixbuf) n = 1 - n }) window.Add(swin) window.SetSizeRequest(400, 200) window.ShowAll() gtk.Main() }
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) }
func main() { gtk.Init(&os.Args) window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL) window.SetTitle("GTK Folder View") window.Connect("destroy", gtk.MainQuit) swin := gtk.NewScrolledWindow(nil, nil) store := gtk.NewTreeStore(gdkpixbuf.GetGdkPixbufType(), glib.G_TYPE_STRING) treeview := gtk.NewTreeView() swin.Add(treeview) treeview.SetModel(store.ToTreeModel()) treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("pixbuf", gtk.NewCellRendererPixbuf(), "pixbuf", 0)) treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("text", gtk.NewCellRendererText(), "text", 1)) for n := 1; n <= 10; n++ { var iter1, iter2, iter3 gtk.TreeIter store.Append(&iter1, nil) store.Set(&iter1, gtk.NewImage().RenderIcon(gtk.STOCK_DIRECTORY, gtk.ICON_SIZE_SMALL_TOOLBAR, "").Pixbuf, "Folder"+strconv.Itoa(n)) store.Append(&iter2, &iter1) store.Set(&iter2, gtk.NewImage().RenderIcon(gtk.STOCK_DIRECTORY, gtk.ICON_SIZE_SMALL_TOOLBAR, "").Pixbuf, "SubFolder"+strconv.Itoa(n)) store.Append(&iter3, &iter2) store.Set(&iter3, gtk.NewImage().RenderIcon(gtk.STOCK_FILE, gtk.ICON_SIZE_SMALL_TOOLBAR, "").Pixbuf, "File"+strconv.Itoa(n)) } treeview.Connect("row_activated", func() { var path *gtk.TreePath var column *gtk.TreeViewColumn treeview.GetCursor(&path, &column) mes := "TreePath is: " + path.String() dialog := gtk.NewMessageDialog( treeview.GetTopLevelAsWindow(), gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, mes) dialog.SetTitle("TreePath") dialog.Response(func() { dialog.Destroy() }) dialog.Run() }) window.Add(swin) window.SetSizeRequest(400, 200) window.ShowAll() gtk.Main() }
func (v *SearchView) Init() { v.store = gtk.NewTreeStore(gtk.TYPE_STRING) v.view = file_tree.NewSearchTree() v.view.ModifyFontEasy("Regular 8") v.model = v.store.ToTreeModel() v.view.SetModel(v.model) v.view.AppendColumn(gtk.NewTreeViewColumnWithAttributes("", gtk.NewCellRendererText(), "text", 0)) v.view.SetHeadersVisible(false) v.view.Connect("cursor-changed", func() { v.Select() }, nil) v.window = gtk.NewScrolledWindow(nil, nil) v.window.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) v.window.Add(v.view) v.window.SetVisible(opt.show_search) }
func guiMain(ch <-chan Accounts) { glib.ThreadInit(nil) gdk.ThreadsInit() gdk.ThreadsEnter() gtk.Init(&os.Args) window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL) window.SetPosition(gtk.WIN_POS_CENTER) window.SetTitle("password") window.Connect("destroy", gtk.MainQuit) entry := gtk.NewEntry() store := gtk.NewListStore(glib.G_TYPE_STRING) treeview := gtk.NewTreeView() treeview.SetModel(store) // treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("icon", gtk.NewCellRendererPixbuf(), "pixbuf", 0)) treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("name", gtk.NewCellRendererText(), "text", 0)) go func() { for accounts := range ch { gthread(func() { store.Clear() for _, a := range accounts { var iter gtk.TreeIter store.Append(&iter) store.Set(&iter, 0, a.Name) } }) } }() swin := gtk.NewScrolledWindow(nil, nil) swin.Add(treeview) vbox := gtk.NewVBox(false, 0) vbox.PackStart(entry, false, false, 1) vbox.PackStart(swin, true, true, 0) window.Add(vbox) window.SetSizeRequest(460, 640) window.SetResizable(false) window.ShowAll() }
// Returns true in case of reloading files, and false in case of keeping as is. func inotify_dialog(s map[string]int) bool { if nil == accel_group { accel_group = gtk.NewAccelGroup() } inotify_dlg := gtk.NewDialog() defer inotify_dlg.Destroy() inotify_dlg.SetTitle("Some files have beed modified outside of tabby") inotify_dlg.AddButton("_Reload all", gtk.RESPONSE_ACCEPT) inotify_dlg.AddButton("_Keep all as is", gtk.RESPONSE_CANCEL) w := inotify_dlg.GetWidgetForResponse(int(gtk.RESPONSE_ACCEPT)) inotify_dlg.AddAccelGroup(accel_group) w.AddAccelerator("clicked", accel_group, gdk.KEY_Return, 0, gtk.ACCEL_VISIBLE) inotify_dlg.SetSizeRequest(800, 350) inotify_store := gtk.NewTreeStore(gtk.TYPE_STRING) inotify_view := gtk.NewTreeView() inotify_view.AppendColumn( gtk.NewTreeViewColumnWithAttributes("text", gtk.NewCellRendererText(), "text", 0)) inotify_view.ModifyFontEasy("Regular 8") inotify_model := inotify_store.ToTreeModel() inotify_view.SetModel(inotify_model) inotify_view.SetHeadersVisible(false) var iter gtk.TreeIter for name, _ := range s { inotify_store.Append(&iter, nil) inotify_store.Set(&iter, name) } inotify_view.SetVisible(true) view_window := gtk.NewScrolledWindow(nil, nil) view_window.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) view_window.SetVisible(true) view_window.Add(inotify_view) vbox := inotify_dlg.GetVBox() vbox.Add(view_window) if gtk.RESPONSE_ACCEPT == inotify_dlg.Run() { return true } return false }