public SearchEntry() { WidthRequest = 300; Gtk.Menu searchMenu = Menu; Gtk.RadioMenuItem searchMenuItemAll = new Gtk.RadioMenuItem("All"); Gtk.RadioMenuItem searchMenuItemAuthor = new Gtk.RadioMenuItem(searchMenuItemAll, "Author"); Gtk.RadioMenuItem searchMenuItemTitle = new Gtk.RadioMenuItem(searchMenuItemAll, "Title"); Gtk.RadioMenuItem searchMenuItemArticle = new Gtk.RadioMenuItem(searchMenuItemAll, "Article"); searchMenuItemAll.Data.Add("searchField", BibtexSearchField.All); searchMenuItemAuthor.Data.Add("searchField", BibtexSearchField.Author); searchMenuItemTitle.Data.Add("searchField", BibtexSearchField.Title); searchMenuItemArticle.Data.Add("searchField", BibtexSearchField.Article); searchMenu.Add(searchMenuItemAll); searchMenu.Add(searchMenuItemAuthor); searchMenu.Add(searchMenuItemTitle); searchMenu.Add(searchMenuItemArticle); searchMenuItemAll.Activated += OnSearchEntryChanged; searchMenuItemAuthor.Activated += OnSearchEntryChanged; searchMenuItemTitle.Activated += OnSearchEntryChanged; searchMenuItemArticle.Activated += OnSearchEntryChanged; Changed += OnSearchEntryChanged; Show(); }
public RadioMenuItem(Gtk.RadioMenuItem group) : base(IntPtr.Zero) { if (GetType() != typeof(RadioMenuItem)) { var vals = new List <GLib.Value> (); var names = new List <string> (); CreateNativeObject(names.ToArray(), vals.ToArray()); return; } Raw = gtk_radio_menu_item_new_from_widget(group == null ? IntPtr.Zero : group.Handle); }
public override void Wrap(object obj, bool initialized) { base.Wrap(obj, initialized); Gtk.RadioMenuItem radio = (Gtk.RadioMenuItem)Wrapped; if (!initialized) { Group = GroupManager.LastGroup; } else if (radio.Group == null) { Group = radio.Name; } }
public RadioMenuItem(Gtk.RadioMenuItem group, string label) : base(IntPtr.Zero) { if (GetType() != typeof(RadioMenuItem)) { var vals = new List <GLib.Value> (); var names = new List <string> (); if (group != null) { names.Add("label"); vals.Add(new GLib.Value(label)); } CreateNativeObject(names.ToArray(), vals.ToArray()); return; } IntPtr native_label = GLib.Marshaller.StringToPtrGStrdup(label); Raw = gtk_radio_menu_item_new_with_mnemonic_from_widget(group == null ? IntPtr.Zero : group.Handle, native_label); GLib.Marshaller.Free(native_label); }
protected override void OnPressed() { base.OnPressed(); Gtk.Menu menu = new Gtk.Menu(); foreach (ComboItemSet iset in items) { if (iset.Count == 0) { continue; } 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 iset) { Gtk.RadioMenuItem mi = new Gtk.RadioMenuItem(grp, ci.Label.Replace("_", "__")); if (ci.Item == iset.CurrentItem || ci.Item.Equals(iset.CurrentItem)) { mi.Active = true; } ComboItemSet isetLocal = iset; ComboItem ciLocal = ci; mi.Activated += delegate { SelectItem(isetLocal, ciLocal); }; mi.ShowAll(); menu.Insert(mi, -1); } } menu.Popup(null, null, PositionFunc, 0, Gtk.Global.CurrentEventTime); }
public void SetType(MenuItemType type) { string text = label.Text; Gtk.MenuItem newItem = null; switch (type) { case MenuItemType.Normal: if (!(item is Gtk.ImageMenuItem)) { newItem = new Gtk.ImageMenuItem(text); } break; case MenuItemType.CheckBox: if (item.GetType() != typeof(Gtk.CheckMenuItem)) { newItem = new Gtk.CheckMenuItem(text); } break; case MenuItemType.RadioButton: if (!(item is Gtk.RadioMenuItem)) { newItem = new Gtk.RadioMenuItem(text); } break; } if (newItem != null) { if ((newItem is Gtk.CheckMenuItem) && (item is Gtk.CheckMenuItem)) { ((Gtk.CheckMenuItem)item).Active = ((Gtk.CheckMenuItem)newItem).Active; } newItem.Sensitive = item.Sensitive; if (item.Parent != null) { Gtk.Menu m = (Gtk.Menu)item.Parent; int pos = Array.IndexOf(m.Children, item); m.Insert(newItem, pos); m.Remove(item); } newItem.ShowAll(); if (!item.Visible) { newItem.Hide(); } if (enabledEvents != null) { foreach (var ob in enabledEvents) { DisableEvent(ob); } } item = newItem; label = (Gtk.Label)item.Child; if (enabledEvents != null) { foreach (var ob in enabledEvents) { EnableEvent(ob); } } } }
public void JoinGroup(Gtk.RadioMenuItem group_source) { gtk_radio_menu_item_join_group(Handle, group_source == null ? IntPtr.Zero : group_source.Handle); }
public void SetType(MenuItemType type) { string text = label.Text; Gtk.MenuItem newItem = null; switch (type) { case MenuItemType.Normal: if (!(item is Gtk.ImageMenuItem)) newItem = new Gtk.ImageMenuItem (text); break; case MenuItemType.CheckBox: if (item.GetType () != typeof(Gtk.CheckMenuItem)) newItem = new Gtk.CheckMenuItem (text); break; case MenuItemType.RadioButton: if (!(item is Gtk.RadioMenuItem)) newItem = new Gtk.RadioMenuItem (text); break; } if (newItem != null) { if ((newItem is Gtk.CheckMenuItem) && (item is Gtk.CheckMenuItem)) ((Gtk.CheckMenuItem)item).Active = ((Gtk.CheckMenuItem)newItem).Active; newItem.Sensitive = item.Sensitive; if (item.Parent != null) { Gtk.Menu m = (Gtk.Menu)item.Parent; int pos = Array.IndexOf (m.Children, item); m.Insert (newItem, pos); m.Remove (item); } newItem.ShowAll (); if (!item.Visible) newItem.Hide (); if (enabledEvents != null) { foreach (var ob in enabledEvents) DisableEvent (ob); } item = newItem; label = (Gtk.Label) item.Child; if (enabledEvents != null) { foreach (var ob in enabledEvents) EnableEvent (ob); } } }