// Load the icon image data from file:
func initIcons() error {
	iconPath := os.Getenv(envIconPathKey)
	if len(iconPath) == 0 {
		log.Fatal("Missing Environment variable ", envIconPathKey)
	}
	var err error
	imageOK, err = gdk.PixbufNewFromFile(fmt.Sprintf("%s/green.png", iconPath))
	if err != nil {
		log.Fatal("Unable to load image:", err)
	}
	imageFAIL, err = gdk.PixbufNewFromFile(fmt.Sprintf("%s/red.png", iconPath))
	if err != nil {
		log.Fatal("Unable to load image:", err)
	}
	return nil
}
Example #2
0
func normalInit(iconPath string, config symbolConfig) (img *gdk.Pixbuf, err error) {
	switch imageMethod {
	case gdkReadFile:
		img, err = gdk.PixbufNewFromFile(fmt.Sprintf("%s/%s", iconPath, config.filename))
	case ioReadFile:
		var file *os.File
		file, err = os.Open(fmt.Sprintf("%s/%s", iconPath, config.filename))
		if err != nil {
			return
		}
		defer file.Close()
		var decImg image.Image
		decImg, _, err = image.Decode(file)
		if err != nil {
			err = fmt.Errorf("readonlyInit error: image.Decode failed: %s", err)
			return
		}
		//img, err = gdk.PixbufNewFromBytes(ImageRgbaToGdkColorspace(decImg))
		_ = decImg
		if err != nil {
			err = fmt.Errorf("readonlyInit error: PixbufNewFromBytes failed: %s", err)
		}
	default:
	}
	return
}
Example #3
0
func MenuAboutInit(menu *GoAppMenu) {
	menu.aboutAbout.Connect("activate", func() { aboutAbout(menu) })
	menu.aboutHelp.Connect("activate", func() { aboutHelp(menu) })

	menu.aboutdialog, _ = gtk.AboutDialogNew()
	menu.aboutdialog.SetCopyright("Copyright (C) 2015 by Axel von Blomberg. All rights reserved.")
	menu.aboutdialog.SetLicenseType(gtk.LICENSE_BSD)
	menu.aboutdialog.SetAuthors([]string{"Axel von Blomberg"})
	menu.aboutdialog.SetProgramName("sge (Signal Graph Editor)")
	iconPath := os.Getenv("SGE_ICON_PATH")
	if len(iconPath) > 0 {
		imageLogo, err := gdk.PixbufNewFromFile(fmt.Sprintf("%s/sge-logo-small.png", iconPath))
		if err == nil {
			menu.aboutdialog.SetLogo(imageLogo)
		}
	}
}
Example #4
0
// SetPackage fills the handbook data with a package.
//
func (widget *Handbook) SetPackage(book datatype.Handbooker) {
	title := common.Bold(common.Big(book.GetTitle()))
	if widget.ShowVersion {
		title += " v" + book.GetModuleVersion()
	}
	widget.title.SetMarkup(title)

	author := book.GetAuthor()
	if author != "" {
		author = fmt.Sprintf("by %s", author)
		widget.author.SetMarkup(common.Small(common.Mono(author)))
	}
	widget.author.SetVisible(author != "")

	widget.description.SetMarkup("<span rise='8000'>" + book.GetDescription() + "</span>")

	previewFound := false
	defer func() { widget.previewFrame.SetVisible(previewFound) }()

	file := book.GetPreviewFilePath()
	if file == "" {
		return
	}
	_, w, h := gdk.PixbufGetFileInfo(file)

	var pixbuf *gdk.Pixbuf
	var e error
	if w > PreviewSizeMax || h > PreviewSizeMax {
		pixbuf, e = gdk.PixbufNewFromFileAtScale(file, PreviewSizeMax, PreviewSizeMax, true)
	} else {
		pixbuf, e = gdk.PixbufNewFromFile(file)
	}

	if e == nil && pixbuf != nil {
		previewFound = true
		widget.previewImage.SetFromPixbuf(pixbuf)
	}
}