func main() { gtk3.Init() var infoBuf, sourceBuf *gtk3.TextBuffer window := gtk3.NewWindow(gtk3.GtkWindowType.TOPLEVEL) window.SetTitle("Gtk+ Code Demos") window.Connect("destroy", gtk3.MainQuit) hbox := gtk3.NewHBox(0) window.Add(hbox) // Create tree tree := CreateTree() hbox.PackStart(tree, false, false, 0) notebook := gtk3.NewNotebook() hbox.PackStart(notebook, true, true, 0) notebook.AppendPage(CreateText(&infoBuf, false), gtk3.NewLabelWithMnemonic("_Info")) infoBuf.CreateTag("title", gtk3.P{"font": "Sans 18"}) notebook.AppendPage(CreateText(&sourceBuf, true), gtk3.NewLabelWithMnemonic("_Source")) sourceBuf.CreateTag("comment", gtk3.P{"foreground": "DodgerBlue"}) window.SetDefaultSize(600, 400) window.ShowAll() gtk3.Main() }
func createTags(buffer *gtk3.TextBuffer) { buffer.CreateTag("heading", gtk3.P{"weight": pango.PangoWeight.BOLD, "size": 15 * pango.PangoScale.Scale}) buffer.CreateTag("italic", gtk3.P{"style": pango.PangoStyle.ITALIC}) buffer.CreateTag("bold", gtk3.P{"weight": pango.PangoWeight.BOLD}) buffer.CreateTag("big", gtk3.P{"size": 20 * pango.PangoScale.Scale}) buffer.CreateTag("xx-small", gtk3.P{"scale": pango.PangoScale.XX_SMALL}) buffer.CreateTag("x-large", gtk3.P{"scale": pango.PangoScale.X_LARGE}) buffer.CreateTag("monospace", gtk3.P{"family": "monospace"}) buffer.CreateTag("blue_foreground", gtk3.P{"foreground": "blue"}) buffer.CreateTag("red_background", gtk3.P{"background": "red"}) buffer.CreateTag("big_gap_before_line", gtk3.P{"pixels_above_lines": 30}) buffer.CreateTag("big_gap_after_line", gtk3.P{"pixels_below_lines": 30}) buffer.CreateTag("double_spaced_line", gtk3.P{"pixels_inside_wrap": 10}) buffer.CreateTag("not_editable", gtk3.P{"editable": false}) buffer.CreateTag("word_wrap", gtk3.P{"wrap_mode": gtk3.GtkWrapMode.WORD}) buffer.CreateTag("char_wrap", gtk3.P{"wrap_mode": gtk3.GtkWrapMode.CHAR}) buffer.CreateTag("no_wrap", gtk3.P{"wrap_mode": gtk3.GtkWrapMode.NONE}) buffer.CreateTag("center", gtk3.P{"justification": gtk3.GtkJustification.CENTER}) buffer.CreateTag("right_justify", gtk3.P{"justification": gtk3.GtkJustification.RIGHT}) buffer.CreateTag("wide_margins", gtk3.P{"left_margin": 50, "right_margin": 50}) buffer.CreateTag("strikethrough", gtk3.P{"strikethrough": true}) buffer.CreateTag("underline", gtk3.P{"underline": pango.PangoUnderline.SINGLE}) buffer.CreateTag("double_underline", gtk3.P{"underline": pango.PangoUnderline.DOUBLE}) buffer.CreateTag("superscript", gtk3.P{"rise": 10 * pango.PangoScale.Scale, "size": 8 * pango.PangoScale.Scale}) buffer.CreateTag("subscript", gtk3.P{"rise": -10 * pango.PangoScale.Scale, "size": 8 * pango.PangoScale.Scale}) buffer.CreateTag("rtl_quote", gtk3.P{"wrap_mode": gtk3.GtkWrapMode.WORD, "direction": gtk3.GtkTextDirection.RTL, "indent": 30, "left_margin": 20, "right_margin": 20}) }