func (window *GhQueuedHighlightsWindow) build() {
	window.SetTitle("Queued Highlights")
	window.bindKeys()

	scrolledWindow := gtk.ScrolledWindow(nil, nil)
	scrolledWindow.SetPolicy(gtk.GTK_POLICY_AUTOMATIC, gtk.GTK_POLICY_AUTOMATIC)

	treeView := gtk.TreeView()
	scrolledWindow.Add(treeView)

	store := gtk.ListStore(glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_DOUBLE, glib.G_TYPE_STRING, glib.G_TYPE_STRING)
	treeView.SetModel(store)

	treeView.AppendColumn(gtk.TreeViewColumnWithAttributes("Book", gtk.CellRendererText(), "text", 0))
	treeView.AppendColumn(gtk.TreeViewColumnWithAttributes("Content", gtk.CellRendererText(), "text", 1))
	treeView.AppendColumn(gtk.TreeViewColumnWithAttributes("Position", gtk.CellRendererText(), "text", 2))
	treeView.AppendColumn(gtk.TreeViewColumnWithAttributes("Timestamp", gtk.CellRendererText(), "text", 3))
	treeView.AppendColumn(gtk.TreeViewColumnWithAttributes("Comment", gtk.CellRendererText(), "text", 4))

	readings := models.Readings()
	highlights := models.Highlights()
	for _, highlight := range highlights.Items {
		var iter gtk.GtkTreeIter
		store.Append(&iter)

		reading := readings.FindByReadmillId(highlight.ReadingReadmillId)
		position := highlight.Position * 100
		timestamp := highlight.Timestamp.Format(time.Stamp)

		store.Set(&iter, reading.Title, highlight.Content, position, timestamp, highlight.Comment)
	}

	window.Add(scrolledWindow)
	window.SetSizeRequest(600, 400)
}
Ejemplo n.º 2
0
func main() {
	gtk.Init(&os.Args)
	window := gtk.Window(gtk.GTK_WINDOW_TOPLEVEL)
	window.SetTitle("GTK Stock Icons")
	window.Connect("destroy", gtk.MainQuit)

	swin := gtk.ScrolledWindow(nil, nil)

	store := gtk.ListStore(glib.G_TYPE_STRING, glib.G_TYPE_BOOL, gdkpixbuf.GetGdkPixbufType())
	treeview := gtk.TreeView()
	swin.Add(treeview)

	treeview.SetModel(store.ToTreeModel())
	treeview.AppendColumn(gtk.TreeViewColumnWithAttributes("name", gtk.CellRendererText(), "text", 0))
	treeview.AppendColumn(gtk.TreeViewColumnWithAttributes("check", gtk.CellRendererToggle(), "active", 1))
	treeview.AppendColumn(gtk.TreeViewColumnWithAttributes("icon", gtk.CellRendererPixbuf(), "pixbuf", 2))
	n := 0
	gtk.GtkStockListIDs().ForEach(func(d interface{}, v interface{}) {
		id := glib.GPtrToString(d)
		var iter gtk.GtkTreeIter
		store.Append(&iter)
		store.Set(&iter, id, (n == 1), gtk.Image().RenderIcon(id, gtk.GTK_ICON_SIZE_SMALL_TOOLBAR, "").Pixbuf)
		n = 1 - n
	})

	window.Add(swin)
	window.SetSizeRequest(400, 200)
	window.ShowAll()

	gtk.Main()
}
Ejemplo n.º 3
0
func main() {
	gtk.Init(&os.Args)
	window := gtk.Window(gtk.GTK_WINDOW_TOPLEVEL)
	window.SetTitle("GTK Folder View")
	window.Connect("destroy", gtk.MainQuit)

	swin := gtk.ScrolledWindow(nil, nil)

	store := gtk.TreeStore(gdkpixbuf.GetGdkPixbufType(), glib.G_TYPE_STRING)
	treeview := gtk.TreeView()
	swin.Add(treeview)

	treeview.SetModel(store.ToTreeModel())
	treeview.AppendColumn(gtk.TreeViewColumnWithAttributes("pixbuf", gtk.CellRendererPixbuf(), "pixbuf", 0))
	treeview.AppendColumn(gtk.TreeViewColumnWithAttributes("text", gtk.CellRendererText(), "text", 1))

	for n := 1; n <= 10; n++ {
		var iter1, iter2, iter3 gtk.GtkTreeIter
		store.Append(&iter1, nil)
		store.Set(&iter1, gtk.Image().RenderIcon(gtk.GTK_STOCK_DIRECTORY, gtk.GTK_ICON_SIZE_SMALL_TOOLBAR, "").Pixbuf, "Folder"+strconv.Itoa(n))
		store.Append(&iter2, &iter1)
		store.Set(&iter2, gtk.Image().RenderIcon(gtk.GTK_STOCK_DIRECTORY, gtk.GTK_ICON_SIZE_SMALL_TOOLBAR, "").Pixbuf, "SubFolder"+strconv.Itoa(n))
		store.Append(&iter3, &iter2)
		store.Set(&iter3, gtk.Image().RenderIcon(gtk.GTK_STOCK_FILE, gtk.GTK_ICON_SIZE_SMALL_TOOLBAR, "").Pixbuf, "File"+strconv.Itoa(n))
	}

	treeview.Connect("row_activated", func() {
		var path *gtk.GtkTreePath
		var column *gtk.GtkTreeViewColumn
		treeview.GetCursor(&path, &column)
		mes := "TreePath is: " + path.String()
		dialog := gtk.MessageDialog(
			treeview.GetTopLevelAsWindow(),
			gtk.GTK_DIALOG_MODAL,
			gtk.GTK_MESSAGE_INFO,
			gtk.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()
}
Ejemplo n.º 4
0
func (v *SearchView) Init() {
	v.store = gtk.TreeStore(gtk.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.TreeViewColumnWithAttributes("",
		gtk.CellRendererText(), "text", 0))
	v.view.SetHeadersVisible(false)
	v.view.Connect("cursor-changed", func() { v.Select() }, nil)
	v.window = gtk.ScrolledWindow(nil, nil)
	v.window.SetPolicy(gtk.GTK_POLICY_AUTOMATIC, gtk.GTK_POLICY_AUTOMATIC)
	v.window.Add(v.view)
	v.window.SetVisible(opt.show_search)
}
Ejemplo n.º 5
0
// 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.AccelGroup()
	}
	inotify_dlg := gtk.Dialog()
	defer inotify_dlg.Destroy()
	inotify_dlg.SetTitle("Some files have beed modified outside of tabby")
	inotify_dlg.AddButton("_Reload all", int(gtk.GTK_RESPONSE_ACCEPT))
	inotify_dlg.AddButton("_Keep all as is", int(gtk.GTK_RESPONSE_CANCEL))
	w := inotify_dlg.GetWidgetForResponse(int(gtk.GTK_RESPONSE_ACCEPT))
	inotify_dlg.AddAccelGroup(accel_group)
	w.AddAccelerator("clicked", accel_group, gdk.GDK_KEY_Return,
		0, gtk.GTK_ACCEL_VISIBLE)
	inotify_dlg.SetSizeRequest(800, 350)
	inotify_store := gtk.TreeStore(gtk.GTK_TYPE_STRING)
	inotify_view := gtk.TreeView()
	inotify_view.AppendColumn(
		gtk.TreeViewColumnWithAttributes("text", gtk.CellRendererText(), "text", 0))
	inotify_view.ModifyFontEasy("Regular 8")
	inotify_model := inotify_store.ToTreeModel()
	inotify_view.SetModel(inotify_model)
	inotify_view.SetHeadersVisible(false)
	var iter gtk.GtkTreeIter
	for name, _ := range s {
		inotify_store.Append(&iter, nil)
		inotify_store.Set(&iter, name)
	}
	inotify_view.SetVisible(true)
	view_window := gtk.ScrolledWindow(nil, nil)
	view_window.SetPolicy(gtk.GTK_POLICY_AUTOMATIC, gtk.GTK_POLICY_AUTOMATIC)
	view_window.SetVisible(true)
	view_window.Add(inotify_view)
	vbox := inotify_dlg.GetVBox()
	vbox.Add(view_window)
	if int(gtk.GTK_RESPONSE_ACCEPT) == inotify_dlg.Run() {
		return true
	}
	return false
}