本文整理汇总了C#中Gtk.ActionGroup.Add方法的典型用法代码示例。如果您正苦于以下问题:C# ActionGroup.Add方法的具体用法?C# ActionGroup.Add怎么用?C# ActionGroup.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.ActionGroup
的用法示例。
在下文中一共展示了ActionGroup.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MainWindow
public MainWindow()
: base(Gtk.WindowType.Toplevel)
{
Build ();
UiManagerHelper uiManagerHelper = new UiManagerHelper(UIManager);
ActionGroup actionGroup1 = new ActionGroup("pageActionGroup");
Gtk.Action newAction = new Gtk.Action("newAction", null, null, Stock.New);
actionGroup1.Add (newAction);
Gtk.Action editAction = new Gtk.Action("editAction", null, null, Stock.Edit);
actionGroup1.Add (editAction);
ActionGroup actionGroup2 = new ActionGroup("pageActionGroup");
Gtk.Action deleteAction = new Gtk.Action("deleteAction", null, null, Stock.Delete);
actionGroup2.Add (deleteAction);
ActionGroup currentActionGroup = actionGroup1;
uiManagerHelper.SetActionGroup (currentActionGroup);
executeAction.Activated += delegate {
Console.WriteLine("executeAction.Activated");
if (currentActionGroup == actionGroup1)
currentActionGroup = actionGroup2;
else
currentActionGroup = actionGroup1;
uiManagerHelper.SetActionGroup(currentActionGroup);
};
}
示例2: Window
public Window(Inventory inventory)
: this(new Builder("window.ui"))
{
Inventory = inventory;
// load the menues and toolbars
uiManager = new UIManager();
// create the file actions
Gtk.Action saveInventoryAction = new Gtk.Action("saveFile","Save","Save the active inventory",Stock.Save);
saveInventoryAction.Activated += OnSaveInventory;
Gtk.Action printLabelsAction = new Gtk.Action("printLabels","Print Labels","Print labels for items.",Stock.Print);
printLabelsAction.Activated += OnPrintLabels;
Gtk.Action quitAction = new Gtk.Action("quit","Quit","Quit the application",Stock.Quit);
quitAction.Activated += OnQuit;
Gtk.Action fileAction = new Gtk.Action("file","File");
ActionGroup fileActionGroup = new ActionGroup("file");
fileActionGroup.Add(saveInventoryAction);
fileActionGroup.Add(printLabelsAction);
fileActionGroup.Add(quitAction);
fileActionGroup.Add(fileAction);
uiManager.InsertActionGroup(fileActionGroup,0);
// create items box
itemsBox = new ItemsBox(inventory.Items, uiManager);
itemsBox.DrawDescriptionEntry += OnDrawDescriptionEntry;
itemsBox.ShowMe += OnShowItemsBox;
itemsAlign.Add(itemsBox);
// create locations box
locationsBox = new LocationsBox(inventory.Locations, uiManager);
locationsBox.DrawDescriptionEntry += OnDrawDescriptionEntry;
locationsBox.ShowMe += OnShowLocationsBox;
locationsBox.GotoItem += OnGotoLocationsItem;
locationsAlign.Add(locationsBox);
// create tags box
tagsBox = new TagsBox(inventory.Tags, uiManager);
tagsBox.ShowMe += OnShowTagsBox;
tagsAlign.Add(tagsBox);
// create tool and menubar
uiManager.AddUiFromResource("window_menues.xml");
menuBar = (MenuBar) uiManager.GetWidget("/menuBar");
toolbar = (Toolbar) uiManager.GetWidget("/toolbar");
toolbar.IconSize = IconSize.LargeToolbar;
toolbar.ToolbarStyle = ToolbarStyle.Both;
mainBox.PackStart(menuBar,false,true,0);
mainBox.PackStart(toolbar,false,true,0);
// laod category icons
itemsTabImage.Pixbuf = ((GtkSettings)Inventory.Settings).ItemsTabIcon;
locationsTabImage.Pixbuf = ((GtkSettings)Inventory.Settings).LocationsTabIcon;
tagsTabImage.Pixbuf = ((GtkSettings)Inventory.Settings).TagsTabIcon;
this.Icon = ((GtkSettings)Inventory.Settings).WindowIcon;
this.Resize(((GtkSettings)Inventory.Settings).MainWindowWidth,((GtkSettings)Inventory.Settings).MainWindowHeight);
}
示例3: Navbar
public Navbar (Gtk.IconSize size)
{
address = new Entry ("address");
// FIXME: this doesnt't seem to work yet
// address.Completion = new EntryCompletion ();
address.WidthChars = 50;
address.Activated += new EventHandler (OnGoUrl);
ActionEntry[] actions = new ActionEntry[]
{
new ActionEntry ("back", Gtk.Stock.GoBack, null, null, GettextCatalog.GetString ("Go back"), new EventHandler (OnBackClicked)),
new ActionEntry ("forward", Gtk.Stock.GoForward, null, null, GettextCatalog.GetString ("Go forward"), new EventHandler (OnForwardClicked)),
new ActionEntry ("stop", Gtk.Stock.Stop, null, null, GettextCatalog.GetString ("Stop loading"), new EventHandler (OnStopClicked)),
new ActionEntry ("reload", Gtk.Stock.Refresh, null, null, GettextCatalog.GetString ("Address"), new EventHandler (OnReloadClicked)),
new ActionEntry ("go", Gtk.Stock.Ok, null, null, GettextCatalog.GetString ("Load address"), new EventHandler (OnGoUrl))
};
ActionGroup ag = new ActionGroup ("navbarGroup");
ag.Add (actions);
UIManager uim = new UIManager ();
uim.InsertActionGroup (ag, 0);
uim.AddWidget += new AddWidgetHandler (OnAddWidget);
uim.AddUiFromString (uiInfo);
ToolItem item = new ToolItem ();
item.Add (address);
Toolbar tb = uim.GetWidget ("/ui/toolbar") as Toolbar;
tb.IconSize = size;
tb.Add (item);
this.ShowAll ();
}
示例4: MainUIManager
public MainUIManager(ViewGui viewGui)
{
this.viewGui = viewGui;
actions = new ActionGroup ("Actions");
ActionEntry actionEntryQuit;
actionEntryQuit = new ActionEntry("Quitter", Gtk.Stock.Quit, null, "<control>Q", "Quitter l'environnement Sofia", new EventHandler (Quit));
ActionEntry[] entries = new ActionEntry [] {
new ActionEntry ("Fichier", null, "_Fichier", null, null, null),
new ActionEntry ("Editer", null, "Editio_n", null, null, null),
new ActionEntry ("Rechercher", null, "Recher_cher", null, null, null),
new ActionEntry ("Aide", null, "_Aide", null, null, null),
actionEntryQuit,
new ActionEntry ("Préférences", Gtk.Stock.Preferences, null, null, "Préférences", new EventHandler (Preferences)),
new ActionEntry ("RubriquesAide", Gtk.Stock.Help, "Rubriques d'_aide", "F1", "Aide - Rubriques d'aide", new EventHandler (Help)),
new ActionEntry ("APropos", Gtk.Stock.About, null, null, "A propos de l'environnement Sofia", new EventHandler (About))
};
actions.Add (entries);
InsertActionGroup(actions, 0);
this.viewGui.AddAccelGroup(AccelGroup);
uint id = 0;
try {
id = AddUiFromFile("MainUIDef.xml");
}
catch {
RemoveUi(id);
}
}
示例5: Shell
public Shell()
: base("Mono Heap Profiler")
{
entries = new ActionEntry[] {
new ActionEntry ("FileMenu", null, "_File", null, null, null),
new ActionEntry ("OpenAction", Stock.Open, null, "<control>O", "Open a profile...", new EventHandler (OnOpen)),
new ActionEntry ("QuitAction", Stock.Quit, null, "<control>Q", "Quit the application", delegate { Application.Quit (); }),
};
DefaultSize = new Gdk.Size (700, 700);
DeleteEvent += delegate { Application.Quit (); };
main_box = new VBox (false, 0);
Add (main_box);
shell_commands = new ActionGroup ("TestActions");
shell_commands.Add (entries);
uim = new UIManager ();
uim.AddWidget += delegate (object obj, AddWidgetArgs args) {
args.Widget.Show ();
main_box.PackStart (args.Widget, false, true, 0);
};
uim.ConnectProxy += OnProxyConnect;
uim.InsertActionGroup (shell_commands, 0);
uim.AddUiFromResource ("shell-ui.xml");
AddAccelGroup (uim.AccelGroup);
sb = new Statusbar ();
main_box.PackEnd (sb, false, true, 0);
pager = new ShellPager (this);
main_box.PackEnd (pager, true, true, 0);
}
示例6: Initialize
public override void Initialize ()
{
action_group = new Gtk.ActionGroup ("RemoveBrokenLinks");
action_group.Add (new Gtk.ActionEntry [] {
new Gtk.ActionEntry ("ToolsMenuAction", null,
Catalog.GetString ("_Tools"), null, null, null),
new Gtk.ActionEntry ("RemoveBrokenLinksAction", null,
Catalog.GetString ("_Remove broken links"), null, null,
delegate {
OnRemoveBrokenLinksActivated ();
})
});
rblUi = Tomboy.ActionManager.UI.AddUiFromString (@"
<ui>
<menubar name='MainWindowMenubar'>
<placeholder name='MainWindowMenuPlaceholder'>
<menu name='ToolsMenu' action='ToolsMenuAction'>
<menuitem name='RemoveBrokenLinks' action='RemoveBrokenLinksAction' />
</menu>
</placeholder>
</menubar>
</ui>
");
Tomboy.ActionManager.UI.InsertActionGroup (action_group, 0);
initialized = true;
}
示例7: AddHelpActions
void AddHelpActions(ActionGroup actionGroup)
{
var help = new Gtk.Action ("help", Catalog.GetString ("_Help"));
actionGroup.Add (help);
var about = new Gtk.Action ("about", null, null, Gtk.Stock.About);
about.Activated += delegate {
var dialog = new AboutDialog ();
dialog.Authors = new string[] { "Christian Hergert" };
dialog.License = Util.ReadResource ("Resources.license.txt");
dialog.Copyright = "Copyright © 2008 Christian Hergert";
dialog.Run ();
dialog.Destroy ();
};
actionGroup.Add (about);
}
示例8: AddAdroitActions
void AddAdroitActions(ActionGroup actionGroup)
{
var adroit = new Gtk.Action ("adroit", Catalog.GetString ("_Adroit"));
actionGroup.Add (adroit);
var quit = new Gtk.Action ("quit", null, null, Gtk.Stock.Quit);
quit.Activated += delegate { Gtk.Application.Quit (); };
actionGroup.Add (quit, "<Control>Q");
var close = new Gtk.Action ("close", null, null, Gtk.Stock.Close);
close.Activated += delegate { Gtk.Application.Quit (); };
close.Visible = false;
actionGroup.Add (close, "<Control>W");
var export = new Gtk.Action ("export", Catalog.GetString ("_Export"));
export.Visible = false;
actionGroup.Add (export, null);
}
示例9: Initialize
public override void Initialize ()
{
Logger.Debug ("TasksApplicationAddin.Initialize ()");
if (manager == null) {
lock (locker) {
if (manager == null) {
manager = new TaskManager (
Path.Combine (Tomboy.DefaultNoteManager.NoteDirectoryPath, "Tasks"));
}
}
///
/// Add a "To Do List" to Tomboy's Tray Icon Menu
///
action_group = new Gtk.ActionGroup ("Tasks");
action_group.Add (new Gtk.ActionEntry [] {
new Gtk.ActionEntry ("ToolsMenuAction", null,
Catalog.GetString ("_Tools"), null, null, null),
new Gtk.ActionEntry ("OpenToDoListAction", null,
Catalog.GetString ("To Do List"), null, null,
delegate { OnOpenToDoListAction (); })
});
// tray_icon_ui = Tomboy.ActionManager.UI.AddUiFromString (@"
// <ui>
// <popup name='TrayIconMenu' action='TrayIconMenuAction'>
// <menuitem name='OpenToDoList' action='OpenToDoListAction' />
// </popup>
// </ui>
// ");
tools_menu_ui = Tomboy.ActionManager.UI.AddUiFromString (@"
<ui>
<menubar name='MainWindowMenubar'>
<placeholder name='MainWindowMenuPlaceholder'>
<menu name='ToolsMenu' action='ToolsMenuAction'>
<menuitem name='OpenToDoList' action='OpenToDoListAction' />
</menu>
</placeholder>
</menubar>
</ui>
");
Tomboy.ActionManager.UI.InsertActionGroup (action_group, 0);
Tomboy.DefaultNoteManager.NoteDeleted += OnNoteDeleted;
tomboy_tray_menu = GetTomboyTrayMenu ();
tomboy_tray_menu.Shown += OnTomboyTrayMenuShown;
tomboy_tray_menu.Hidden += OnTomboyTrayMenuHidden;
initialized = true;
}
}
示例10: MainWindow
public MainWindow()
: base(Gtk.WindowType.Toplevel)
{
Build ();
ActionGroup actionGroup1 = new ActionGroup("pageActionGroup");
Gtk.Action newAction = new Gtk.Action("newAction", null, null, Stock.New);
actionGroup1.Add (newAction);
Gtk.Action editAction = new Gtk.Action("editAction", null, null, Stock.Edit);
actionGroup1.Add (editAction);
UIManager.InsertActionGroup(actionGroup1, 0);
// uint mergeId = UIManager.AddUiFromString(
// "<ui>" +
// "<toolbar name='toolbar'>" +
// "<toolitem name='newAction' action='newAction'/>" +
// "<toolitem name='editAction' action='editAction'/>" +
// "</toolbar>" +
// "</ui>");
uint mergeId = UIManager.AddUiFromString( getUi(actionGroup1) );
Console.WriteLine ("mergeId={0}", mergeId);
ActionGroup actionGroup2 = new ActionGroup("pageActionGroup");
Gtk.Action deleteAction = new Gtk.Action("deleteAction", null, null, Stock.Delete);
actionGroup2.Add (deleteAction);
executeAction.Activated += delegate {
Console.WriteLine("executeAction.Activated");
//Console.WriteLine("UIManager.Ui='{0}'", UIManager.Ui);
UIManager.RemoveUi (mergeId);
UIManager.RemoveActionGroup(actionGroup1);
UIManager.InsertActionGroup(actionGroup2, 0);
UIManager.AddUiFromString( getUi(actionGroup2) );
};
}
示例11: ShowWindow
public void ShowWindow ()
{
Application.Init ();
gxml = new Glade.XML ("contactviewer.glade", "MainWindow");
gxml.Autoconnect (this);
ActionEntry[] entries = new ActionEntry [] {
new ActionEntry ("FileMenuAction", null, "_File", null, null, null),
new ActionEntry ("OpenAction", Gtk.Stock.Open,
"_Open", "<control>O", Catalog.GetString ("Open..."), new EventHandler (OnOpenDatabase)),
new ActionEntry ("QuitAction", Gtk.Stock.Quit,
"_Quit", "<control>Q", Catalog.GetString ("Quit"), new EventHandler (OnQuit)),
new ActionEntry ("HelpMenuAction", null, "_Help", null, null, null),
new ActionEntry ("AboutAction", Gnome.Stock.About,
"_About", null, Catalog.GetString ("About"), new EventHandler (OnAbout))
};
ActionGroup grp = new ActionGroup ("MainGroup");
grp.Add (entries);
ui_manager = new UIManager ();
ui_manager.InsertActionGroup(grp, 0);
ui_manager.AddUiFromResource ("menu.xml");
MenubarHolder.Add (ui_manager.GetWidget ("/MainMenu"));
// Fix the TreeView that will contain all contacts
contact_store = new ListStore (typeof (string), typeof (string));
ContactList.Model = contact_store;
ContactList.RulesHint = true;
ContactList.AppendColumn (Catalog.GetString ("Contacts"), new CellRendererText (), "text", 1);
ContactList.ButtonReleaseEvent += OnContactSelected;
// This ListStore will let the user choose what to see in the contact list
contact_show_type_store = new ListStore (typeof (string), typeof (string));
contact_show_type_store.AppendValues ("DisplayName", Catalog.GetString ("Display name"));
contact_show_type_store.AppendValues ("PrimaryEmail", Catalog.GetString ("Primary E-mail"));
contact_show_type_store.AppendValues ("SecondEmail", Catalog.GetString ("Secondary E-mail"));
contact_show_type_store.AppendValues ("NickName", Catalog.GetString ("Nickname"));
CellRendererText cell = new CellRendererText ();
ListIdentifier.PackStart (cell, false);
ListIdentifier.AddAttribute (cell, "text", 1);
ListIdentifier.Model = contact_show_type_store;
ListIdentifier.Active = 0;
ListIdentifier.Changed += OnContactListTypeChanged;
MainWindow.Icon = Beagle.Images.GetPixbuf ("contact-icon.png");
MainWindow.DeleteEvent += OnDeleteEvent;
LoadDatabase ();
Application.Run ();
}
示例12: SetupSpecialActions
protected void SetupSpecialActions()
{
// This demonstrates a shortcut assigned to an action that is
// not attached to a menu widget. This particular one is assigned
// to a textbox entry. I'm not sure that this is the best way
// to do this, but it seems to work. :)
Gtk.ActionGroup specialActions = new Gtk.ActionGroup("Special");
this.specialAction1 = new Gtk.Action("specialAction1", "Special Action 1");
string accelerator = Gtk.Accelerator.Name((uint)Gdk.Key.j, Gdk.ModifierType.ControlMask);
specialActions.Add(this.specialAction1, accelerator);
this.entry1.SetAccelPath(this.specialAction1.AccelPath, this.UIManager.AccelGroup);
this.entry1.Activated += new System.EventHandler(this.OnSpecialAction1Activated);
this.UIManager.InsertActionGroup(specialActions, -1);
}
示例13: AddProjectActions
void AddProjectActions(ActionGroup actionGroup)
{
var guiService = ServiceManager.Get<GuiService> ();
var project = new Gtk.Action ("project", Catalog.GetString ("_Project"));
actionGroup.Add (project);
var addproject = new Gtk.Action ("add-project", Catalog.GetString ("_Add Project"), null, Gtk.Stock.Add);
addproject.Activated += delegate {
guiService.Window.Planning.AppendProject ();
};
actionGroup.Add (addproject, "<Control>plus");
var removeproject = new Gtk.Action ("remove-project", Catalog.GetString ("_Remove Project"), null, Gtk.Stock.Remove);
removeproject.Sensitive = false;
guiService.Window.Planning.ProjectChanged += delegate {
var p = guiService.Window.Planning.SelectedProject;
removeproject.Sensitive = p != null && p.Id > 0;
};
removeproject.Activated += delegate {
guiService.Window.Planning.RemoveSelectedProject ();
};
actionGroup.Add (removeproject);
}
示例14: LircPlugin
public LircPlugin()
{
actions = new ActionGroup("Lirc");
ctrl = new ActionMapper(new BansheeController());
actions.Add(new ActionEntry[] {
new ActionEntry("LircAction", null, "_Lirc", null,
"Configure the Lirc Addin", null),
new ActionEntry("LircConfigureAction", Stock.Properties, "_Configure",
null, "Configure the Lirc addin", OnConfigurePlugin),
});
action_service = ServiceManager.Get<InterfaceActionService>("InterfaceActionService");
action_service.UIManager.InsertActionGroup(actions, 0);
action_service.UIManager.AddUiFromResource("Ui.xml");
}
示例15: LocationsBox
public LocationsBox (Locations locations, UIManager uiManager)
: this(new Builder("locations_box.ui"))
{
Locations = locations;
// create the actions
Gtk.Action create = new Gtk.Action("createLocation","Create Location","",Stock.Add);
create.Activated += OnCreateLocation;
Gtk.Action delete = new Gtk.Action("deleteLocation","Delete Location","",Stock.Remove);
delete.Activated += OnDeleteLocation;
Gtk.Action gotoItem = new Gtk.Action("gotoLocationItem","Goto Item","",Stock.GoForward);
gotoItem.Activated += OnGotoLocationItem;
Gtk.Action action = new Gtk.Action("location","Location");
ActionGroup group = new ActionGroup("location");
group.Add(create);
group.Add(delete);
group.Add(gotoItem);
group.Add(action);
uiManager.InsertActionGroup(group,0);
// create item column with id
TreeViewColumn col = new TreeViewColumn ();
locationsItemColumn = col;
col.Title = "Item";
col.Expand = true;
CellRenderer render;
render = new CellRendererPixbuf ();
col.PackStart (render, false);
col.AddAttribute (render, "pixbuf", 1);
render = new CellRendererText ();
(render as CellRendererText).Editable = true;
render.EditingStarted += OnStartLocationItemEdit;
col.PackStart (render, true);
col.AddAttribute (render, "text", 2);
locationsView.AppendColumn(col);
locationsView.AppendColumn ("ID", new Gtk.CellRendererText (), "text", 3);
// create the labeled column
col = new TreeViewColumn ();
col.Title = "Labeled";
render = new CellRendererToggle ();
(render as CellRendererToggle).Toggled += OnLabeledToggle;
col.PackStart (render, false);
col.AddAttribute (render, "active", 4);
col.AddAttribute (render, "activatable", 5);
locationsView.AppendColumn(col);
// create the amount column
col = new TreeViewColumn ();
col.Title = "Amount";
render = new CellRendererSpin ();
(render as CellRendererText).Editable = true;
(render as CellRendererText).Edited += OnAmountEdited;
Adjustment adj = new Adjustment(0, 0, 0, 0, 0, 0); //set all limits etc to 0
adj.Upper = 1000000000; // assign some special values, that aren't 0
adj.PageIncrement = 10;
adj.StepIncrement = 1;
(render as CellRendererSpin).Adjustment = adj;
col.PackStart (render, false);
col.AddAttribute (render, "text", 6);
locationsView.AppendColumn (col);
//set model etc
locations.CollectionChanged += OnLocationCreation;
TreeModelFilter filter = new LocationsFilter ( new LocationsModel( locations ));
filter.Model.RowInserted += OnRowInserted;
filter.VisibleFunc = new TreeModelFilterVisibleFunc (FilterLocations);
locationsView.Model = filter;
locationsView.Reorderable = true;
// create the items chooser completion
locationCompletion = new LocationItemChooser();
TreeModel compModel = new TreeModelAdapter( new ItemsModel(locations.Inventory.Items));
locationCompletion.Model = compModel;
locationCompletion.MatchFunc = LocationItemCompletionMatch;
locationCompletion.MinimumKeyLength = 0;
// add the item info cell renderer to the completion
render = new CellRendererText ();
locationCompletion.PackStart (render, true);
locationCompletion.AddAttribute (render, "text", 2);
// create the popups
uiManager.AddUiFromResource("locations_box_menues.xml");
locationPopup = (Menu) uiManager.GetWidget("/locationPopup");
}