예제 #1
0
파일: main.go 프로젝트: pavben/InstantShare
func main() {
	flag.Parse()

	menuItems := []trayhost.MenuItem{
		{
			Title:   "Instant Share",
			Enabled: instantShareEnabled,
			Handler: instantShareHandler,
		},
		trayhost.SeparatorMenuItem(),
		{
			Title:   "Quit",
			Handler: trayhost.Exit,
		},
	}
	if *debugFlag {
		menuItems = append(menuItems, trayhost.SeparatorMenuItem())
		menuItems = append(menuItems, debugMenuItems()...)
	}

	// NOTE: Optionally, if non-Retina pixel perfection is required, generate or load 1x image and supply that as a second representation.
	iconData, err := ioutil.ReadFile("*****@*****.**")
	if err != nil {
		panic(err)
	}

	log.Println("Starting.")

	trayhost.Initialize("Instant Share", iconData, menuItems)

	trayhost.EnterLoop()

	log.Println("Exiting.")
}
예제 #2
0
파일: main.go 프로젝트: tnhu/InstantShare
func main() {
	flag.Parse()
	runtime.LockOSThread()

	menuItems := []trayhost.MenuItem{
		trayhost.MenuItem{
			Title:   "Instant Share",
			Enabled: instantShareEnabled,
			Handler: instantShareHandler,
		},
		trayhost.SeparatorMenuItem(),
		trayhost.MenuItem{
			Title:   "Quit",
			Handler: trayhost.Exit,
		},
	}
	if *debugFlag {
		menuItems = append(menuItems,
			trayhost.SeparatorMenuItem(),
			trayhost.MenuItem{
				Title: "Debug: Get Clipboard Content",
				Handler: func() {
					cc, err := trayhost.GetClipboardContent()
					fmt.Printf("GetClipboardContent() error: %v\n", err)
					fmt.Printf("Text: %q\n", cc.Text)
					fmt.Printf("Image: %v len(%v)\n", cc.Image.Kind, len(cc.Image.Bytes))
					fmt.Printf("Files: len(%v) %v\n", len(cc.Files), cc.Files)
				},
			},
			trayhost.MenuItem{
				Title: "Debug: Set Clipboard Text",
				Handler: func() {
					trayhost.SetClipboardText("http://www.example.com/image.png")
				},
			},
			trayhost.MenuItem{
				Title: "Debug: Notification",
				Handler: func() {
					handler := func() {
						u4.Open("http://www.example.com/image.png")
					}
					notification := trayhost.Notification{Title: "Success", Body: "http://www.example.com/image.png", Timeout: 3 * time.Second, Handler: handler}
					//trayhost.Notification{Title: "Upload Failed", Body: "error description goes here"}.Display()
					if cc, err := trayhost.GetClipboardContent(); err == nil && cc.Image.Kind != "" {
						notification.Image = cc.Image
					}
					notification.Display()
				},
			},
		)
	}

	// TODO: Create a real icon and bake it into the binary.
	// TODO: Optionally, if non-Retina pixel perfection is required, generate or load 1x image and supply that as a second representation.
	iconData, err := ioutil.ReadFile("./[email protected]")
	if err != nil {
		panic(err)
	}

	fmt.Println("Starting.")

	trayhost.Initialize("Instant Share", iconData, menuItems)

	trayhost.EnterLoop()

	fmt.Println("Exiting.")
}