protected virtual void OnMessageTextViewPopulatePopup(object sender, Gtk.PopulatePopupArgs e) { Trace.Call(sender, e); if (OutputMessageTextView.IsAtUrlTag) { return; } if (Frontend.MainWindow.ShowMenuBar) { return; } Gtk.Menu popup = e.Menu; popup.Prepend(new Gtk.SeparatorMenuItem()); var item = new Gtk.CheckMenuItem(_("Show _Menubar")); item.Active = Frontend.MainWindow.ShowMenuBar; item.Activated += delegate { try { Frontend.MainWindow.ShowMenuBar = true; } catch (Exception ex) { Frontend.ShowException(ex); } }; popup.Prepend(item); popup.ShowAll(); }
void OnSelectIcon(object s, Gtk.ButtonPressEventArgs args) { Gtk.Menu menu = new Gtk.Menu(); Gtk.CheckMenuItem item = new Gtk.CheckMenuItem(Catalog.GetString("Action")); item.DrawAsRadio = true; item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Action); item.Activated += OnSetActionType; menu.Insert(item, -1); item = new Gtk.CheckMenuItem(Catalog.GetString("Radio Action")); item.DrawAsRadio = true; item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Radio); item.Activated += OnSetRadioType; menu.Insert(item, -1); item = new Gtk.CheckMenuItem(Catalog.GetString("Toggle Action")); item.DrawAsRadio = true; item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Toggle); item.Activated += OnSetToggleType; menu.Insert(item, -1); menu.Insert(new Gtk.SeparatorMenuItem(), -1); Gtk.MenuItem itIcons = new Gtk.MenuItem(Catalog.GetString("Select Icon")); menu.Insert(itIcons, -1); IconSelectorMenu menuIcons = new IconSelectorMenu(GetProject()); menuIcons.IconSelected += OnStockSelected; itIcons.Submenu = menuIcons; Gtk.MenuItem it = new Gtk.MenuItem(Catalog.GetString("Clear Icon")); it.Sensitive = (node.Action.GtkAction.StockId != null); it.Activated += OnClearIcon; menu.Insert(it, -1); menu.ShowAll(); uint but = args != null ? args.Event.Button : 1; menu.Popup(null, null, new Gtk.MenuPositionFunc(OnDropMenuPosition), but, Gtk.Global.CurrentEventTime); // Make sure we get the focus after closing the menu, so we can keep browsing buttons // using the keyboard. menu.Hidden += delegate(object sender, EventArgs a) { GrabFocus(); }; if (args != null) { args.RetVal = false; } }
public static Gtk.MenuItem MakeCheckMenuItem (Gtk.Menu menu, string label, EventHandler e, bool enabled, bool active, bool as_radio) { Gtk.CheckMenuItem i = new Gtk.CheckMenuItem (label); i.Activated += e; i.Sensitive = enabled; i.DrawAsRadio = as_radio; i.Active = active; menu.Append(i); i.Show (); return i; }
public static Gtk.MenuItem MakeCheckMenuItem(Gtk.Menu menu, string label, EventHandler e, bool enabled, bool active, bool as_radio) { Gtk.CheckMenuItem i = new Gtk.CheckMenuItem(label); i.Activated += e; i.Sensitive = enabled; i.DrawAsRadio = as_radio; i.Active = active; menu.Append(i); i.Show(); return(i); }
static Gtk.MenuItem CreateMenuItem (ContextMenuItem item) { if (!item.Visible) return null; if (item.IsSeparator) { return new Gtk.SeparatorMenuItem (); } Gtk.MenuItem menuItem; if (item is RadioButtonContextMenuItem) { var radioItem = (RadioButtonContextMenuItem)item; menuItem = new Gtk.CheckMenuItem (item.Label) { Active = radioItem.Checked, DrawAsRadio = true }; } else if (item is CheckBoxContextMenuItem) { var checkItem = (CheckBoxContextMenuItem)item; menuItem = new Gtk.CheckMenuItem (item.Label) { Active = checkItem.Checked }; } else { menuItem = new Gtk.ImageMenuItem (item.Label); } if (item.SubMenu != null && item.SubMenu.Items.Count > 0) { menuItem.Submenu = FromMenu (item.SubMenu); } else { menuItem.Activated += (sender, e) => item.Click (); } menuItem.Sensitive = item.Sensitive; var label = (Gtk.Label) menuItem.Child; label.UseUnderline = item.UseMnemonic; if (item.UseMnemonic) label.TextWithMnemonic = item.Label; if (item.Image != null) { Gtk.ImageMenuItem imageItem = menuItem as Gtk.ImageMenuItem; if (imageItem != null) { var img = new ImageView (item.Image); img.ShowAll (); imageItem.Image = img; GtkWorkarounds.ForceImageOnMenuItem (imageItem); } } return menuItem; }
void OnSelectIcon(object sender, Gtk.ButtonPressEventArgs e) { Gtk.Menu menu = new Gtk.Menu(); Gtk.CheckMenuItem item = new Gtk.CheckMenuItem(Catalog.GetString("Action")); item.DrawAsRadio = true; item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Action); item.Activated += OnSetActionType; menu.Insert(item, -1); item = new Gtk.CheckMenuItem(Catalog.GetString("Radio Action")); item.DrawAsRadio = true; item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Radio); item.Activated += OnSetRadioType; menu.Insert(item, -1); item = new Gtk.CheckMenuItem(Catalog.GetString("Toggle Action")); item.DrawAsRadio = true; item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Toggle); item.Activated += OnSetToggleType; menu.Insert(item, -1); menu.Insert(new Gtk.SeparatorMenuItem(), -1); Gtk.MenuItem itIcons = new Gtk.MenuItem(Catalog.GetString("Select Icon")); menu.Insert(itIcons, -1); IconSelectorMenu menuIcons = new IconSelectorMenu(GetProject()); menuIcons.IconSelected += OnStockSelected; itIcons.Submenu = menuIcons; Gtk.MenuItem it = new Gtk.MenuItem(Catalog.GetString("Clear Icon")); it.Sensitive = (node.Action.GtkAction.StockId != null); it.Activated += OnClearIcon; menu.Insert(it, -1); menu.ShowAll(); menu.Popup(null, null, new Gtk.MenuPositionFunc(OnDropMenuPosition), 3, Gtk.Global.CurrentEventTime); e.RetVal = false; }
public virtual void Initialize(PropertyDescriptor prop) { CheckType(prop); this.prop = prop; mainHBox = new Gtk.HBox(false, 6); PackStart(mainHBox, false, false, 0); if (!prop.Translatable) { return; } button = new Gtk.Button(); try { globe = Gdk.Pixbuf.LoadFromResource("globe.png"); globe_not = Gdk.Pixbuf.LoadFromResource("globe-not.png"); } catch (Exception e) { Console.WriteLine("Error while loading pixbuf: " + e); } image = new Gtk.Image(globe); button.Add(image); button.ButtonPressEvent += ButtonPressed; mainHBox.PackEnd(button, false, false, 0); mainHBox.ShowAll(); menu = new Gtk.Menu(); markItem = new Gtk.CheckMenuItem("Mark for Translation"); markItem.Toggled += ToggleMark; markItem.Show(); menu.Add(markItem); addContextItem = new Gtk.MenuItem("Add Translation Context Hint"); addContextItem.Activated += AddContext; menu.Add(addContextItem); remContextItem = new Gtk.MenuItem("Remove Translation Context Hint"); remContextItem.Activated += RemoveContext; menu.Add(remContextItem); addCommentItem = new Gtk.MenuItem("Add Comment for Translators"); addCommentItem.Activated += AddComment; menu.Add(addCommentItem); remCommentItem = new Gtk.MenuItem("Remove Comment for Translators"); remCommentItem.Activated += RemoveComment; menu.Add(remCommentItem); contextBox = new Gtk.HBox(false, 6); Gtk.Label contextLabel = new Gtk.Label("Translation context"); contextLabel.Xalign = 0.0f; contextBox.PackStart(contextLabel, false, false, 0); contextEntry = new Gtk.Entry(); contextEntry.WidthChars = 8; contextBox.PackStart(contextEntry, true, true, 0); contextBox.ShowAll(); contextEntry.Changed += ContextChanged; commentBox = new Gtk.VBox(false, 3); Gtk.Label commentLabel = new Gtk.Label("Comment for Translators:"); commentLabel.Xalign = 0.0f; commentBox.PackStart(commentLabel, false, false, 0); commentText = new TextBox(3); commentBox.PackStart(commentText, false, false, 0); commentBox.ShowAll(); commentText.Changed += CommentChanged; }
void OnSelectIcon (object sender, Gtk.ButtonPressEventArgs e) { Gtk.Menu menu = new Gtk.Menu (); Gtk.CheckMenuItem item = new Gtk.CheckMenuItem (Catalog.GetString ("Action")); item.DrawAsRadio = true; item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Action); item.Activated += OnSetActionType; menu.Insert (item, -1); item = new Gtk.CheckMenuItem (Catalog.GetString ("Radio Action")); item.DrawAsRadio = true; item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Radio); item.Activated += OnSetRadioType; menu.Insert (item, -1); item = new Gtk.CheckMenuItem (Catalog.GetString ("Toggle Action")); item.DrawAsRadio = true; item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Toggle); item.Activated += OnSetToggleType; menu.Insert (item, -1); menu.Insert (new Gtk.SeparatorMenuItem (), -1); Gtk.MenuItem itIcons = new Gtk.MenuItem (Catalog.GetString ("Select Icon")); menu.Insert (itIcons, -1); IconSelectorMenu menuIcons = new IconSelectorMenu (GetProject ()); menuIcons.IconSelected += OnStockSelected; itIcons.Submenu = menuIcons; Gtk.MenuItem it = new Gtk.MenuItem (Catalog.GetString ("Clear Icon")); it.Sensitive = (node.Action.GtkAction.StockId != null); it.Activated += OnClearIcon; menu.Insert (it, -1); menu.ShowAll (); menu.Popup (null, null, new Gtk.MenuPositionFunc (OnDropMenuPosition), 3, Gtk.Global.CurrentEventTime); e.RetVal = false; }
public MainWindow() : base("Smuxi") { // restore window size / position int width, heigth; if (Frontend.FrontendConfig[Frontend.UIName + "/Interface/Width"] != null) { width = (int) Frontend.FrontendConfig[Frontend.UIName + "/Interface/Width"]; } else { width = 800; } if (Frontend.FrontendConfig[Frontend.UIName + "/Interface/Heigth"] != null) { heigth = (int) Frontend.FrontendConfig[Frontend.UIName + "/Interface/Heigth"]; } else { heigth = 600; } if (width == -1 && heigth == -1) { SetDefaultSize(800, 600); Maximize(); } else if (width == 0 && heigth == 0) { // HACK: map 0/0 to default size as it crashes on Windows :/ SetDefaultSize(800, 600); } else { SetDefaultSize(width, heigth); } int x, y; if (Frontend.FrontendConfig[Frontend.UIName + "/Interface/XPosition"] != null) { x = (int) Frontend.FrontendConfig[Frontend.UIName + "/Interface/XPosition"]; } else { x = 0; } if (Frontend.FrontendConfig[Frontend.UIName + "/Interface/YPosition"] != null) { y = (int) Frontend.FrontendConfig[Frontend.UIName + "/Interface/YPosition"]; } else { y = 0; } if (x == 0 && y == 0) { SetPosition(Gtk.WindowPosition.Center); } else { Move(x, y); } DeleteEvent += OnDeleteEvent; FocusInEvent += OnFocusInEvent; FocusOutEvent += OnFocusOutEvent; WindowStateEvent += OnWindowStateEvent; Gtk.AccelGroup agrp = new Gtk.AccelGroup(); Gtk.AccelKey akey; AddAccelGroup(agrp); // Menu _MenuBar = new Gtk.MenuBar(); Gtk.Menu menu; Gtk.MenuItem item; Gtk.ImageMenuItem image_item; // Menu - File menu = new Gtk.Menu(); item = new Gtk.MenuItem(_("_File")); item.Submenu = menu; _MenuBar.Append(item); item = new Gtk.ImageMenuItem(Gtk.Stock.Preferences, agrp); item.Activated += new EventHandler(_OnPreferencesButtonClicked); menu.Append(item); menu.Append(new Gtk.SeparatorMenuItem()); item = new Gtk.ImageMenuItem(Gtk.Stock.Quit, agrp); item.Activated += new EventHandler(_OnQuitButtonClicked); menu.Append(item); // Menu - Server menu = new Gtk.Menu(); item = new Gtk.MenuItem(_("_Server")); item.Submenu = menu; _MenuBar.Append(item); image_item = new Gtk.ImageMenuItem(_("_Quick Connect")); image_item.Image = new Gtk.Image(Gtk.Stock.Connect, Gtk.IconSize.Menu); image_item.Activated += OnServerQuickConnectButtonClicked; menu.Append(image_item); menu.Append(new Gtk.SeparatorMenuItem()); image_item = new Gtk.ImageMenuItem(Gtk.Stock.Add, agrp); image_item.Activated += OnServerAddButtonClicked; menu.Append(image_item); image_item = new Gtk.ImageMenuItem(_("_Manage")); image_item.Image = new Gtk.Image(Gtk.Stock.Edit, Gtk.IconSize.Menu); image_item.Activated += OnServerManageServersButtonClicked; menu.Append(image_item); // Menu - Chat menu = new Gtk.Menu(); item = new Gtk.MenuItem(_("_Chat")); item.Submenu = menu; _MenuBar.Append(item); _OpenChatMenuItem = new Gtk.ImageMenuItem(_("Open / Join Chat")); _OpenChatMenuItem.Image = new Gtk.Image(Gtk.Stock.Open, Gtk.IconSize.Menu); _OpenChatMenuItem.Activated += OnChatOpenChatButtonClicked; _OpenChatMenuItem.Sensitive = false; menu.Append(_OpenChatMenuItem); _FindGroupChatMenuItem = new Gtk.ImageMenuItem(_("_Find Group Chat")); _FindGroupChatMenuItem.Image = new Gtk.Image(Gtk.Stock.Find, Gtk.IconSize.Menu); _FindGroupChatMenuItem.Activated += OnChatFindGroupChatButtonClicked; _FindGroupChatMenuItem.Sensitive = false; menu.Append(_FindGroupChatMenuItem); image_item = new Gtk.ImageMenuItem(_("C_lear All Activity")); image_item.Image = new Gtk.Image(Gtk.Stock.Clear, Gtk.IconSize.Menu); image_item.Activated += OnChatClearAllActivityButtonClicked; menu.Append(image_item); menu.Append(new Gtk.SeparatorMenuItem()); image_item = new Gtk.ImageMenuItem(_("_Next Chat")); image_item.Image = new Gtk.Image(Gtk.Stock.GoForward, Gtk.IconSize.Menu); image_item.Activated += OnNextChatMenuItemActivated; akey = new Gtk.AccelKey(); akey.AccelFlags = Gtk.AccelFlags.Visible; akey.AccelMods = Gdk.ModifierType.ControlMask; akey.Key = Gdk.Key.Page_Down; image_item.AddAccelerator("activate", agrp, akey); menu.Append(image_item); image_item = new Gtk.ImageMenuItem(_("_Previous Chat")); image_item.Image = new Gtk.Image(Gtk.Stock.GoBack, Gtk.IconSize.Menu); image_item.Activated += OnPreviousChatMenuItemActivated; akey = new Gtk.AccelKey(); akey.AccelFlags = Gtk.AccelFlags.Visible; akey.AccelMods = Gdk.ModifierType.ControlMask; akey.Key = Gdk.Key.Page_Up; image_item.AddAccelerator("activate", agrp, akey); menu.Append(image_item); menu.Append(new Gtk.SeparatorMenuItem()); /* // TODO: make a radio item for each chat hotkey Gtk.RadioMenuItem radio_item; radio_item = new Gtk.RadioMenuItem(); radio_item = new Gtk.RadioMenuItem(radio_item); radio_item = new Gtk.RadioMenuItem(radio_item); menu.Append(new Gtk.SeparatorMenuItem()); */ /* image_item = new Gtk.ImageMenuItem(Gtk.Stock.Find, agrp); image_item.Activated += OnFindChatMenuItemActivated; menu.Append(image_item); item = new Gtk.MenuItem(_("Find _Next")); item.Activated += OnFindNextChatMenuItemActivated; akey = new Gtk.AccelKey(); akey.AccelFlags = Gtk.AccelFlags.Visible; akey.AccelMods = Gdk.ModifierType.ControlMask; akey.Key = Gdk.Key.G; item.AddAccelerator("activate", agrp, akey); menu.Append(item); item = new Gtk.MenuItem(_("Find _Previous")); item.Activated += OnFindPreviousChatMenuItemActivated; akey = new Gtk.AccelKey(); akey.AccelFlags = Gtk.AccelFlags.Visible; akey.AccelMods = Gdk.ModifierType.ControlMask | Gdk.ModifierType.ShiftMask; akey.Key = Gdk.Key.G; item.AddAccelerator("activate", agrp, akey); menu.Append(item); */ // ROFL: the empty code statement below is needed to keep stupid // gettext away from using all the commented code from above as // translator comment ; _OpenLogChatMenuItem = new Gtk.ImageMenuItem(_("Open Log")); _OpenLogChatMenuItem.Image = new Gtk.Image(Gtk.Stock.Open, Gtk.IconSize.Menu); _OpenLogChatMenuItem.Activated += OnOpenLogChatMenuItemActivated; _OpenLogChatMenuItem.Sensitive = false; _OpenLogChatMenuItem.NoShowAll = true; menu.Append(_OpenLogChatMenuItem); _CloseChatMenuItem = new Gtk.ImageMenuItem(Gtk.Stock.Close, agrp); _CloseChatMenuItem.Activated += OnCloseChatMenuItemActivated; menu.Append(_CloseChatMenuItem); // Menu - Engine menu = new Gtk.Menu(); item = new Gtk.MenuItem(_("_Engine")); item.Submenu = menu; _MenuBar.Append(item); item = new Gtk.MenuItem(_("_Use Local Engine")); item.Activated += new EventHandler(_OnUseLocalEngineButtonClicked); menu.Append(item); menu.Append(new Gtk.SeparatorMenuItem()); image_item = new Gtk.ImageMenuItem(_("_Add Remote Engine")); image_item.Image = new Gtk.Image(Gtk.Stock.Add, Gtk.IconSize.Menu); image_item.Activated += new EventHandler(_OnAddRemoteEngineButtonClicked); menu.Append(image_item); image_item = new Gtk.ImageMenuItem(_("_Switch Remote Engine")); image_item.Image = new Gtk.Image(Gtk.Stock.Refresh, Gtk.IconSize.Menu); image_item.Activated += new EventHandler(_OnSwitchRemoteEngineButtonClicked); menu.Append(image_item); // Menu - View menu = new Gtk.Menu(); item = new Gtk.MenuItem(_("_View")); item.Submenu = menu; _MenuBar.Append(item); item = new Gtk.CheckMenuItem(_("_Caret Mode")); item.Activated += new EventHandler(_OnCaretModeButtonClicked); akey = new Gtk.AccelKey(); akey.AccelFlags = Gtk.AccelFlags.Visible; akey.Key = Gdk.Key.F7; item.AddAccelerator("activate", agrp, akey); menu.Append(item); item = new Gtk.CheckMenuItem(_("_Browse Mode")); item.Activated += delegate { try { _Notebook.IsBrowseModeEnabled = !_Notebook.IsBrowseModeEnabled; } catch (Exception ex) { Frontend.ShowException(this, ex); } }; akey = new Gtk.AccelKey(); akey.AccelFlags = Gtk.AccelFlags.Visible; akey.Key = Gdk.Key.F8; item.AddAccelerator("activate", agrp, akey); menu.Append(item); _ShowMenuBarItem = new Gtk.CheckMenuItem(_("Show _Menubar")); _ShowMenuBarItem.Active = true; _ShowMenuBarItem.Activated += delegate { try { _MenuBar.Visible = !_MenuBar.Visible; } catch (Exception ex) { Frontend.ShowException(this, ex); } }; menu.Append(_ShowMenuBarItem); item = new Gtk.ImageMenuItem(Gtk.Stock.Fullscreen, agrp); item.Activated += delegate { try { IsFullscreen = !IsFullscreen; } catch (Exception ex) { Frontend.ShowException(this, ex); } }; akey = new Gtk.AccelKey(); akey.AccelFlags = Gtk.AccelFlags.Visible; akey.Key = Gdk.Key.F11; item.AddAccelerator("activate", agrp, akey); menu.Append(item); // Menu - Help menu = new Gtk.Menu(); item = new Gtk.MenuItem(_("_Help")); item.Submenu = menu; _MenuBar.Append(item); image_item = new Gtk.ImageMenuItem(Gtk.Stock.About, agrp); image_item.Activated += new EventHandler(_OnAboutButtonClicked); menu.Append(image_item); // TODO: network treeview _Notebook = new Notebook(); _Notebook.SwitchPage += OnNotebookSwitchPage; _ChatViewManager = new ChatViewManager(_Notebook, null); Assembly asm = Assembly.GetExecutingAssembly(); _ChatViewManager.Load(asm); _ChatViewManager.LoadAll(System.IO.Path.GetDirectoryName(asm.Location), "smuxi-frontend-gnome-*.dll"); _ChatViewManager.ChatAdded += OnChatViewManagerChatAdded; _ChatViewManager.ChatRemoved += OnChatViewManagerChatRemoved; #if GTK_SHARP_2_10 _StatusIconManager = new StatusIconManager(this, _ChatViewManager); #endif #if INDICATE_SHARP _IndicateManager = new IndicateManager(this, _ChatViewManager); #endif #if NOTIFY_SHARP _NotifyManager = new NotifyManager(this, _ChatViewManager); #endif _UI = new GnomeUI(_ChatViewManager); // HACK: Frontend.FrontendConfig out of scope _EngineManager = new EngineManager(Frontend.FrontendConfig, _UI); _Entry = new Entry(_Notebook); _ProgressBar = new Gtk.ProgressBar(); Gtk.VBox vbox = new Gtk.VBox(); vbox.PackStart(_MenuBar, false, false, 0); vbox.PackStart(_Notebook, true, true, 0); vbox.PackStart(_Entry, false, false, 0); _NetworkStatusbar = new Gtk.Statusbar(); _NetworkStatusbar.WidthRequest = 300; _NetworkStatusbar.HasResizeGrip = false; _Statusbar = new Gtk.Statusbar(); _Statusbar.HasResizeGrip = false; Gtk.HBox status_bar_hbox = new Gtk.HBox(); status_bar_hbox.Homogeneous = true; status_bar_hbox.PackStart(_NetworkStatusbar, false, true, 0); status_bar_hbox.PackStart(_Statusbar, true, true, 0); Gtk.HBox status_hbox = new Gtk.HBox(); status_hbox.PackStart(status_bar_hbox); status_hbox.PackStart(_ProgressBar, false, false, 0); vbox.PackStart(status_hbox, false, false, 0); Add(vbox); }
static Gtk.MenuItem CreateMenuItem(ContextMenuItem item) { if (!item.Visible) { return(null); } if (item.IsSeparator) { return(new Gtk.SeparatorMenuItem()); } Gtk.MenuItem menuItem; if (item is RadioButtonContextMenuItem) { var radioItem = (RadioButtonContextMenuItem)item; menuItem = new Gtk.CheckMenuItem(item.Label) { Active = radioItem.Checked, DrawAsRadio = true }; } else if (item is CheckBoxContextMenuItem) { var checkItem = (CheckBoxContextMenuItem)item; menuItem = new Gtk.CheckMenuItem(item.Label) { Active = checkItem.Checked }; } else { menuItem = new Gtk.ImageMenuItem(item.Label); } if (item.SubMenu != null && item.SubMenu.Items.Count > 0) { menuItem.Submenu = FromMenu(item.SubMenu, null); } else { menuItem.Activated += (sender, e) => item.Click(); } menuItem.Sensitive = item.Sensitive; var label = (Gtk.Label)menuItem.Child; label.UseUnderline = item.UseMnemonic; if (item.UseMnemonic) { label.TextWithMnemonic = item.Label; } if (item.Image != null) { Gtk.ImageMenuItem imageItem = menuItem as Gtk.ImageMenuItem; if (imageItem != null) { var img = new ImageView(item.Image); img.ShowAll(); imageItem.Image = img; Xwt.GtkBackend.GtkWorkarounds.ForceImageOnMenuItem(imageItem); } } return(menuItem); }
/// <summary> /// Creates a menu item for command. /// </summary> /// <param name="command">The command for which a menu item is to be created.</param> /// <param name="parentMenu">The menu to put the menu item into.</param> /// <param name="parentCommand">Parent command for the given command.</param> /// <param name="stockItem">If non-Zero, defines the stock item to use for the command.</param> /// <param name="menuItemType">A specific type of menu item to use.</param> /// <param name="stateData">If not <c>null</c>, state data for the menu item being created.</param> /// <returns>The menu item for the command.</returns> public static OSMenuItem CreateMenuItem(this VisualRelayCommand command, Gtk.MenuShell parentMenu, VisualRelayCommand parentCommand, Gtk.StockItem stockItem, System.Type menuItemType = null, object stateData = null) { var useDefaultMenuHandler = true; Gtk.MenuItem menuItemVisual; if (command.UniqueId == RootCommandGroup.MenuSeparatorCommand.UniqueId) { menuItemVisual = new Gtk.SeparatorMenuItem(); useDefaultMenuHandler = false; } else if (menuItemType == typeof(Gtk.CheckMenuItem)) { var checkMenuItem = new Gtk.CheckMenuItem(command.MenuItemName); checkMenuItem.Active = (bool)stateData; menuItemVisual = checkMenuItem; useDefaultMenuHandler = false; } else if ((command.SmallIcon != null) || (stockItem.StockId != Gtk.StockItem.Zero.StockId)) { if (stockItem.StockId == Gtk.StockItem.Zero.StockId) { menuItemVisual = new Gtk.ImageMenuItem(command.MenuItemName) { Image = new Gtk.Image(command.SmallIcon) }; if (Properties.Settings.Default.EnableMenuIcons) { // NOTE: This causes some internal errors if we try to draw stock items. So don't do it. menuItemVisual.ExposeEvent += ImageMenuItemHackExposeEvent; } } else { menuItemVisual = new Gtk.ImageMenuItem(stockItem.StockId, null); } } else { menuItemVisual = new Gtk.MenuItem(command.MenuItemName); } menuItemVisual.Name = command.UniqueId; menuItemVisual.SetValue(CommandGroup.AttachedCommandPropertyName, command); var submenu = command.Visual.AsType <Gtk.Menu>(); if ((submenu == null) && (parentMenu is Gtk.MenuBar) && command.Visual.IsEmpty) { submenu = new Gtk.Menu() { Name = parentCommand.UniqueId }; command.Visual = submenu; } menuItemVisual.Submenu = submenu; var insertLocation = FindInsertLocation(parentCommand, command, true); if ((insertLocation < 0) || (insertLocation >= parentMenu.Children.Length)) { parentMenu.Append(menuItemVisual); } else { parentMenu.Insert(menuItemVisual, insertLocation); } if (useDefaultMenuHandler && (menuItemVisual.Submenu == null)) { menuItemVisual.Activated += HandleCommand; } if (!string.IsNullOrEmpty(command.KeyboardShortcutKey)) { command.AddAccelerator(menuItemVisual, command.GetAcceleratorKey()); } menuItemVisual.ShowAll(); // because programmatically created, need to show ////DebugOutputIf(requiresParentCommand && (parentCommand.MenuItem.IsEmpty) && (parentCommand.Visual.IsEmpty), "Failed to create parent menu item for command: " + command.Name + "(" + command.UniqueId + ")"); ////DebugOutputIf(requiresParentCommand && (parentCommand == null) && (parentCommand.Visual.IsEmpty), "No parent menu item for command: " + command.Name + "(" + command.UniqueId + ")"); if (menuItemVisual != null) { var group = command.GetCommandGroup() as CommandGroup; if (group != null) { var context = group.GetCommandContext(command, null); menuItemVisual.SetValue(IFakeDependencyObjectHelpers.DataContextPropertyName, context); group.AttachCanExecuteChangeHandler(command); } } return(menuItemVisual); }
static Gtk.MenuItem CreateMenuItem (ContextMenuItem item) { if (!item.Visible) return null; if (item.IsSeparator) { return new Gtk.SeparatorMenuItem (); } Gtk.MenuItem menuItem; if (item is RadioButtonContextMenuItem) { var radioItem = (RadioButtonContextMenuItem)item; menuItem = new Gtk.CheckMenuItem (item.Label) { Active = radioItem.Checked, DrawAsRadio = true }; } else if (item is CheckBoxContextMenuItem) { var checkItem = (CheckBoxContextMenuItem)item; menuItem = new Gtk.CheckMenuItem (item.Label) { Active = checkItem.Checked }; } else { menuItem = new Gtk.ImageMenuItem (item.Label); } menuItem.Selected += delegate (object sender, EventArgs e) { var si = sender as Gtk.MenuItem; if (si == null || si.GdkWindow == null) return; int x, y; si.GdkWindow.GetOrigin (out x, out y); int rx, ry; IdeApp.Workbench.RootWindow.GdkWindow.GetOrigin (out rx, out ry); item.FireSelectedEvent (new Xwt.Rectangle (x - rx, y - ry, si.Allocation.Width, si.Allocation.Height)); }; menuItem.Deselected += delegate { item.FireDeselectedEvent (); }; if (item.SubMenu != null && item.SubMenu.Items.Count > 0) { menuItem.Submenu = FromMenu (item.SubMenu, null); } else { menuItem.Activated += (sender, e) => item.Click (); } menuItem.Sensitive = item.Sensitive; var label = (Gtk.Label) menuItem.Child; label.UseUnderline = item.UseMnemonic; if (item.UseMnemonic) label.TextWithMnemonic = item.Label; if (item.Image != null) { Gtk.ImageMenuItem imageItem = menuItem as Gtk.ImageMenuItem; if (imageItem != null) { var img = new ImageView (item.Image); img.ShowAll (); imageItem.Image = img; Xwt.GtkBackend.GtkWorkarounds.ForceImageOnMenuItem (imageItem); } } return menuItem; }
public MainWindow() : base("Smuxi") { // restore window size / position int width, heigth; if (Frontend.FrontendConfig[Frontend.UIName + "/Interface/Width"] != null) { width = (int)Frontend.FrontendConfig[Frontend.UIName + "/Interface/Width"]; } else { width = 800; } if (Frontend.FrontendConfig[Frontend.UIName + "/Interface/Heigth"] != null) { heigth = (int)Frontend.FrontendConfig[Frontend.UIName + "/Interface/Heigth"]; } else { heigth = 600; } if (width < -1 || heigth < -1) { width = -1; heigth = -1; } if (width == -1 && heigth == -1) { SetDefaultSize(800, 600); Maximize(); } else if (width == 0 && heigth == 0) { // HACK: map 0/0 to default size as it crashes on Windows :/ SetDefaultSize(800, 600); } else { SetDefaultSize(width, heigth); } int x, y; if (Frontend.FrontendConfig[Frontend.UIName + "/Interface/XPosition"] != null) { x = (int)Frontend.FrontendConfig[Frontend.UIName + "/Interface/XPosition"]; } else { x = 0; } if (Frontend.FrontendConfig[Frontend.UIName + "/Interface/YPosition"] != null) { y = (int)Frontend.FrontendConfig[Frontend.UIName + "/Interface/YPosition"]; } else { y = 0; } if (x < 0 || y < 0) { x = 0; y = 0; } if (x == 0 && y == 0) { SetPosition(Gtk.WindowPosition.Center); } else { Move(x, y); } DeleteEvent += OnDeleteEvent; FocusInEvent += OnFocusInEvent; FocusOutEvent += OnFocusOutEvent; WindowStateEvent += OnWindowStateEvent; Gtk.AccelGroup agrp = new Gtk.AccelGroup(); Gtk.AccelKey akey; AddAccelGroup(agrp); // Menu _MenuBar = new Gtk.MenuBar(); Gtk.Menu menu; Gtk.MenuItem item; Gtk.ImageMenuItem image_item; // Menu - File menu = new Gtk.Menu(); item = new Gtk.MenuItem(_("_File")); item.Submenu = menu; _MenuBar.Append(item); item = new Gtk.ImageMenuItem(Gtk.Stock.Preferences, agrp); item.Activated += new EventHandler(_OnPreferencesButtonClicked); menu.Append(item); menu.Append(new Gtk.SeparatorMenuItem()); item = new Gtk.ImageMenuItem(Gtk.Stock.Quit, agrp); item.Activated += new EventHandler(_OnQuitButtonClicked); menu.Append(item); // Menu - Server menu = new Gtk.Menu(); item = new Gtk.MenuItem(_("_Server")); item.Submenu = menu; _MenuBar.Append(item); image_item = new Gtk.ImageMenuItem(_("_Quick Connect")); image_item.Image = new Gtk.Image(Gtk.Stock.Connect, Gtk.IconSize.Menu); image_item.Activated += OnServerQuickConnectButtonClicked; menu.Append(image_item); menu.Append(new Gtk.SeparatorMenuItem()); image_item = new Gtk.ImageMenuItem(Gtk.Stock.Add, agrp); image_item.Activated += OnServerAddButtonClicked; menu.Append(image_item); image_item = new Gtk.ImageMenuItem(_("_Manage")); image_item.Image = new Gtk.Image(Gtk.Stock.Edit, Gtk.IconSize.Menu); image_item.Activated += OnServerManageServersButtonClicked; menu.Append(image_item); // Menu - Chat menu = new Gtk.Menu(); item = new Gtk.MenuItem(_("_Chat")); item.Submenu = menu; _MenuBar.Append(item); _OpenChatMenuItem = new Gtk.ImageMenuItem(_("Open / Join Chat")); _OpenChatMenuItem.Image = new Gtk.Image(Gtk.Stock.Open, Gtk.IconSize.Menu); _OpenChatMenuItem.Activated += OnChatOpenChatButtonClicked; _OpenChatMenuItem.Sensitive = false; menu.Append(_OpenChatMenuItem); _FindGroupChatMenuItem = new Gtk.ImageMenuItem(_("_Find Group Chat")); _FindGroupChatMenuItem.Image = new Gtk.Image(Gtk.Stock.Find, Gtk.IconSize.Menu); _FindGroupChatMenuItem.Activated += OnChatFindGroupChatButtonClicked; _FindGroupChatMenuItem.Sensitive = false; menu.Append(_FindGroupChatMenuItem); image_item = new Gtk.ImageMenuItem(_("C_lear All Activity")); image_item.Image = new Gtk.Image(Gtk.Stock.Clear, Gtk.IconSize.Menu); image_item.Activated += OnChatClearAllActivityButtonClicked; menu.Append(image_item); menu.Append(new Gtk.SeparatorMenuItem()); image_item = new Gtk.ImageMenuItem(_("_Next Chat")); image_item.Image = new Gtk.Image(Gtk.Stock.GoForward, Gtk.IconSize.Menu); image_item.Activated += OnNextChatMenuItemActivated; akey = new Gtk.AccelKey(); akey.AccelFlags = Gtk.AccelFlags.Visible; akey.AccelMods = Gdk.ModifierType.ControlMask; akey.Key = Gdk.Key.Page_Down; image_item.AddAccelerator("activate", agrp, akey); menu.Append(image_item); image_item = new Gtk.ImageMenuItem(_("_Previous Chat")); image_item.Image = new Gtk.Image(Gtk.Stock.GoBack, Gtk.IconSize.Menu); image_item.Activated += OnPreviousChatMenuItemActivated; akey = new Gtk.AccelKey(); akey.AccelFlags = Gtk.AccelFlags.Visible; akey.AccelMods = Gdk.ModifierType.ControlMask; akey.Key = Gdk.Key.Page_Up; image_item.AddAccelerator("activate", agrp, akey); menu.Append(image_item); menu.Append(new Gtk.SeparatorMenuItem()); /* * // TODO: make a radio item for each chat hotkey * Gtk.RadioMenuItem radio_item; * radio_item = new Gtk.RadioMenuItem(); * radio_item = new Gtk.RadioMenuItem(radio_item); * radio_item = new Gtk.RadioMenuItem(radio_item); * * menu.Append(new Gtk.SeparatorMenuItem()); */ /* * image_item = new Gtk.ImageMenuItem(Gtk.Stock.Find, agrp); * image_item.Activated += OnFindChatMenuItemActivated; * menu.Append(image_item); * * item = new Gtk.MenuItem(_("Find _Next")); * item.Activated += OnFindNextChatMenuItemActivated; * akey = new Gtk.AccelKey(); * akey.AccelFlags = Gtk.AccelFlags.Visible; * akey.AccelMods = Gdk.ModifierType.ControlMask; * akey.Key = Gdk.Key.G; * item.AddAccelerator("activate", agrp, akey); * menu.Append(item); * * item = new Gtk.MenuItem(_("Find _Previous")); * item.Activated += OnFindPreviousChatMenuItemActivated; * akey = new Gtk.AccelKey(); * akey.AccelFlags = Gtk.AccelFlags.Visible; * akey.AccelMods = Gdk.ModifierType.ControlMask | Gdk.ModifierType.ShiftMask; * akey.Key = Gdk.Key.G; * item.AddAccelerator("activate", agrp, akey); * menu.Append(item); */ // ROFL: the empty code statement below is needed to keep stupid // gettext away from using all the commented code from above as // translator comment ; _OpenLogChatMenuItem = new Gtk.ImageMenuItem(_("Open Log")); _OpenLogChatMenuItem.Image = new Gtk.Image(Gtk.Stock.Open, Gtk.IconSize.Menu); _OpenLogChatMenuItem.Activated += OnOpenLogChatMenuItemActivated; _OpenLogChatMenuItem.Sensitive = false; _OpenLogChatMenuItem.NoShowAll = true; menu.Append(_OpenLogChatMenuItem); _CloseChatMenuItem = new Gtk.ImageMenuItem(Gtk.Stock.Close, agrp); _CloseChatMenuItem.Activated += OnCloseChatMenuItemActivated; menu.Append(_CloseChatMenuItem); // Menu - Engine menu = new Gtk.Menu(); item = new Gtk.MenuItem(_("_Engine")); item.Submenu = menu; _MenuBar.Append(item); item = new Gtk.MenuItem(_("_Use Local Engine")); item.Activated += new EventHandler(_OnUseLocalEngineButtonClicked); menu.Append(item); menu.Append(new Gtk.SeparatorMenuItem()); image_item = new Gtk.ImageMenuItem(_("_Add Remote Engine")); image_item.Image = new Gtk.Image(Gtk.Stock.Add, Gtk.IconSize.Menu); image_item.Activated += new EventHandler(_OnAddRemoteEngineButtonClicked); menu.Append(image_item); image_item = new Gtk.ImageMenuItem(_("_Switch Remote Engine")); image_item.Image = new Gtk.Image(Gtk.Stock.Refresh, Gtk.IconSize.Menu); image_item.Activated += new EventHandler(_OnSwitchRemoteEngineButtonClicked); menu.Append(image_item); // Menu - View menu = new Gtk.Menu(); item = new Gtk.MenuItem(_("_View")); item.Submenu = menu; _MenuBar.Append(item); item = new Gtk.CheckMenuItem(_("_Caret Mode")); item.Activated += new EventHandler(_OnCaretModeButtonClicked); akey = new Gtk.AccelKey(); akey.AccelFlags = Gtk.AccelFlags.Visible; akey.Key = Gdk.Key.F7; item.AddAccelerator("activate", agrp, akey); menu.Append(item); item = new Gtk.CheckMenuItem(_("_Browse Mode")); item.Activated += delegate { try { _Notebook.IsBrowseModeEnabled = !_Notebook.IsBrowseModeEnabled; } catch (Exception ex) { Frontend.ShowException(this, ex); } }; akey = new Gtk.AccelKey(); akey.AccelFlags = Gtk.AccelFlags.Visible; akey.Key = Gdk.Key.F8; item.AddAccelerator("activate", agrp, akey); menu.Append(item); _ShowMenuBarItem = new Gtk.CheckMenuItem(_("Show _Menubar")); _ShowMenuBarItem.Active = true; _ShowMenuBarItem.Activated += delegate { try { _MenuBar.Visible = !_MenuBar.Visible; } catch (Exception ex) { Frontend.ShowException(this, ex); } }; menu.Append(_ShowMenuBarItem); item = new Gtk.ImageMenuItem(Gtk.Stock.Fullscreen, agrp); item.Activated += delegate { try { IsFullscreen = !IsFullscreen; } catch (Exception ex) { Frontend.ShowException(this, ex); } }; akey = new Gtk.AccelKey(); akey.AccelFlags = Gtk.AccelFlags.Visible; akey.Key = Gdk.Key.F11; item.AddAccelerator("activate", agrp, akey); menu.Append(item); // Menu - Help menu = new Gtk.Menu(); item = new Gtk.MenuItem(_("_Help")); item.Submenu = menu; _MenuBar.Append(item); image_item = new Gtk.ImageMenuItem(Gtk.Stock.About, agrp); image_item.Activated += new EventHandler(_OnAboutButtonClicked); menu.Append(image_item); // TODO: network treeview _Notebook = new Notebook(); _Notebook.SwitchPage += OnNotebookSwitchPage; _ChatViewManager = new ChatViewManager(_Notebook, null); Assembly asm = Assembly.GetExecutingAssembly(); _ChatViewManager.Load(asm); _ChatViewManager.LoadAll(System.IO.Path.GetDirectoryName(asm.Location), "smuxi-frontend-gnome-*.dll"); _ChatViewManager.ChatAdded += OnChatViewManagerChatAdded; _ChatViewManager.ChatSynced += OnChatViewManagerChatSynced; _ChatViewManager.ChatRemoved += OnChatViewManagerChatRemoved; #if GTK_SHARP_2_10 _StatusIconManager = new StatusIconManager(this, _ChatViewManager); #endif #if INDICATE_SHARP _IndicateManager = new IndicateManager(this, _ChatViewManager); #endif #if NOTIFY_SHARP _NotifyManager = new NotifyManager(this, _ChatViewManager); #endif #if IPC_DBUS _NetworkManager = new NetworkManager(_ChatViewManager); #endif _UI = new GnomeUI(_ChatViewManager); // HACK: Frontend.FrontendConfig out of scope _EngineManager = new EngineManager(Frontend.FrontendConfig, _UI); _Entry = new Entry(_ChatViewManager); _ProgressBar = new Gtk.ProgressBar(); _ProgressBar.BarStyle = Gtk.ProgressBarStyle.Continuous; Gtk.VBox vbox = new Gtk.VBox(); vbox.PackStart(_MenuBar, false, false, 0); vbox.PackStart(_Notebook, true, true, 0); vbox.PackStart(_Entry, false, false, 0); _NetworkStatusbar = new Gtk.Statusbar(); _NetworkStatusbar.WidthRequest = 300; _NetworkStatusbar.HasResizeGrip = false; _Statusbar = new Gtk.Statusbar(); _Statusbar.HasResizeGrip = false; Gtk.HBox status_bar_hbox = new Gtk.HBox(); status_bar_hbox.Homogeneous = true; status_bar_hbox.PackStart(_NetworkStatusbar, false, true, 0); status_bar_hbox.PackStart(_Statusbar, true, true, 0); Gtk.HBox status_hbox = new Gtk.HBox(); status_hbox.PackStart(status_bar_hbox); status_hbox.PackStart(_ProgressBar, false, false, 0); vbox.PackStart(status_hbox, false, false, 0); Add(vbox); }
public MainWindow() : base("Smuxi") { // restore window size / position int width, heigth; if (Frontend.FrontendConfig[Frontend.UIName + "/Interface/Width"] != null) { width = (int) Frontend.FrontendConfig[Frontend.UIName + "/Interface/Width"]; } else { width = 800; } if (Frontend.FrontendConfig[Frontend.UIName + "/Interface/Heigth"] != null) { heigth = (int) Frontend.FrontendConfig[Frontend.UIName + "/Interface/Heigth"]; } else { heigth = 600; } if (width < -1 || heigth < -1) { width = -1; heigth = -1; } if (width == -1 && heigth == -1) { SetDefaultSize(800, 600); Maximize(); } else if (width == 0 && heigth == 0) { // HACK: map 0/0 to default size as it crashes on Windows :/ SetDefaultSize(800, 600); } else { SetDefaultSize(width, heigth); } int x, y; if (Frontend.FrontendConfig[Frontend.UIName + "/Interface/XPosition"] != null) { x = (int) Frontend.FrontendConfig[Frontend.UIName + "/Interface/XPosition"]; } else { x = 0; } if (Frontend.FrontendConfig[Frontend.UIName + "/Interface/YPosition"] != null) { y = (int) Frontend.FrontendConfig[Frontend.UIName + "/Interface/YPosition"]; } else { y = 0; } if (x < 0 || y < 0) { x = 0; y = 0; } if (x == 0 && y == 0) { SetPosition(Gtk.WindowPosition.Center); } else { Move(x, y); } DeleteEvent += OnDeleteEvent; FocusInEvent += OnFocusInEvent; FocusOutEvent += OnFocusOutEvent; WindowStateEvent += OnWindowStateEvent; Gtk.AccelGroup agrp = new Gtk.AccelGroup(); Gtk.AccelKey akey; AddAccelGroup(agrp); // Menu MenuBar = new Gtk.MenuBar(); Gtk.Menu menu; Gtk.MenuItem item; Gtk.ImageMenuItem image_item; // Menu - File menu = new Gtk.Menu(); item = new Gtk.MenuItem(_("_File")); item.Submenu = menu; MenuBar.Append(item); item = new Gtk.ImageMenuItem(Gtk.Stock.Preferences, agrp); item.Activated += new EventHandler(_OnPreferencesButtonClicked); item.AccelCanActivate += AccelCanActivateSensitive; menu.Append(item); menu.Append(new Gtk.SeparatorMenuItem()); item = new Gtk.ImageMenuItem(Gtk.Stock.Quit, agrp); item.Activated += new EventHandler(_OnQuitButtonClicked); item.AccelCanActivate += AccelCanActivateSensitive; menu.Append(item); // Menu - Server menu = new Gtk.Menu(); item = new Gtk.MenuItem(_("_Server")); item.Submenu = menu; MenuBar.Append(item); image_item = new Gtk.ImageMenuItem(_("_Quick Connect")); image_item.Image = new Gtk.Image(Gtk.Stock.Connect, Gtk.IconSize.Menu); image_item.Activated += OnServerQuickConnectButtonClicked; menu.Append(image_item); menu.Append(new Gtk.SeparatorMenuItem()); image_item = new Gtk.ImageMenuItem(Gtk.Stock.Add, agrp); image_item.Activated += OnServerAddButtonClicked; menu.Append(image_item); image_item = new Gtk.ImageMenuItem(_("_Manage")); image_item.Image = new Gtk.Image(Gtk.Stock.Edit, Gtk.IconSize.Menu); image_item.Activated += OnServerManageServersButtonClicked; menu.Append(image_item); // Menu - Chat menu = new Gtk.Menu(); item = new Gtk.MenuItem(_("_Chat")); item.Submenu = menu; MenuBar.Append(item); _OpenChatMenuItem = new Gtk.ImageMenuItem(_("Open / Join Chat")); _OpenChatMenuItem.Image = new Gtk.Image(Gtk.Stock.Open, Gtk.IconSize.Menu); _OpenChatMenuItem.Activated += OnOpenChatMenuItemActivated; akey = new Gtk.AccelKey(); akey.AccelFlags = Gtk.AccelFlags.Visible; akey.AccelMods = Gdk.ModifierType.ControlMask; akey.Key = Gdk.Key.L; _OpenChatMenuItem.AddAccelerator("activate", agrp, akey); _OpenChatMenuItem.AccelCanActivate += AccelCanActivateSensitive; menu.Append(_OpenChatMenuItem); _FindGroupChatMenuItem = new Gtk.ImageMenuItem(_("_Find Group Chat")); _FindGroupChatMenuItem.Image = new Gtk.Image(Gtk.Stock.Find, Gtk.IconSize.Menu); _FindGroupChatMenuItem.Activated += OnChatFindGroupChatButtonClicked; _FindGroupChatMenuItem.Sensitive = false; menu.Append(_FindGroupChatMenuItem); image_item = new Gtk.ImageMenuItem(_("C_lear All Activity")); image_item.Image = new Gtk.Image(Gtk.Stock.Clear, Gtk.IconSize.Menu); image_item.Activated += OnChatClearAllActivityButtonClicked; menu.Append(image_item); menu.Append(new Gtk.SeparatorMenuItem()); image_item = new Gtk.ImageMenuItem(_("_Next Chat")); image_item.Image = new Gtk.Image(Gtk.Stock.GoForward, Gtk.IconSize.Menu); image_item.Activated += OnNextChatMenuItemActivated; akey = new Gtk.AccelKey(); akey.AccelFlags = Gtk.AccelFlags.Visible; akey.AccelMods = Gdk.ModifierType.ControlMask; akey.Key = Gdk.Key.Page_Down; image_item.AddAccelerator("activate", agrp, akey); image_item.AccelCanActivate += AccelCanActivateSensitive; menu.Append(image_item); image_item = new Gtk.ImageMenuItem(_("_Previous Chat")); image_item.Image = new Gtk.Image(Gtk.Stock.GoBack, Gtk.IconSize.Menu); image_item.Activated += OnPreviousChatMenuItemActivated; akey = new Gtk.AccelKey(); akey.AccelFlags = Gtk.AccelFlags.Visible; akey.AccelMods = Gdk.ModifierType.ControlMask; akey.Key = Gdk.Key.Page_Up; image_item.AddAccelerator("activate", agrp, akey); image_item.AccelCanActivate += AccelCanActivateSensitive; menu.Append(image_item); menu.Append(new Gtk.SeparatorMenuItem()); /* // TODO: make a radio item for each chat hotkey Gtk.RadioMenuItem radio_item; radio_item = new Gtk.RadioMenuItem(); radio_item = new Gtk.RadioMenuItem(radio_item); radio_item = new Gtk.RadioMenuItem(radio_item); menu.Append(new Gtk.SeparatorMenuItem()); */ /* image_item = new Gtk.ImageMenuItem(Gtk.Stock.Find, agrp); image_item.Activated += OnFindChatMenuItemActivated; menu.Append(image_item); item = new Gtk.MenuItem(_("Find _Next")); item.Activated += OnFindNextChatMenuItemActivated; akey = new Gtk.AccelKey(); akey.AccelFlags = Gtk.AccelFlags.Visible; akey.AccelMods = Gdk.ModifierType.ControlMask; akey.Key = Gdk.Key.G; item.AddAccelerator("activate", agrp, akey); menu.Append(item); item = new Gtk.MenuItem(_("Find _Previous")); item.Activated += OnFindPreviousChatMenuItemActivated; akey = new Gtk.AccelKey(); akey.AccelFlags = Gtk.AccelFlags.Visible; akey.AccelMods = Gdk.ModifierType.ControlMask | Gdk.ModifierType.ShiftMask; akey.Key = Gdk.Key.G; item.AddAccelerator("activate", agrp, akey); menu.Append(item); */ // ROFL: the empty code statement below is needed to keep stupid // gettext away from using all the commented code from above as // translator comment ; _OpenLogChatMenuItem = new Gtk.ImageMenuItem(_("Open Log")); _OpenLogChatMenuItem.Image = new Gtk.Image(Gtk.Stock.Open, Gtk.IconSize.Menu); _OpenLogChatMenuItem.Activated += OnOpenLogChatMenuItemActivated; _OpenLogChatMenuItem.Sensitive = false; _OpenLogChatMenuItem.NoShowAll = true; menu.Append(_OpenLogChatMenuItem); _CloseChatMenuItem = new Gtk.ImageMenuItem(Gtk.Stock.Close, agrp); _CloseChatMenuItem.Activated += OnCloseChatMenuItemActivated; _CloseChatMenuItem.AccelCanActivate += AccelCanActivateSensitive; menu.Append(_CloseChatMenuItem); // Menu - Engine menu = new Gtk.Menu(); item = new Gtk.MenuItem(_("_Engine")); item.Submenu = menu; MenuBar.Append(item); item = new Gtk.MenuItem(_("_Use Local Engine")); item.Activated += new EventHandler(_OnUseLocalEngineButtonClicked); menu.Append(item); menu.Append(new Gtk.SeparatorMenuItem()); image_item = new Gtk.ImageMenuItem(_("_Add Remote Engine")); image_item.Image = new Gtk.Image(Gtk.Stock.Add, Gtk.IconSize.Menu); image_item.Activated += new EventHandler(_OnAddRemoteEngineButtonClicked); menu.Append(image_item); image_item = new Gtk.ImageMenuItem(_("_Switch Remote Engine")); image_item.Image = new Gtk.Image(Gtk.Stock.Refresh, Gtk.IconSize.Menu); image_item.Activated += new EventHandler(_OnSwitchRemoteEngineButtonClicked); menu.Append(image_item); // Menu - View menu = new Gtk.Menu(); item = new Gtk.MenuItem(_("_View")); item.Submenu = menu; MenuBar.Append(item); item = new Gtk.CheckMenuItem(_("_Caret Mode")); item.Activated += new EventHandler(_OnCaretModeButtonClicked); akey = new Gtk.AccelKey(); akey.AccelFlags = Gtk.AccelFlags.Visible; akey.Key = Gdk.Key.F7; item.AddAccelerator("activate", agrp, akey); item.AccelCanActivate += AccelCanActivateSensitive; menu.Append(item); item = new Gtk.CheckMenuItem(_("_Browse Mode")); item.Activated += delegate { try { _Notebook.IsBrowseModeEnabled = !_Notebook.IsBrowseModeEnabled; } catch (Exception ex) { Frontend.ShowException(this, ex); } }; akey = new Gtk.AccelKey(); akey.AccelFlags = Gtk.AccelFlags.Visible; akey.Key = Gdk.Key.F8; item.AddAccelerator("activate", agrp, akey); item.AccelCanActivate += AccelCanActivateSensitive; menu.Append(item); ShowMenuBarMenuItem = new Gtk.CheckMenuItem(_("Show _Menubar")); ShowMenuBarMenuItem.Active = (bool) Frontend.FrontendConfig["ShowMenuBar"]; ShowMenuBarMenuItem.Activated += OnShowMenuBarMenuItemActivated; menu.Append(ShowMenuBarMenuItem); ShowStatusBarMenuItem = new Gtk.CheckMenuItem(_("Show _Status Bar")); ShowStatusBarMenuItem.Active = (bool) Frontend.FrontendConfig["ShowStatusBar"]; ShowStatusBarMenuItem.Activated += OnShowStatusBarMenuItemActivated; menu.Append(ShowStatusBarMenuItem); JoinWidget = new JoinWidget(); JoinWidget.NoShowAll = true; JoinWidget.Visible = (bool) Frontend.FrontendConfig["ShowQuickJoin"]; JoinWidget.Activated += OnJoinWidgetActivated; ShowQuickJoinMenuItem = new Gtk.CheckMenuItem(_("Show _Quick Join")); ShowQuickJoinMenuItem.Active = JoinWidget.Visible; ShowQuickJoinMenuItem.Activated += OnShowQuickJoinMenuItemActivated; menu.Append(ShowQuickJoinMenuItem); item = new Gtk.ImageMenuItem(Gtk.Stock.Fullscreen, agrp); item.Activated += delegate { try { IsFullscreen = !IsFullscreen; } catch (Exception ex) { Frontend.ShowException(this, ex); } }; akey = new Gtk.AccelKey(); akey.AccelFlags = Gtk.AccelFlags.Visible; akey.Key = Gdk.Key.F11; item.AddAccelerator("activate", agrp, akey); item.AccelCanActivate += AccelCanActivateSensitive; menu.Append(item); // Menu - Help menu = new Gtk.Menu(); item = new Gtk.MenuItem(_("_Help")); item.Submenu = menu; MenuBar.Append(item); image_item = new Gtk.ImageMenuItem(Gtk.Stock.About, agrp); image_item.Activated += new EventHandler(_OnAboutButtonClicked); menu.Append(image_item); MenuBar.ShowAll(); MenuBar.NoShowAll = true; MenuBar.Visible = ShowMenuBarMenuItem.Active; // TODO: network treeview _Notebook = new Notebook(); _Notebook.SwitchPage += OnNotebookSwitchPage; _Notebook.FocusInEvent += OnNotebookFocusInEvent; _ChatViewManager = new ChatViewManager(_Notebook, null); Assembly asm = Assembly.GetExecutingAssembly(); _ChatViewManager.Load(asm); _ChatViewManager.LoadAll(System.IO.Path.GetDirectoryName(asm.Location), "smuxi-frontend-gnome-*.dll"); _ChatViewManager.ChatAdded += OnChatViewManagerChatAdded; _ChatViewManager.ChatSynced += OnChatViewManagerChatSynced; _ChatViewManager.ChatRemoved += OnChatViewManagerChatRemoved; #if GTK_SHARP_2_10 _StatusIconManager = new StatusIconManager(this, _ChatViewManager); #endif #if INDICATE_SHARP _IndicateManager = new IndicateManager(this, _ChatViewManager); #endif #if NOTIFY_SHARP _NotifyManager = new NotifyManager(this, _ChatViewManager); #endif #if IPC_DBUS _NetworkManager = new NetworkManager(_ChatViewManager); #endif _UI = new GnomeUI(_ChatViewManager); // HACK: Frontend.FrontendConfig out of scope _EngineManager = new EngineManager(Frontend.FrontendConfig, _UI); _Entry = new Entry(_ChatViewManager); var entryScrolledWindow = new Gtk.ScrolledWindow(); entryScrolledWindow.ShadowType = Gtk.ShadowType.EtchedIn; entryScrolledWindow.HscrollbarPolicy = Gtk.PolicyType.Never; entryScrolledWindow.SizeRequested += delegate(object o, Gtk.SizeRequestedArgs args) { // predict and set useful heigth var layout = _Entry.CreatePangoLayout("Qp"); int lineWidth, lineHeigth; layout.GetPixelSize(out lineHeigth, out lineHeigth); var text = Entry.Text; var newLines = text.Count(f => f == '\n'); // cap to 1-3 lines if (text.Length > 0) { newLines++; newLines = Math.Max(newLines, 1); newLines = Math.Min(newLines, 3); } else { newLines = 1; } // use text heigth + a bit extra var bestSize = new Gtk.Requisition() { Height = (lineHeigth * newLines) + 5 }; args.Requisition = bestSize; }; entryScrolledWindow.Add(_Entry); _ProgressBar = new Gtk.ProgressBar(); _ProgressBar.BarStyle = Gtk.ProgressBarStyle.Continuous; MenuHBox = new Gtk.HBox(); MenuHBox.PackStart(MenuBar, false, false, 0); MenuHBox.PackEnd(JoinWidget, false, false, 0); Gtk.VBox vbox = new Gtk.VBox(); vbox.PackStart(MenuHBox, false, false, 0); vbox.PackStart(_Notebook, true, true, 0); vbox.PackStart(entryScrolledWindow, false, false, 0); _NetworkStatusbar = new Gtk.Statusbar(); _NetworkStatusbar.WidthRequest = 300; _NetworkStatusbar.HasResizeGrip = false; _Statusbar = new Gtk.Statusbar(); _Statusbar.HasResizeGrip = false; Gtk.HBox status_bar_hbox = new Gtk.HBox(); status_bar_hbox.Homogeneous = true; status_bar_hbox.PackStart(_NetworkStatusbar, false, true, 0); status_bar_hbox.PackStart(_Statusbar, true, true, 0); StatusHBox = new Gtk.HBox(); StatusHBox.PackStart(status_bar_hbox); StatusHBox.PackStart(_ProgressBar, false, false, 0); StatusHBox.ShowAll(); StatusHBox.NoShowAll = true; StatusHBox.Visible = ShowStatusBarMenuItem.Active; vbox.PackStart(StatusHBox, false, false, 0); Add(vbox); }
static Gtk.MenuItem CreateMenuItem(ContextMenuItem item) { if (!item.Visible) { return(null); } if (item.IsSeparator) { return(new Gtk.SeparatorMenuItem()); } Gtk.MenuItem menuItem; if (item is RadioButtonContextMenuItem) { var radioItem = (RadioButtonContextMenuItem)item; menuItem = new Gtk.CheckMenuItem(item.Label) { Active = radioItem.Checked, DrawAsRadio = true }; } else if (item is CheckBoxContextMenuItem) { var checkItem = (CheckBoxContextMenuItem)item; menuItem = new Gtk.CheckMenuItem(item.Label) { Active = checkItem.Checked }; } else { menuItem = new Gtk.ImageMenuItem(item.Label); } menuItem.Selected += delegate(object sender, EventArgs e) { var si = sender as Gtk.MenuItem; if (si == null || si.GdkWindow == null) { return; } int x, y; si.GdkWindow.GetOrigin(out x, out y); int rx, ry; IdeApp.Workbench.RootWindow.GdkWindow.GetOrigin(out rx, out ry); item.FireSelectedEvent(new Xwt.Rectangle(x - rx, y - ry, si.Allocation.Width, si.Allocation.Height)); }; menuItem.Deselected += delegate { item.FireDeselectedEvent(); }; if (item.SubMenu != null && item.SubMenu.Items.Count > 0) { menuItem.Submenu = FromMenu(item.SubMenu, null); } else { menuItem.Activated += (sender, e) => item.Click(); } menuItem.Sensitive = item.Sensitive; var label = (Gtk.Label)menuItem.Child; label.UseUnderline = item.UseMnemonic; if (item.UseMnemonic) { label.TextWithMnemonic = item.Label; } if (item.Image != null) { Gtk.ImageMenuItem imageItem = menuItem as Gtk.ImageMenuItem; if (imageItem != null) { var img = new ImageView(item.Image); img.ShowAll(); imageItem.Image = img; Xwt.GtkBackend.GtkWorkarounds.ForceImageOnMenuItem(imageItem); } } return(menuItem); }
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); } } } }
private void BuildMenu() { var accelerators = new Gtk.AccelGroup(); var mMain = new Gtk.MenuBar(); var mFile = new Gtk.Menu(); var mEdit = new Gtk.Menu(); var mView = new Gtk.Menu(); var mTools = new Gtk.Menu(); var mHelp = new Gtk.Menu(); var miFile = new Gtk.MenuItem("_File"); var miEdit = new Gtk.MenuItem("_Edit"); var miView = new Gtk.MenuItem("_View"); var miTools = new Gtk.MenuItem("_Tools"); var miHelp = new Gtk.MenuItem("_Help"); // Menu items var opNew = this.actNew.CreateMenuItem(); opNew.AddAccelerator("activate", accelerators, new Gtk.AccelKey( Gdk.Key.n, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible)); var opOpen = this.actOpen.CreateMenuItem(); opOpen.AddAccelerator("activate", accelerators, new Gtk.AccelKey( Gdk.Key.o, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible)); var opSave = this.actSave.CreateMenuItem(); opSave.AddAccelerator("activate", accelerators, new Gtk.AccelKey( Gdk.Key.s, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible)); var opQuit = this.actQuit.CreateMenuItem(); opQuit.AddAccelerator("activate", accelerators, new Gtk.AccelKey( Gdk.Key.q, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible)); var opAdd = this.actAdd.CreateMenuItem(); opAdd.AddAccelerator("activate", accelerators, new Gtk.AccelKey( Gdk.Key.plus, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible)); var opRemove = this.actRemove.CreateMenuItem(); opRemove.AddAccelerator("activate", accelerators, new Gtk.AccelKey( Gdk.Key.Delete, Gdk.ModifierType.None, Gtk.AccelFlags.Visible)); var opFind = this.actFind.CreateMenuItem(); opFind.AddAccelerator("activate", accelerators, new Gtk.AccelKey( Gdk.Key.f, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible)); var opFindAgain = this.actFindAgain.CreateMenuItem(); opFindAgain.AddAccelerator("activate", accelerators, new Gtk.AccelKey( Gdk.Key.F3, Gdk.ModifierType.None, Gtk.AccelFlags.Visible)); var opSettings = this.actSettings.CreateMenuItem(); opSettings.AddAccelerator("activate", accelerators, new Gtk.AccelKey( Gdk.Key.F2, Gdk.ModifierType.None, Gtk.AccelFlags.Visible)); var opView = new Gtk.CheckMenuItem(this.actViewCard.Label); opView.Active = true; opView.Activated += (sender, e) => this.actViewCard.Activate(); // Create menu structure mMain.Append(miFile); miFile.Submenu = mFile; mFile.Append(opNew); mFile.Append(opOpen); mFile.Append(this.actImport.CreateMenuItem()); mFile.Append(new Gtk.SeparatorMenuItem()); mFile.Append(opSave); mFile.Append(this.actExport.CreateMenuItem()); mFile.Append(new Gtk.SeparatorMenuItem()); mFile.Append(opQuit); mMain.Append(miEdit); miEdit.Submenu = mEdit; mEdit.Append(opAdd); mEdit.Append(opRemove); mEdit.Append(this.actModify.CreateMenuItem()); mEdit.Append(this.actConnect.CreateMenuItem()); mEdit.Append(new Gtk.SeparatorMenuItem()); mEdit.Append(opFind); mEdit.Append(opFindAgain); mEdit.Append(new Gtk.SeparatorMenuItem()); mEdit.Append(opSettings); mMain.Append(miView); miView.Submenu = mView; mView.Append(opView); mMain.Append(miTools); miTools.Submenu = mTools; mTools.Append(this.actSort.CreateMenuItem()); mMain.Append(miHelp); miHelp.Submenu = mHelp; mHelp.Append(this.actAbout.CreateMenuItem()); this.AddAccelGroup(accelerators); this.vbMain.PackStart(mMain, false, false, 0); }
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); } } }
private void BuildMenu() { var accelerators = new Gtk.AccelGroup(); var mMain = new Gtk.MenuBar(); var mFile = new Gtk.Menu(); var mEdit = new Gtk.Menu(); var mView = new Gtk.Menu(); var mTools = new Gtk.Menu(); var mHelp = new Gtk.Menu(); var miFile = new Gtk.MenuItem( "_File" ); var miEdit = new Gtk.MenuItem( "_Edit" ); var miView = new Gtk.MenuItem( "_View" ); var miTools = new Gtk.MenuItem( "_Tools" ); var miHelp = new Gtk.MenuItem( "_Help" ); // Menu items var opNew = this.actNew.CreateMenuItem(); opNew.AddAccelerator( "activate", accelerators, new Gtk.AccelKey( Gdk.Key.n, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible ) ); var opOpen = this.actOpen.CreateMenuItem(); opOpen.AddAccelerator( "activate", accelerators, new Gtk.AccelKey( Gdk.Key.o, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible ) ); var opSave = this.actSave.CreateMenuItem(); opSave.AddAccelerator( "activate", accelerators, new Gtk.AccelKey( Gdk.Key.s, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible ) ); var opQuit = this.actQuit.CreateMenuItem(); opQuit.AddAccelerator( "activate", accelerators, new Gtk.AccelKey( Gdk.Key.q, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible ) ); var opAdd = this.actAdd.CreateMenuItem(); opAdd.AddAccelerator( "activate", accelerators, new Gtk.AccelKey( Gdk.Key.plus, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible ) ); var opRemove = this.actRemove.CreateMenuItem(); opRemove.AddAccelerator( "activate", accelerators, new Gtk.AccelKey( Gdk.Key.Delete, Gdk.ModifierType.None, Gtk.AccelFlags.Visible ) ); var opFind = this.actFind.CreateMenuItem(); opFind.AddAccelerator( "activate", accelerators, new Gtk.AccelKey( Gdk.Key.f, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible ) ); var opFindAgain = this.actFindAgain.CreateMenuItem(); opFindAgain.AddAccelerator( "activate", accelerators, new Gtk.AccelKey( Gdk.Key.F3, Gdk.ModifierType.None, Gtk.AccelFlags.Visible ) ); var opSettings = this.actSettings.CreateMenuItem(); opSettings.AddAccelerator( "activate", accelerators, new Gtk.AccelKey( Gdk.Key.F2, Gdk.ModifierType.None, Gtk.AccelFlags.Visible ) ); var opView = new Gtk.CheckMenuItem( this.actViewCard.Label ); opView.Active = true; opView.Activated += (sender, e) => this.actViewCard.Activate(); // Create menu structure mMain.Append( miFile ); miFile.Submenu = mFile; mFile.Append( opNew ); mFile.Append( opOpen ); mFile.Append( this.actImport.CreateMenuItem() ); mFile.Append( new Gtk.SeparatorMenuItem() ); mFile.Append( opSave ); mFile.Append( this.actExport.CreateMenuItem() ); mFile.Append( new Gtk.SeparatorMenuItem() ); mFile.Append( opQuit ); mMain.Append( miEdit ); miEdit.Submenu = mEdit; mEdit.Append( opAdd ); mEdit.Append( opRemove ); mEdit.Append( this.actModify.CreateMenuItem() ); mEdit.Append( this.actConnect.CreateMenuItem() ); mEdit.Append( new Gtk.SeparatorMenuItem() ); mEdit.Append( opFind ); mEdit.Append( opFindAgain ); mEdit.Append( new Gtk.SeparatorMenuItem() ); mEdit.Append( opSettings ); mMain.Append( miView ); miView.Submenu = mView; mView.Append( opView ); mMain.Append( miTools ); miTools.Submenu = mTools; mTools.Append( this.actSort.CreateMenuItem() ); mMain.Append( miHelp ); miHelp.Submenu = mHelp; mHelp.Append( this.actAbout.CreateMenuItem() ); this.AddAccelGroup( accelerators ); this.vbMain.PackStart( mMain, false, false, 0 ); }
void OnSelectIcon (object s, Gtk.ButtonPressEventArgs args) { Gtk.Menu menu = new Gtk.Menu (); Gtk.CheckMenuItem item = new Gtk.CheckMenuItem (Catalog.GetString ("Action")); item.DrawAsRadio = true; item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Action); item.Activated += OnSetActionType; menu.Insert (item, -1); item = new Gtk.CheckMenuItem (Catalog.GetString ("Radio Action")); item.DrawAsRadio = true; item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Radio); item.Activated += OnSetRadioType; menu.Insert (item, -1); item = new Gtk.CheckMenuItem (Catalog.GetString ("Toggle Action")); item.DrawAsRadio = true; item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Toggle); item.Activated += OnSetToggleType; menu.Insert (item, -1); menu.Insert (new Gtk.SeparatorMenuItem (), -1); Gtk.MenuItem itIcons = new Gtk.MenuItem (Catalog.GetString ("Select Icon")); menu.Insert (itIcons, -1); IconSelectorMenu menuIcons = new IconSelectorMenu (GetProject ()); menuIcons.IconSelected += OnStockSelected; itIcons.Submenu = menuIcons; Gtk.MenuItem it = new Gtk.MenuItem (Catalog.GetString ("Clear Icon")); it.Sensitive = (node.Action.GtkAction.StockId != null); it.Activated += OnClearIcon; menu.Insert (it, -1); menu.ShowAll (); uint but = args != null ? args.Event.Button : 1; menu.Popup (null, null, new Gtk.MenuPositionFunc (OnDropMenuPosition), but, Gtk.Global.CurrentEventTime); // Make sure we get the focus after closing the menu, so we can keep browsing buttons // using the keyboard. menu.Hidden += delegate (object sender, EventArgs a) { GrabFocus (); }; if (args != null) args.RetVal = false; }
public virtual void Initialize (PropertyDescriptor prop) { CheckType (prop); this.prop = prop; mainHBox = new Gtk.HBox (false, 6); PackStart (mainHBox, false, false, 0); if (!prop.Translatable) return; button = new Gtk.Button (); try { globe = Gdk.Pixbuf.LoadFromResource ("globe.png"); globe_not = Gdk.Pixbuf.LoadFromResource ("globe-not.png"); } catch (Exception e) { Console.WriteLine ("Error while loading pixbuf: " + e); } image = new Gtk.Image (globe); button.Add (image); button.ButtonPressEvent += ButtonPressed; mainHBox.PackEnd (button, false, false, 0); mainHBox.ShowAll (); menu = new Gtk.Menu (); markItem = new Gtk.CheckMenuItem ("Mark for Translation"); markItem.Toggled += ToggleMark; markItem.Show (); menu.Add (markItem); addContextItem = new Gtk.MenuItem ("Add Translation Context Hint"); addContextItem.Activated += AddContext; menu.Add (addContextItem); remContextItem = new Gtk.MenuItem ("Remove Translation Context Hint"); remContextItem.Activated += RemoveContext; menu.Add (remContextItem); addCommentItem = new Gtk.MenuItem ("Add Comment for Translators"); addCommentItem.Activated += AddComment; menu.Add (addCommentItem); remCommentItem = new Gtk.MenuItem ("Remove Comment for Translators"); remCommentItem.Activated += RemoveComment; menu.Add (remCommentItem); contextBox = new Gtk.HBox (false, 6); Gtk.Label contextLabel = new Gtk.Label ("Translation context"); contextLabel.Xalign = 0.0f; contextBox.PackStart (contextLabel, false, false, 0); contextEntry = new Gtk.Entry (); contextEntry.WidthChars = 8; contextBox.PackStart (contextEntry, true, true, 0); contextBox.ShowAll (); contextEntry.Changed += ContextChanged; commentBox = new Gtk.VBox (false, 3); Gtk.Label commentLabel = new Gtk.Label ("Comment for Translators:"); commentLabel.Xalign = 0.0f; commentBox.PackStart (commentLabel, false, false, 0); commentText = new TextBox (3); commentBox.PackStart (commentText, false, false, 0); commentBox.ShowAll (); commentText.Changed += CommentChanged; }
protected virtual void OnMessageTextViewPopulatePopup(object sender, Gtk.PopulatePopupArgs e) { Trace.Call(sender, e); if (OutputMessageTextView.IsAtUrlTag) { return; } Gtk.Menu popup = e.Menu; // hide menu bar item as it uses the app menu on OS X if (!Frontend.IsMacOSX) { popup.Prepend(new Gtk.SeparatorMenuItem()); var item = new Gtk.CheckMenuItem(_("Show _Menubar")); item.Active = Frontend.MainWindow.ShowMenuBar; item.Activated += delegate { try { Frontend.MainWindow.ShowMenuBar = !Frontend.MainWindow.ShowMenuBar; } catch (Exception ex) { Frontend.ShowException(ex); } }; popup.Prepend(item); } popup.ShowAll(); }
private void CreateMenu(object o, Gtk.PopulatePopupArgs e) { CreatingMenu = true; Hooks._Scrollback.BeforeMenu(owner, this, e.Menu); Gtk.SeparatorMenuItem separator1 = new Gtk.SeparatorMenuItem(); separator1.Show(); e.Menu.Append(separator1); e.Menu.Append(new Gtk.SeparatorMenuItem()); listAllChannelsToolStripMenuItem.Visible = (owner != null && owner._Network != null); // channels if (joinToolStripMenuItem.Visible) { Gtk.MenuItem join = new Gtk.MenuItem(joinToolStripMenuItem.Text); join.Show(); join.Activated += new EventHandler(joinToolStripMenuItem_Click); e.Menu.Append(join); Gtk.SeparatorMenuItem separator6 = new Gtk.SeparatorMenuItem(); separator6.Show(); e.Menu.Append(separator6); } if (openLinkInBrowserToolStripMenuItem.Visible) { Gtk.MenuItem copylink = new Gtk.MenuItem(copyLinkToClipboardToolStripMenuItem.Text); copylink.Show(); copylink.Activated += new EventHandler(copyLinkToClipboardToolStripMenuItem_Click); e.Menu.Append(copylink); } if (openLinkInBrowserToolStripMenuItem.Visible) { Gtk.MenuItem open = new Gtk.MenuItem(openLinkInBrowserToolStripMenuItem.Text); open.Show(); open.Activated += new EventHandler(openLinkInBrowserToolStripMenuItem_Click); e.Menu.Append(open); Gtk.SeparatorMenuItem separator8 = new Gtk.SeparatorMenuItem(); separator8.Show(); e.Menu.Append(separator8); } // whois items if (whoisToolStripMenuItem.Visible) { Gtk.MenuItem whois = new Gtk.MenuItem(whoisToolStripMenuItem.Text); whois.Show(); whois.Activated += new EventHandler(whoisToolStripMenuItem_Click); e.Menu.Append(whois); Gtk.MenuItem whowas = new Gtk.MenuItem(whowasToolStripMenuItem.Text); whowas.Show(); whowas.Activated += new EventHandler(whowasToolStripMenuItem_Click); e.Menu.Append(whowas); if (kickToolStripMenuItem.Visible) { Gtk.MenuItem ku = new Gtk.MenuItem(kickToolStripMenuItem.Text); ku.Show(); ku.Activated += new EventHandler(kickToolStripMenuItem_Click); e.Menu.Append(ku); } Gtk.SeparatorMenuItem separator3 = new Gtk.SeparatorMenuItem(); separator3.Show(); e.Menu.Append(separator3); } if (mode1b2ToolStripMenuItem.Visible) { Gtk.MenuItem mode1 = new Gtk.MenuItem(mode1b2ToolStripMenuItem.Text); mode1.Show(); mode1.Activated += new EventHandler(mode1b2ToolStripMenuItem_Click); e.Menu.Append(mode1); Gtk.MenuItem mode2 = new Gtk.MenuItem(mode1e2ToolStripMenuItem.Text); mode2.Show(); mode2.Activated += new EventHandler(mode1e2ToolStripMenuItem_Click); e.Menu.Append(mode2); Gtk.MenuItem mode3 = new Gtk.MenuItem(mode1I2ToolStripMenuItem.Text); mode3.Show(); mode3.Activated += new EventHandler(mode1I2ToolStripMenuItem_Click); e.Menu.Append(mode3); Gtk.MenuItem mode4 = new Gtk.MenuItem(mode1q2ToolStripMenuItem.Text); mode4.Show(); mode4.Activated += new EventHandler(mode1q2ToolStripMenuItem_Click); e.Menu.Append(mode4); Gtk.SeparatorMenuItem separator4 = new Gtk.SeparatorMenuItem(); separator4.Show(); e.Menu.Append(separator4); } Gtk.MenuItem clean = new Gtk.MenuItem("Clean"); clean.Show(); e.Menu.Append(clean); clean.Activated += new EventHandler(mrhToolStripMenuItem_Click); Gtk.CheckMenuItem scroll = new Gtk.CheckMenuItem(scrollToolStripMenuItem.Text); if (scrollToolStripMenuItem.Checked) { scroll.Active = true; } scroll.Show(); scroll.Activated += new EventHandler(scrollToolStripMenuItem_Click); e.Menu.Append(scroll); Gtk.MenuItem refresh = new Gtk.MenuItem("Refresh"); refresh.Show(); refresh.Activated += new EventHandler(refreshToolStripMenuItem_Click); e.Menu.Append(refresh); Gtk.CheckMenuItem taly = new Gtk.CheckMenuItem(toggleAdvancedLayoutToolStripMenuItem.Text); taly.Activated += new EventHandler(toggleAdvancedLayoutToolStripMenuItem_Click); if (toggleAdvancedLayoutToolStripMenuItem.Checked) { taly.Active = true; } taly.Show(); e.Menu.Append(taly); Gtk.CheckMenuItem tsly = new Gtk.CheckMenuItem("Toggle simple layout"); tsly.Activated += new EventHandler(toggleSimpleLayoutToolStripMenuItem_Click); if (toggleSimpleLayoutToolStripMenuItem.Checked) { tsly.Active = true; } tsly.Show(); e.Menu.Append(tsly); Gtk.SeparatorMenuItem separator2 = new Gtk.SeparatorMenuItem(); separator2.Show(); e.Menu.Append(separator2); if (channelToolStripMenuItem.Visible) { Gtk.MenuItem channel = new Gtk.MenuItem("Channel"); channel.Show(); e.Menu.Append(channel); channel.Activated += new EventHandler(channelToolStripMenuItem_Click); } if (listAllChannelsToolStripMenuItem.Visible) { Gtk.MenuItem list = new Gtk.MenuItem(listAllChannelsToolStripMenuItem.Text); list.Show(); list.Activated += new EventHandler(listAllChannelsToolStripMenuItem_Click); e.Menu.Append(list); } if (retrieveTopicToolStripMenuItem.Visible) { Gtk.MenuItem retrieve = new Gtk.MenuItem("Retrieve topic"); retrieve.Show(); retrieve.Activated += new EventHandler(retrieveTopicToolStripMenuItem_Click); e.Menu.Append(retrieve); } Hooks._Scrollback.AfterMenu(owner, this, e.Menu); Gtk.MenuItem copy = new Gtk.MenuItem(copyTextToClipBoardToolStripMenuItem.Text); copy.Activated += new EventHandler(copyTextToClipBoardToolStripMenuItem_Click); copy.Show(); e.Menu.Append(copy); Gtk.MenuItem copy_x = new Gtk.MenuItem(copyEntireWindowToClipBoardToolStripMenuItem.Text); copy_x.Activated += new EventHandler(copyEntireWindowToClipBoardToolStripMenuItem_Click); copy_x.Show(); e.Menu.Append(copy_x); CreatingMenu = false; }