Exemple #1
0
// NewActionMenu creates a new action menu button.
func NewActionMenu() *ActionMenu {
	mb, _ := gtk.MenuButtonNew()
	menu, _ := gtk.MenuNew()
	menu.SetHAlign(gtk.ALIGN_END)

	newTab, _ := gtk.MenuItemNewWithLabel("New tab")
	menu.Append(newTab)
	newTab.Show()

	sep, _ := gtk.SeparatorMenuItemNew()
	menu.Append(sep)
	sep.Show()

	downloads, _ := gtk.MenuItemNewWithLabel("Downloads (TODO)")
	menu.Append(downloads)
	downloads.Show()

	favorites, _ := gtk.MenuItemNewWithLabel("Manage favorites (TODO)")
	menu.Append(favorites)
	favorites.Show()

	settings, _ := gtk.MenuItemNewWithLabel("Settings (TODO)")
	menu.Append(settings)
	settings.Show()

	sep, _ = gtk.SeparatorMenuItemNew()
	menu.Append(sep)
	sep.Show()

	restart, _ := gtk.MenuItemNewWithLabel("Restart (TODO)")
	menu.Append(restart)
	restart.Show()

	quit, _ := gtk.MenuItemNewWithLabel("Quit")
	menu.Append(quit)
	quit.Show()

	mb.SetPopup(menu)
	menu.Show()

	return &ActionMenu{
		MenuButton: mb,
		newTab:     newTab,
		downloads:  downloads,
		favorites:  favorites,
		settings:   settings,
		restart:    restart,
		quit:       quit,
	}
}
Exemple #2
0
func createSettingsMenu() *gtk.MenuItem {
	menu, err := gtk.MenuItemNewWithMnemonic("_Settings")
	if err != nil {
		log.Fatal(err)
	}
	dropdown, err := gtk.MenuNew()
	if err != nil {
		log.Fatal(err)
	}
	menu.SetSubmenu(dropdown)

	// TODO(jrick): Dialog will be shown on first start and cannot be
	// cancled out of anymore, so disable this until multi-account
	// support is added.
	/*
		mitem, err := gtk.MenuItemNewWithLabel("New Wallet...")
		if err != nil {
			log.Fatal(err)
		}
		mitem.Connect("activate", func() {
			if dialog, err := createNewWalletDialog(); err != nil {
				log.Print(err)
			} else {
				dialog.Run()
			}
		})
		dropdown.Append(mitem)
		mitem.SetSensitive(false)
		MenuBar.Settings.New = mitem
	*/

	// TODO(jrick): Wallet is already encrypted, but we can possibly use
	// this code for a second level of encryption later that will encrypt
	// everything, not just private keys.
	/*
		mitem, err := gtk.MenuItemNewWithLabel("Encrypt Wallet...")
		if err != nil {
			log.Fatal(err)
		}
		mitem.Connect("activate", func() {
			if dialog, err := createEncryptionDialog(); err != nil {
				log.Print(err)
			} else {
				dialog.Run()
			}
		})
		dropdown.Append(mitem)
		mitem.SetSensitive(false)
		MenuBar.Settings.Encrypt = mitem
	*/

	mitem, err := gtk.MenuItemNewWithLabel("Lock wallet")
	if err != nil {
		log.Fatal(err)
	}
	mitem.Connect("activate", func() {
		go func() {
			triggers.lockWallet <- 1
		}()
	})
	dropdown.Append(mitem)
	mitem.SetSensitive(false)
	MenuBar.Settings.Lock = mitem

	mitem, err = gtk.MenuItemNewWithLabel("Unlock Wallet...")
	if err != nil {
		log.Fatal(err)
	}
	mitem.Connect("activate", func() {
		if dialog, err := createUnlockDialog(unlockManual, nil); err != nil {
			log.Print(err)
		} else {
			dialog.Run()
		}
	})
	dropdown.Append(mitem)
	mitem.SetSensitive(false)
	MenuBar.Settings.Unlock = mitem

	sep, err := gtk.SeparatorMenuItemNew()
	if err != nil {
		log.Fatal(err)
	}
	dropdown.Append(sep)

	mitem, err = gtk.MenuItemNewWithLabel("Set Transaction Fee...")
	if err != nil {
		log.Fatal(err)
	}
	mitem.Connect("activate", func() {
		if dialog, err := createTxFeeDialog(); err != nil {
			log.Print(err)
		} else {
			dialog.Run()
		}
	})
	dropdown.Append(mitem)
	//mitem.SetSensitive(false)
	MenuBar.Settings.TxFee = mitem

	return menu
}