3
* GNOME Do is the legal property of its developers. Please refer to the
4
* COPYRIGHT file distributed with this source distribution.
6
* This program is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
34
public class MainMenu : Gtk.Menu
37
static MainMenu instance;
39
public static MainMenu Instance {
42
instance = new MainMenu ();
47
int mainMenuX, mainMenuY;
51
foreach (IRunnableItem item in Services.Application.MainMenuItems)
52
Add (MenuItemFromRunnableItem (item));
56
MenuItem MenuItemFromRunnableItem (IRunnableItem item)
60
ImageMenuItem menuItem;
62
menuItem = new ImageMenuItem (item.Name);
63
Icon.SizeLookup (IconSize.Menu, out iconSize, out iconSize);
64
icon = IconProvider.PixbufFromIconName (item.Icon, iconSize);
65
menuItem.Image = new Image (icon);
66
menuItem.CanFocus = false;
67
menuItem.Activated += (sender, e) => item.Run ();
71
public void PopupAtPosition (int x, int y)
73
menuPositioner = null;
76
Popup (null, null, PositionMainMenu, 3, Gtk.Global.CurrentEventTime);
79
private void PositionMainMenu (Menu menu, out int x, out int y, out bool push_in)
81
if (menuPositioner == null) {
85
Requisition menuReq = menu.SizeRequest ();
86
menuPositioner (menuReq.Height, menuReq.Width, out x, out y);
91
PositionMenu menuPositioner;
93
public void PopupWithPositioner (PositionMenu menuPositioner)
95
this.menuPositioner = menuPositioner;
96
Popup (null, null, PositionMainMenu, 3, Gtk.Global.CurrentEventTime);