Esempio n. 1
0
File: menus.go Progetto: sqp/godock
// NewMenu creates a gtk menu builder.
//
// Warning, don't forget to use ShowAll when you add entries manually.
//
func NewMenu(items ...interface{}) *Menu {
	gtkmenu := newgtk.Menu()
	menu := WrapMenu(gtkmenu)
	menu.AddList(items...)
	menu.ShowAll()
	return menu
}
Esempio n. 2
0
File: menus.go Progetto: sqp/godock
// WrapMenu wraps a gtk menu as a menu builder.
//
func WrapMenu(menu *gtk.Menu) *Menu {
	return &Menu{
		Menu:   *menu,
		groups: make(map[int]*glib.SList),

		callNewItem: func(menu *gtk.Menu, label, iconPath string) *gtk.MenuItem {
			item := newgtk.MenuItemWithLabel(label)
			menu.Append(item)
			return item
		},

		callNewSubMenu: func(menu *gtk.Menu, label, iconPath string) (*gtk.Menu, *gtk.MenuItem) {
			gtkmenu := newgtk.Menu()
			item := newgtk.MenuItemWithLabel(label)
			menu.Append(item)
			item.SetSubmenu(gtkmenu)
			return gtkmenu, item
		},
	}
}