本文整理汇总了C#中Gtk.Menu.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# Menu.Insert方法的具体用法?C# Menu.Insert怎么用?C# Menu.Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.Menu
的用法示例。
在下文中一共展示了Menu.Insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnPressed
protected override void OnPressed()
{
//base.OnPressed ();
Gtk.Menu menu = new Gtk.Menu ();
if (menu.Children.Length > 0) {
Gtk.SeparatorMenuItem sep = new Gtk.SeparatorMenuItem ();
sep.Show ();
menu.Insert (sep, -1);
}
Gtk.RadioMenuItem grp = new Gtk.RadioMenuItem ("");
foreach (ComboItem ci in items) {
Gtk.RadioMenuItem mi = new Gtk.RadioMenuItem (grp, ci.Label.Replace ("_","__"));
if (ci.Item == items.CurrentItem || ci.Item.Equals (items.CurrentItem))
mi.Active = true;
ComboItemSet isetLocal = items;
ComboItem ciLocal = ci;
mi.Activated += delegate {
SelectItem (isetLocal, ciLocal);
};
mi.ShowAll ();
menu.Insert (mi, -1);
}
menu.Popup (null, null, PositionFunc, 0, Gtk.Global.CurrentEventTime);
}
示例2: DockNotebook
public DockNotebook ()
{
pagesCol = new ReadOnlyCollection<IDockNotebookTab> (pages);
AddEvents ((Int32)(EventMask.AllEventsMask));
tabStrip = new TabStrip (this);
PackStart (tabStrip, false, false, 0);
contentBox = new EventBox ();
PackStart (contentBox, true, true, 0);
ShowAll ();
tabStrip.DropDownButton.Sensitive = false;
tabStrip.DropDownButton.MenuCreator = delegate {
Gtk.Menu menu = new Menu ();
foreach (var tab in pages) {
var mi = new Gtk.ImageMenuItem ("");
menu.Insert (mi, -1);
var label = (Gtk.AccelLabel) mi.Child;
if (tab.Markup != null)
label.Markup = tab.Markup;
else
label.Text = tab.Text;
var locTab = tab;
mi.Activated += delegate {
CurrentTab = locTab;
};
}
menu.ShowAll ();
return menu;
};
}
示例3: InterfaceInitialize
protected override void InterfaceInitialize()
{
viewMenu = (Globals.ActionManager.GetWidget("/MainMenu/ViewMenu") as MenuItem).Submenu as Menu;
menuItem = new MenuItem(Catalog.GetString("Mini mode"));
menuItem.Activated += delegate {
if (mini_mode == null)
mini_mode = new MiniMode();
mini_mode.Show();
};
viewMenu.Insert(menuItem, 2);
menuItem.Show();
}
示例4: DockNotebook
public DockNotebook ()
{
pagesCol = new ReadOnlyCollection<DockNotebookTab> (pages);
AddEvents ((Int32)(EventMask.AllEventsMask));
tabStrip = new TabStrip (this);
PackStart (tabStrip, false, false, 0);
contentBox = new EventBox ();
PackStart (contentBox, true, true, 0);
ShowAll ();
contentBox.NoShowAll = true;
tabStrip.DropDownButton.Sensitive = false;
tabStrip.DropDownButton.MenuCreator = delegate {
Gtk.Menu menu = new Menu ();
foreach (var tab in pages) {
var mi = new Gtk.ImageMenuItem ("");
menu.Insert (mi, -1);
var label = (Gtk.AccelLabel) mi.Child;
if (tab.Markup != null)
label.Markup = tab.Markup;
else
label.Text = tab.Text;
var locTab = tab;
mi.Activated += delegate {
CurrentTab = locTab;
};
}
menu.ShowAll ();
return menu;
};
Gtk.Drag.DestSet (this, Gtk.DestDefaults.Motion | Gtk.DestDefaults.Highlight | Gtk.DestDefaults.Drop, targetEntryTypes, Gdk.DragAction.Copy);
DragDataReceived += new Gtk.DragDataReceivedHandler (OnDragDataReceived);
DragMotion += delegate {
// Bring this window to the front. Otherwise, the drop may end being done in another window that overlaps this one
if (!Platform.IsWindows) {
var window = ((Gtk.Window)Toplevel);
if (window is DockWindow)
window.Present ();
}
};
allNotebooks.Add (this);
}
示例5: MenuItem
void IExtensionService.Initialize()
{
action_service = ServiceManager.Get<InterfaceActionService> ();
viewMenu = (action_service.UIManager.GetWidget ("/MainMenu/ViewMenu") as MenuItem).Submenu as Menu;
menuItem = new MenuItem (Catalog.GetString ("_Mini Mode"));
menuItem.Activated += delegate {
if (mini_mode == null) {
mini_mode = new MiniMode (ServiceManager.Get<GtkElementsService> ().PrimaryWindow);
}
ServiceManager.Get<GtkElementsService> ().PrimaryWindow = mini_mode;
mini_mode.Enable ();
};
viewMenu.Insert (menuItem, 2);
menuItem.Show ();
}
示例6: BuildTemplateItems
Gtk.Menu BuildTemplateItems (ExtensionNodeList nodes)
{
Gtk.Menu menu = new Gtk.Menu ();
foreach (ExtensionNode tn in nodes) {
Gtk.MenuItem item;
if (tn is TemplateCategoryNode) {
TemplateCategoryNode cat = (TemplateCategoryNode) tn;
item = new Gtk.MenuItem (cat.Name);
item.Submenu = BuildTemplateItems (cat.ChildNodes);
}
else {
FileTemplateNode t = (FileTemplateNode) tn;
item = new Gtk.MenuItem (t.Name);
item.Activated += delegate {
TextEditor.TextEditorApp.NewFile (t.GetContent ());
};
}
menu.Insert (item, -1);
}
return menu;
}
示例7: UpdateGlobalWarningLabel
void UpdateGlobalWarningLabel ()
{
KeyBindingConflict[] conflicts = currentBindings.CheckKeyBindingConflicts (IdeApp.CommandService.GetCommands ());
if (conflicts.Length == 0) {
globalWarningBox.Hide ();
return;
}
globalWarningBox.Show ();
conflicButton.MenuCreator = delegate {
Menu menu = new Menu ();
foreach (KeyBindingConflict conf in conflicts) {
if (menu.Children.Length > 0) {
SeparatorMenuItem it = new SeparatorMenuItem ();
it.Show ();
menu.Insert (it, -1);
}
foreach (Command cmd in conf.Commands) {
string txt = currentBindings.GetBinding (cmd) + " - " + cmd.Text;
MenuItem item = new MenuItem (txt);
Command localCmd = cmd;
item.Activated += delegate {
SelectCommand (localCmd);
};
item.Show ();
menu.Insert (item, -1);
}
}
return menu;
};
}
示例8: Initialize
private void Initialize()
{
view_menu = (interface_action_service.UIManager.GetWidget ("/MainMenu/ViewMenu") as MenuItem).Submenu as Menu;
menu_item = new MenuItem (Catalog.GetString ("Media _Panel"));
menu_item.Activated += delegate { PresentMediaPanel (); };
view_menu.Insert (menu_item, 2);
menu_item.Show ();
// If Banshee is running from the MediaPanel client entry assembly,
// the MediaPanel instance will have already been created.
panel = MediaPanel.Instance;
if (panel != null) {
panel.BuildContents ();
PresentMediaPanel ();
}
}
示例9: DefaultPolicyOptionsDialog
public DefaultPolicyOptionsDialog (Gtk.Window parentWindow)
: base (parentWindow, new PolicySet (),
"/MonoDevelop/ProjectModel/Gui/DefaultPolicyPanels")
{
this.Title = GettextCatalog.GetString ("Custom Policies");
editingSet = (PolicySet) DataObject;
HBox topBar = new HBox ();
topBar.Spacing = 3;
topBar.PackStart (new Label (GettextCatalog.GetString ("Editing Policy:")), false, false, 0);
policiesCombo = ComboBox.NewText ();
topBar.PackStart (policiesCombo, false, false, 0);
deleteButton = new Button (GettextCatalog.GetString ("Delete Policy"));
topBar.PackEnd (deleteButton, false, false, 0);
exportButton = new MenuButton ();
exportButton.Label = GettextCatalog.GetString ("Export");
exportButton.MenuCreator = delegate {
Gtk.Menu menu = new Gtk.Menu ();
MenuItem mi = new MenuItem (GettextCatalog.GetString ("To file..."));
mi.Activated += HandleToFile;
menu.Insert (mi, -1);
mi = new MenuItem (GettextCatalog.GetString ("To project or solution..."));
mi.Activated += HandleToProject;
if (!IdeApp.Workspace.IsOpen)
mi.Sensitive = false;
menu.Insert (mi, -1);
menu.ShowAll ();
return menu;
};
topBar.PackEnd (exportButton, false, false, 0);
newButton = new MenuButton ();
newButton.Label = GettextCatalog.GetString ("Add Policy");
newButton.MenuCreator = delegate {
Gtk.Menu menu = new Gtk.Menu ();
MenuItem mi = new MenuItem (GettextCatalog.GetString ("New policy..."));
mi.Activated += HandleNewButtonClicked;
menu.Insert (mi, -1);
mi = new MenuItem (GettextCatalog.GetString ("From file..."));
mi.Activated += HandleFromFile;
menu.Insert (mi, -1);
mi = new MenuItem (GettextCatalog.GetString ("From project or solution..."));
mi.Activated += HandleFromProject;
if (!IdeApp.Workspace.IsOpen)
mi.Sensitive = false;
menu.Insert (mi, -1);
menu.ShowAll ();
return menu;
};
topBar.PackEnd (newButton, false, false, 0);
Alignment align = new Alignment (0f, 0f, 1f, 1f);
align.LeftPadding = 9;
align.TopPadding = 9;
align.RightPadding = 9;
align.BottomPadding = 9;
align.Add (topBar);
HeaderBox ebox = new HeaderBox ();
ebox.GradientBackround = true;
ebox.SetMargins (0, 1, 0, 0);
ebox.Add (align);
ebox.ShowAll ();
VBox.PackStart (ebox, false, false, 0);
VBox.BorderWidth = 0;
Box.BoxChild c = (Box.BoxChild) VBox [ebox];
c.Position = 0;
foreach (PolicySet ps in PolicyService.GetUserPolicySets ()) {
PolicySet copy = ps.Clone ();
originalSets [copy] = ps;
sets.Add (copy);
}
FillPolicySets ();
policiesCombo.Changed += HandlePoliciesComboChanged;
deleteButton.Clicked += HandleDeleteButtonClicked;
}
示例10: UpdateRecentProjectList
public void UpdateRecentProjectList()
{
History.Default.Load ();
recentMenu.Submenu = null;
var m = new Menu ();
int nop = 0;
foreach (var project in History.Default.ProjectHistory)
{
nop++;
var recentItem = new MenuItem(project);
// We need a local to make the delegate work correctly.
var localProject = project;
recentItem.Activated += (sender, args) => _controller.OpenProject(localProject);
m.Insert (recentItem, 0);
}
if (nop > 0) {
m.Add (new SeparatorMenuItem ());
var item = new MenuItem ("Clear");
item.Activated += delegate {
History.Default.Clear ();
UpdateRecentProjectList ();
};
m.Add (item);
recentMenu.Submenu = m;
m.ShowAll ();
}
recentMenu.Sensitive = nop > 0;
menubar1.ShowAll ();
}
示例11: UpdateRecentProjectList
public void UpdateRecentProjectList()
{
var m = new Menu ();
recentMenu.Submenu = null;
if (Global.UseHeaderBar)
recentListStore.Clear();
var projectList = PipelineSettings.Default.ProjectHistory.ToList();
foreach (var project in projectList)
{
if (Global.UseHeaderBar)
recentListStore.InsertWithValues(0, "<b>" + System.IO.Path.GetFileName(project) + "</b>" + Environment.NewLine + System.IO.Path.GetDirectoryName(project), project);
var recentItem = new MenuItem(project);
recentItem.Activated += (sender, e) => OpenProject(project);
m.Insert (recentItem, 0);
}
if (projectList.Count > 0)
{
m.Add(new SeparatorMenuItem());
var item = new MenuItem("Clear");
item.Activated += delegate
{
PipelineSettings.Default.Clear();
UpdateRecentProjectList();
};
m.Add(item);
Application.Invoke(delegate
{
recentMenu.Submenu = m;
m.ShowAll();
recentMenu.Sensitive = projectList.Count > 0;
menubar1.ShowAll();
});
}
}
示例12: WorkspaceTree
// Icon,Show Name, Full Path, TypFile
public WorkspaceTree()
{
treeView = new TreeView();
treeView.ButtonReleaseEvent += new ButtonReleaseEventHandler(OnButtonRelease);
treeView.KeyReleaseEvent += delegate(object o, KeyReleaseEventArgs args) {
if(args.Event.Key == Gdk.Key.Delete){
MainClass.MainWindow.DeleteFile();
}
};
//treeView.Model = modelStore = store;
filter = new Gtk.TreeModelFilter(store, null);
filter.VisibleFunc = new Gtk.TreeModelFilterVisibleFunc(FilterTree);
treeView.Model = filter;
treeView.HeadersVisible = true;
//this.ExpandAll();
treeView.Selection.Mode = Gtk.SelectionMode.Single;
treeView.RowActivated += OnRowActivate;
treeView.Selection.Changed+= OnRowSelection;
treeView.ShowExpanders = true;
// TreeViewColumn display_column.PackStart (text_render, true);
CellRendererPixbuf crp = new CellRendererPixbuf();
crp.Ypad = 0;
crp.Yalign = 0;
Gtk.CellRendererText fileNameRenderer = new Gtk.CellRendererText();
fileNameRenderer.Ypad =0;
TreeViewColumn icon_column = new TreeViewColumn();//("Icon", crp, "pixbuf", ICO_ROW);
icon_column.PackStart (crp, false);
icon_column.AddAttribute(crp,"pixbuf",ICO_ROW);
icon_column.PackStart (fileNameRenderer, true);
icon_column.AddAttribute (fileNameRenderer, "markup", NAME_ROW);
treeView.AppendColumn(icon_column);
//treeView.AppendColumn("Icon", crp, "pixbuf", ICO_ROW);
treeView.AppendColumn("Name", fileNameRenderer, "text", NAME_ROW);
treeView.Columns[NAME_ROW].Visible = false;
CellRendererText textRenderer = new CellRendererText();
textRenderer.Ypad =0;
treeView.AppendColumn("FullPath", textRenderer, "text", PATH_ROW);
treeView.Columns[PATH_ROW].Visible = false;
treeView.HeadersVisible = false;
treeView.EnableTreeLines = true;
treeView.HoverExpand = false;
treeView.HoverSelection = false;
treeView.Columns[NAME_ROW].SetCellDataFunc(fileNameRenderer, new Gtk.TreeCellDataFunc(RenderFileNme));
sw.ShadowType = ShadowType.Out;
sw.Add(treeView);
this.PackEnd(sw, true, true, 0);
Toolbar toolbar = new Toolbar ();
refreshButton = new ToolButton ("refresh.png");//Stock.Home);
refreshButton.IsImportant = true;
refreshButton.Label = MainClass.Languages.Translate("menu_refresh");
refreshButton.BorderWidth = 1;
refreshButton.Clicked+= delegate {
MainClass.MainWindow.RefreshProject();
};
toolbar.Insert (refreshButton, -1);
Gtk.Menu menuAdd = new Gtk.Menu ();
MenuItem mi = new MenuItem (MainClass.Languages.Translate("menu_create_file"));
mi.Activated += delegate(object sender, EventArgs e) {
NewAction nw = new NewAction();
nw.Activate();
};
menuAdd.Insert (mi, -1);
mi = new MenuItem (MainClass.Languages.Translate("menu_create_dir"));
mi.Activated += delegate(object sender, EventArgs e) {
NewDirectoryAction nw = new NewDirectoryAction();
nw.Activate();
};
menuAdd.Insert (mi, -1);
menuAdd.ShowAll ();
mtbCreate= new MenusToolButton(menuAdd,"file-new.png");
mtbCreate.IsImportant = true;
mtbCreate.Label = "Create";
toolbar.Insert (mtbCreate, -1);
if(MainClass.Settings.LogicalSort == null)
//.........这里部分代码省略.........
示例13: PluginInitialize
protected override void PluginInitialize()
{
// Check that our SmartPlaylists table exists in the database, otherwise make it
if(!Globals.Library.Db.TableExists("SmartPlaylists")) {
Globals.Library.Db.Execute(@"
CREATE TABLE SmartPlaylists (
PlaylistID INTEGER PRIMARY KEY,
Condition TEXT,
OrderBy TEXT,
LimitNumber TEXT)
");
}
// Listen for deleted playlists and new/changed songs
SourceManager.SourceAdded += HandleSourceAdded;
SourceManager.SourceRemoved += HandleSourceRemoved;
Globals.Library.Reloaded += HandleLibraryReloaded;
Globals.Library.TrackAdded += HandleTrackAdded;
Globals.Library.TrackRemoved += HandleTrackRemoved;
// Add a menu option to create a new smart playlist
musicMenu = (Globals.ActionManager.GetWidget ("/MainMenu/MusicMenu") as MenuItem).Submenu as Menu;
addItem = new MenuItem (Catalog.GetString("New Smart Playlist..."));
addItem.Activated += delegate {
SmartPlaylistEditor ed = new SmartPlaylistEditor ();
ed.RunDialog ();
};
// Insert right after the New Playlist item
musicMenu.Insert (addItem, 2);
addItem.Show ();
// Add option for editing smart playlists
/*Globals.ActionManager.PlaylistActions.Add(new ActionEntry [] {
new ActionEntry("EditSmartPlaylistAction", null,
Catalog.GetString("Edit Smart Playlist"), "<shift>Delete",
Catalog.GetString("Edit the active smart playlist"), null)
});
Globals.ActionManager.PlaylistActions.GetAction ("EditSmartPlaylistAction").Visible = true;
Globals.ActionManager.PlaylistActions.GetAction ("EditSmartPlaylistAction").Sensitive = true;*/
sourceMenu = Globals.ActionManager.GetWidget ("/SourceMenu") as Menu;
editItem = new MenuItem (Catalog.GetString("Edit Smart Playlist..."));
editItem.Activated += delegate {
SmartPlaylistEditor ed = new SmartPlaylistEditor (playlists[SourceManager.ActiveSource] as SmartPlaylist);
ed.RunDialog ();
};
sourceMenu.Insert (editItem, 2);
editItem.Show ();
}
示例14: FileExplorer
public FileExplorer()
{
navigBar = new NavigationBar(NavigationBar.NavigationType.favorites);
navigBar.OnChangePath+= NavigateBarChange;
Toolbar toolbar = new Toolbar ();
//WinMenuBar toolbar = new WinMenuBar ();
this.PackStart (toolbar, false, false, 0);
refreshButton = new ToolButton ("refresh.png");//Stock.Home);
refreshButton.IsImportant = true;
refreshButton.Label = MainClass.Languages.Translate("menu_refresh");
refreshButton.BorderWidth = 1;
refreshButton.Clicked+= delegate {
FillStore (true);
};
toolbar.Insert (refreshButton, -1);
upButton = new ToolButton ("go-up.png");//Stock.GoUp
upButton.Sensitive = false;
upButton.Label ="Up";
upButton.BorderWidth = 1;
toolbar.Insert (upButton, -1);
Gtk.Menu menu = new Gtk.Menu ();
MenuItem mi = new MenuItem ("Workspace");
mi.Activated += OnWorkspaceClicked;
menu.Insert (mi, -1);
mi = new MenuItem ("Project");
mi.Activated += OnProjectClicked;
menu.Insert (mi, -1);
menu.ShowAll ();
mi = new MenuItem ("User home folder");
mi.Activated += OnHomeClicked;
menu.Insert (mi, -1);
menu.ShowAll ();
mi = new MenuItem ("Output folder");
mi.Activated += OnOutputClicked;
menu.Insert (mi, -1);
menu.ShowAll ();
mi = new MenuItem ("Disk root");
mi.Activated += OnOutputClicked;
menu.Insert (mi, -1);
menu.ShowAll ();
if(MainClass.Platform.IsWindows){
SeparatorMenuItem smi = new SeparatorMenuItem();
menu.Insert (smi, -1);
string[] drives = Environment.GetLogicalDrives();
foreach(string strDrive in drives)
{
mi = new MenuItem (strDrive);
mi.TooltipText = strDrive;
mi.Activated += delegate(object sender, EventArgs e)
{
string drive = (sender as MenuItem).TooltipText;
parent = new DirectoryInfo(drive);
FillStore (true);
upButton.Sensitive = false;
};
menu.Insert (mi, -1);
menu.ShowAll ();
};
}
MenusToolButton gotoButton= new MenusToolButton(menu,"workspace.png");
gotoButton.IsImportant = true;
gotoButton.Label = "Go To";
toolbar.Insert (gotoButton, -1);
Gtk.Menu menuAdd = new Gtk.Menu ();
mi = new MenuItem (MainClass.Languages.Translate("menu_create_file"));
mi.Activated += OnCreateFileClicked;
menuAdd.Insert (mi, -1);
mi = new MenuItem (MainClass.Languages.Translate("menu_create_dir"));
mi.Activated += OnCreateDirectoryClicked;
menuAdd.Insert (mi, -1);
menuAdd.ShowAll ();
MenusToolButton mtbCreate= new MenusToolButton(menuAdd,"file-new.png");
mtbCreate.IsImportant = true;
mtbCreate.Label = "Create";
toolbar.Insert (mtbCreate, -1);
fileIcon = GetIcon ("file.png");//Stock.File);
dirIcon = GetIcon ("folder.png");//Stock.Open);
upIcon = GetIcon ("go-up.png");
ScrolledWindow sw = new ScrolledWindow ();
sw.ShadowType = ShadowType.EtchedIn;
sw.SetPolicy (PolicyType.Automatic, PolicyType.Automatic);
this.PackStart (sw, true, true, 0);
// Create the store and fill it with the contents of '/'
store = CreateStore ();
//.........这里部分代码省略.........
示例15: ShowPopupMenu
void ShowPopupMenu (Gdk.EventButton evt)
{
TreeIter it;
if (!tree.Selection.GetSelected (out it))
return;
Menu menu = new Menu ();
Gtk.ImageMenuItem mi = new Gtk.ImageMenuItem (AddinManager.CurrentLocalizer.GetString ("Select Extension Points..."));
menu.Insert (mi, -1);
string aid = (string) store.GetValue (it, ColAddin);
if (aid != null) {
}
PopulateNodeTypes (menu, it);
menu.Insert (new Gtk.SeparatorMenuItem (), -1);
mi = new Gtk.ImageMenuItem (Gtk.Stock.Remove, null);
menu.Insert (mi, -1);
mi.Activated += delegate { DeleteSelection (); };
menu.ShowAll ();
GtkWorkarounds.ShowContextMenu (menu, tree, evt);
}