示例#1
0
func createStockIconStore() gtk3.TreeModelLike {
	stockId := []string{gtk3.GtkStock.DIALOG_WARNING, gtk3.GtkStock.STOP,
		gtk3.GtkStock.NEW, gtk3.GtkStock.CLEAR, "", gtk3.GtkStock.OPEN}

	cellView := gtk3.NewCellView()
	store := gtk3.NewListStore([]gobject.GType{gp.G_TYPE_PIXBUF, gobject.G_TYPE_STRING})

	var iter gtk3.TreeIter

	for _, s := range stockId {
		if s != "" {
			pixbuf := cellView.RenderIconPixbuf(s, gtk3.GtkIconSize.BUTTON)
			_, stockItem := gtk3.StockLookup(s)

			label := strings.Map(func(in rune) rune {
				if in == rune('_') {
					return rune(-1)
				}
				return in
			}, stockItem.Label)

			store.Append(&iter)
			store.SetValues(&iter, gtk3.V{PixbufCol: pixbuf, TextCol: label})
		} else {
			store.Append(&iter)
			store.SetValues(&iter, gtk3.V{PixbufCol: nil, TextCol: "seperator"})
		}
	}
	return store
}
示例#2
0
func createModel() *gtk3.ListStore {
	store := gtk3.NewListStore([]gobject.GType{gobject.G_TYPE_BOOLEAN,
		gobject.G_TYPE_UINT,
		gobject.G_TYPE_STRING,
		gobject.G_TYPE_STRING,
		gobject.G_TYPE_UINT,
		gobject.G_TYPE_STRING,
		gobject.G_TYPE_BOOLEAN,
		gobject.G_TYPE_BOOLEAN})

	// Add data to list store
	var icon_name string
	var sensitive bool

	var iter gtk3.TreeIter

	for i, bug := range Bugs {
		if i == 1 || i == 3 {
			icon_name = "battery-caution-charging-symbolic"
		} else {
			icon_name = ""
		}

		if i == 3 {
			sensitive = false
		} else {
			sensitive = true
		}

		store.Append(&iter)
		store.SetValues(&iter, gtk3.V{ColumnFixed: bug.Fixed,
			ColumnNumber:      bug.Number,
			ColumnSeverity:    bug.Severity,
			ColumnDescription: bug.Description,
			ColumnPulse:       uint(0),
			ColumnIcon:        icon_name,
			ColumnActive:      false,
			ColumnSensitive:   sensitive})

	}

	return store
}