Exemplo n.º 1
0
        public override void OnNoteOpened()
        {
            if (menu == null)
            {
                menu = new Gtk.Menu();
                menu.ShowAll();
            }

            if (toolButton == null)
            {
                InitializeToolButton();

                // Disable the notebook button if this note is a template note
                Tag templateTag = TagManager.GetOrCreateSystemTag(TagManager.TemplateNoteSystemTag);
                if (Note.ContainsTag(templateTag) == true)
                {
                    toolButton.Sensitive = false;

                    // Also prevent notebook templates from being deleted
                    if (NotebookManager.GetNotebookFromNote(Note) != null)
                    {
                        Note.Window.DeleteButton.Sensitive = false;
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void _OnOutputMessageTextViewPopulatePopup(object o, Gtk.PopulatePopupArgs args)
        {
            if (OutputMessageTextView.IsAtUrlTag)
            {
                return;
            }

            Gtk.Menu popup = args.Menu;

            popup.Append(new Gtk.SeparatorMenuItem());

            Gtk.ImageMenuItem whois_item = new Gtk.ImageMenuItem(_("Whois"));
            whois_item.Activated += _OnMenuWhoisItemActivated;
            popup.Append(whois_item);

            Gtk.ImageMenuItem ctcp_item      = new Gtk.ImageMenuItem(_("CTCP"));
            Gtk.Menu          ctcp_menu_item = new CtcpMenu(_IrcProtocolManager,
                                                            Frontend.MainWindow.ChatViewManager,
                                                            PersonModel);
            ctcp_item.Submenu = ctcp_menu_item;
            popup.Append(ctcp_item);

            Gtk.ImageMenuItem invite_to_item      = new Gtk.ImageMenuItem(_("Invite to"));
            Gtk.Menu          invite_to_menu_item = new InviteToMenu(_IrcProtocolManager,
                                                                     Frontend.MainWindow.ChatViewManager,
                                                                     PersonModel);
            invite_to_item.Submenu = invite_to_menu_item;
            popup.Append(invite_to_item);

            popup.ShowAll();
        }
        protected virtual void ShowDropDown()
        {
            if (HasChildren)
            {
                PopupMenu         = new Gtk.Menu();
                PopupMenu.Hidden += (s, o) =>
                                    HideDropDown();
                PopupMenu.SelectionDone += (s, e) => {
                    var i = 0;
                };
                Populate(PopupMenu);
                PopupMenu.ShowAll();

                PopupMenu.Popup(null, null, delegate(Gtk.Menu menu, out int x, out int y, out bool push_in) {
                    var all = ContentWidget.Allocation;
                    var loc = GtkBackendHelper.ConvertToScreenCoordinates(ContentWidget, new Xwt.Point(0, all.Height));
                    x       = (int)loc.X;
                    y       = (int)loc.Y;
                    push_in = true;
                }, 0,
                                Gtk.Global.CurrentEventTime);

                PopupMenu.WidthRequest = this.Widget.Allocation.Width;
            }
        }
Exemplo n.º 4
0
        void IMenuItemContainer.ShowContextMenu(ActionItem aitem)
        {
            ActionMenuItem menuItem = aitem as ActionMenuItem;

            Gtk.Menu     m    = new Gtk.Menu();
            Gtk.MenuItem item = new Gtk.ImageMenuItem(Gtk.Stock.Cut, null);
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a) {
                Cut(menuItem);
            };
            item.Visible = false;               // No copy & paste for now
            item         = new Gtk.ImageMenuItem(Gtk.Stock.Copy, null);
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a) {
                Copy(menuItem);
            };
            item.Visible = false;               // No copy & paste for now
            item         = new Gtk.ImageMenuItem(Gtk.Stock.Paste, null);
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a) {
                Paste(menuItem);
            };
            item.Visible = false;               // No copy & paste for now
            item         = new Gtk.ImageMenuItem(Gtk.Stock.Delete, null);
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a) {
                Delete(menuItem);
            };
            m.ShowAll();
            m.Popup();
        }
Exemplo n.º 5
0
 private void IconClicked(object source, Gtk.ButtonPressEventArgs args)
 {
     //ProjectWindow pw = new ProjectWindow();
     //pw.Show();
     menu.ShowAll();
     menu.Popup(null, null, null, IntPtr.Zero, args.Event.Button, args.Event.Time);
 }
Exemplo n.º 6
0
        private void PopulateAlbums()
        {
            Gtk.Menu menu = new Gtk.Menu();
            if (gallery.Version == GalleryVersion.Version1)
            {
                Gtk.MenuItem top_item = new Gtk.MenuItem(Catalog.GetString("(TopLevel)"));
                menu.Append(top_item);
            }

            foreach (Album album in gallery.Albums)
            {
                System.Text.StringBuilder label_builder = new System.Text.StringBuilder();

                for (int i = 0; i < album.Parents.Count; i++)
                {
                    label_builder.Append("  ");
                }

                label_builder.Append(album.Title);
                album_optionmenu.AppendText(label_builder.ToString());
            }

            album_optionmenu.Sensitive = true;
            menu.ShowAll();
        }
Exemplo n.º 7
0
        void PopupQuickFixMenu(Gdk.EventButton evt)
        {
            Gtk.Menu menu = new Gtk.Menu();

            Dictionary <Gtk.MenuItem, ContextAction> fixTable = new Dictionary <Gtk.MenuItem, ContextAction> ();
            int mnemonic = 1;

            foreach (ContextAction fix in fixes)
            {
                var escapedLabel = fix.GetMenuText(document, loc).Replace("_", "__");
                var label        = (mnemonic <= 10)
                                                ? "_" + (mnemonic++ % 10).ToString() + " " + escapedLabel
                                                : "  " + escapedLabel;
                Gtk.MenuItem menuItem = new Gtk.MenuItem(label);
                fixTable [menuItem] = fix;
                menuItem.Activated += delegate(object sender, EventArgs e) {
                    // ensure that the Ast is recent.
                    document.UpdateParseDocument();
                    var runFix = fixTable [(Gtk.MenuItem)sender];
                    runFix.Run(document, loc);

                    document.Editor.Document.CommitUpdateAll();
                    menu.Destroy();
                };
                menu.Add(menuItem);
            }
            menu.ShowAll();
            menu.SelectFirst(true);
            menuPushed      = true;
            menu.Destroyed += delegate {
                menuPushed = false;
                QueueDraw();
            };
            GtkWorkarounds.ShowContextMenu(menu, this, evt, Allocation);
        }
Exemplo n.º 8
0
        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();
        }
Exemplo n.º 9
0
        protected virtual void OnPopulatePopup(object sender, Gtk.PopulatePopupArgs e)
        {
            Trace.Call(sender, e);

            if (!_AtLinkTag)
            {
                return;
            }

            Gtk.Menu popup = e.Menu;
            // remove all items
            foreach (Gtk.Widget children in popup.Children)
            {
                popup.Remove(children);
            }

            Gtk.ImageMenuItem open_item = new Gtk.ImageMenuItem(Gtk.Stock.Open, null);
            open_item.Activated += delegate {
                if (_ActiveLink != null)
                {
                    OpenLink(_ActiveLink);
                }
            };
            popup.Append(open_item);

            Gtk.ImageMenuItem copy_item = new Gtk.ImageMenuItem(Gtk.Stock.Copy, null);
            copy_item.Activated += delegate {
                Gdk.Atom      clipboardAtom = Gdk.Atom.Intern("CLIPBOARD", false);
                Gtk.Clipboard clipboard     = Gtk.Clipboard.Get(clipboardAtom);
                clipboard.Text = _ActiveLink.ToString();
            };
            popup.Append(copy_item);

            popup.ShowAll();
        }
Exemplo n.º 10
0
        private void PopulateAlbums()
        {
            Gtk.Menu menu = new Gtk.Menu();
            if (gallery.Version == GalleryVersion.Version1)
            {
                Gtk.MenuItem top_item = new Gtk.MenuItem(Catalog.GetString("(TopLevel)"));
                menu.Append(top_item);
            }

            foreach (Album album in gallery.Albums)
            {
                System.Text.StringBuilder label_builder = new System.Text.StringBuilder();

                for (int i = 0; i < album.Parents.Count; i++)
                {
                    label_builder.Append("  ");
                }
                label_builder.Append(album.Title);

                Gtk.MenuItem item = new Gtk.MenuItem(label_builder.ToString());
                ((Gtk.Label)item.Child).UseUnderline = false;
                menu.Append(item);

                AlbumPermission create_sub = album.Perms & AlbumPermission.CreateSubAlbum;

                if (create_sub == 0)
                {
                    item.Sensitive = false;
                }
            }

            album_optionmenu.Sensitive = true;
            menu.ShowAll();
            album_optionmenu.Menu = menu;
        }
Exemplo n.º 11
0
 void OnIconMarginButtonPress(object s, MarginMouseEventArgs args)
 {
     if (args.Button == 3)
     {
         editor.Caret.Line   = args.LineNumber;
         editor.Caret.Column = 1;
         Gtk.Menu popupMenu = (Gtk.Menu)MainClass.MainWindow.ActionUiManager.GetWidget("/iconMarginPopup");
         if (popupMenu != null)
         {
             popupMenu.ShowAll();
             popupMenu.Popup();
         }
     }
     else if (args.Button == 1)
     {
         if (!string.IsNullOrEmpty(FileName))
         {
             if (args.LineSegment != null)
             {
                 //DebuggingService.Breakpoints.Toggle (this.Document.FileName, args.LineNumber + 1);
                 //AddBreakpoints(args.LineSegment);
             }
         }
     }
 }
        public void ShowContextMenu(ActionItem aitem)
        {
            ActionToolItem menuItem = aitem as ActionToolItem;

            Gtk.Menu     m    = new Gtk.Menu();
            Gtk.MenuItem item = new Gtk.MenuItem(Catalog.GetString("Insert Before"));
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a)
            {
                InsertActionAt(menuItem, false, false);
            };
            item = new Gtk.MenuItem(Catalog.GetString("Insert After"));
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a)
            {
                InsertActionAt(menuItem, true, false);
            };
            item = new Gtk.MenuItem(Catalog.GetString("Insert Separator Before"));
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a)
            {
                InsertActionAt(menuItem, false, true);
            };
            item = new Gtk.MenuItem(Catalog.GetString("Insert Separator After"));
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a)
            {
                InsertActionAt(menuItem, true, true);
            };

            m.Add(new Gtk.SeparatorMenuItem());

            item = new Gtk.ImageMenuItem(Gtk.Stock.Cut, null);
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a)
            {
                menuItem.Cut();
            };
            item = new Gtk.ImageMenuItem(Gtk.Stock.Copy, null);
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a)
            {
                menuItem.Copy();
            };
            item = new Gtk.ImageMenuItem(Gtk.Stock.Paste, null);
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a)
            {
                Paste(menuItem);
            };
            item = new Gtk.ImageMenuItem(Gtk.Stock.Delete, null);
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a)
            {
                menuItem.Delete();
            };
            m.ShowAll();
            m.Popup();
        }
Exemplo n.º 13
0
 private void BuildPopup()
 {
     popup = new Gtk.Menu();
     popup.Append(this.actAdd.CreateMenuItem());
     popup.Append(this.actRemove.CreateMenuItem());
     popup.Append(this.actModify.CreateMenuItem());
     popup.Append(this.actSettings.CreateMenuItem());
     popup.ShowAll();
 }
Exemplo n.º 14
0
        private void PopulateAlbumOptionMenu(PicasaWeb picasa)
        {
            PicasaAlbumCollection albums = null;

            if (picasa != null)
            {
                try {
                    albums = picasa.GetAlbums();
                } catch {
                    Console.WriteLine("Can't get the albums");
                    picasa = null;
                }
            }

            Gtk.Menu menu = new Gtk.Menu();

            bool disconnected = picasa == null || !account.Connected || albums == null;

            if (disconnected || albums.Count == 0)
            {
                string msg = disconnected ? Catalog.GetString("(Not Connected)")
                                        : Catalog.GetString("(No Albums)");

                Gtk.MenuItem item = new Gtk.MenuItem(msg);
                menu.Append(item);

                ok_button.Sensitive        = false;
                album_optionmenu.Sensitive = false;
                album_button.Sensitive     = false;

                if (disconnected)
                {
                    album_button.Sensitive = false;
                }
            }
            else
            {
                foreach (PicasaAlbum album in albums.AllValues)
                {
                    System.Text.StringBuilder label_builder = new System.Text.StringBuilder();

                    label_builder.Append(album.Title);

                    Gtk.MenuItem item = new Gtk.MenuItem(label_builder.ToString());
                    ((Gtk.Label)item.Child).UseUnderline = false;
                    menu.Append(item);
                }

                ok_button.Sensitive        = items.Length > 0;
                album_optionmenu.Sensitive = true;
                album_button.Sensitive     = true;
            }

            menu.ShowAll();
            album_optionmenu.Menu = menu;
        }
        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;
            }
        }
Exemplo n.º 16
0
        Gtk.Menu GetRightClickMenu()
        {
            if (tray.TomboyTrayMenu != null)
            {
                tray.TomboyTrayMenu.Hide();
            }

            if (context_menu != null)
            {
                context_menu.Hide();
                return(context_menu);
            }

            context_menu = new Gtk.Menu();

            Gtk.AccelGroup accel_group = new Gtk.AccelGroup();
            context_menu.AccelGroup = accel_group;

            Gtk.ImageMenuItem item;

            sync_menu_item       = new Gtk.ImageMenuItem(Catalog.GetString("S_ynchronize Notes"));
            sync_menu_item.Image = new Gtk.Image(Gtk.Stock.Convert, Gtk.IconSize.Menu);
            UpdateMenuItems();
            Preferences.SettingChanged += Preferences_SettingChanged;
            sync_menu_item.Activated   += SyncNotes;
            context_menu.Append(sync_menu_item);

            context_menu.Append(new Gtk.SeparatorMenuItem());

            item            = new Gtk.ImageMenuItem(Catalog.GetString("_Preferences"));
            item.Image      = new Gtk.Image(Gtk.Stock.Preferences, Gtk.IconSize.Menu);
            item.Activated += ShowPreferences;
            context_menu.Append(item);

            item            = new Gtk.ImageMenuItem(Catalog.GetString("_Help"));
            item.Image      = new Gtk.Image(Gtk.Stock.Help, Gtk.IconSize.Menu);
            item.Activated += ShowHelpContents;
            context_menu.Append(item);

            item            = new Gtk.ImageMenuItem(Catalog.GetString("_About Tomboy"));
            item.Image      = new Gtk.Image(Gtk.Stock.About, Gtk.IconSize.Menu);
            item.Activated += ShowAbout;
            context_menu.Append(item);

            context_menu.Append(new Gtk.SeparatorMenuItem());

            item            = new Gtk.ImageMenuItem(Catalog.GetString("_Quit"));
            item.Image      = new Gtk.Image(Gtk.Stock.Quit, Gtk.IconSize.Menu);
            item.Activated += Quit;
            context_menu.Append(item);

            context_menu.ShowAll();
            return(context_menu);
        }
Exemplo n.º 17
0
        private void Traverse(Wrappers.Node grp, Gtk.Menu sub)
        {
            foreach (Wrappers.Wrapper child in grp.Children)
            {
                AddTemplate(sub, child);
            }

            sub.ShowAll();

            grp.ChildAdded   += HandleChildAdded;
            grp.ChildRemoved += HandleChildRemoved;
        }
Exemplo n.º 18
0
        protected override void Run(RefactoringOptions options)
        {
            Gtk.Menu menu = new Gtk.Menu();

            bool          resolveDirect;
            List <string> namespaces = GetResolveableNamespaces(options, out resolveDirect);

            foreach (string ns in namespaces)
            {
                // remove used namespaces for conflict resolving.
                if (options.Document.CompilationUnit.IsNamespaceUsedAt(ns, options.ResolveResult.ResolvedExpression.Region.Start))
                {
                    continue;
                }
                Gtk.MenuItem menuItem = new Gtk.MenuItem(string.Format(GettextCatalog.GetString("Add using '{0}'"), ns));
                CurrentRefactoryOperationsHandler.ResolveNameOperation resolveNameOperation = new CurrentRefactoryOperationsHandler.ResolveNameOperation(options.Dom, options.Document, options.ResolveResult, ns);
                menuItem.Activated += delegate
                {
                    resolveNameOperation.AddImport();
                };
                menu.Add(menuItem);
            }
            if (resolveDirect)
            {
                foreach (string ns in namespaces)
                {
                    Gtk.MenuItem menuItem = new Gtk.MenuItem(string.Format(GettextCatalog.GetString("Add '{0}'"), ns));
                    CurrentRefactoryOperationsHandler.ResolveNameOperation resolveNameOperation = new CurrentRefactoryOperationsHandler.ResolveNameOperation(options.Dom, options.Document, options.ResolveResult, ns);
                    menuItem.Activated += delegate
                    {
                        resolveNameOperation.ResolveName();
                    };
                    menu.Add(menuItem);
                }
            }

            if (menu.Children != null && menu.Children.Length > 0)
            {
                menu.ShowAll();

                ICompletionWidget     widget = options.Document.GetContent <ICompletionWidget> ();
                CodeCompletionContext codeCompletionContext = widget.CreateCodeCompletionContext(options.GetTextEditorData().Caret.Offset);

                menu.Popup(null, null, delegate(Gtk.Menu menu2, out int x, out int y, out bool pushIn)
                {
                    x      = codeCompletionContext.TriggerXCoord;
                    y      = codeCompletionContext.TriggerYCoord;
                    pushIn = false;
                }, 0, Gtk.Global.CurrentEventTime);
                menu.SelectFirst(true);
            }
        }
Exemplo n.º 19
0
        internal void ShowDockPopupMenu(uint time)
        {
            Gtk.Menu menu = new Gtk.Menu();

            // Hide menuitem
            if ((Behavior & DockItemBehavior.CantClose) == 0)
            {
                Gtk.MenuItem mitem = new Gtk.MenuItem(Catalog.GetString("Hide"));
                mitem.Activated += delegate { Visible = false; };
                menu.Append(mitem);
            }

            Gtk.MenuItem citem;

            // Auto Hide menuitem
            if ((Behavior & DockItemBehavior.CantAutoHide) == 0 && Status != DockItemStatus.AutoHide)
            {
                citem            = new Gtk.MenuItem(Catalog.GetString("Minimize"));
                citem.Activated += delegate { Status = DockItemStatus.AutoHide; };
                menu.Append(citem);
            }

            if (Status != DockItemStatus.Dockable)
            {
                // Dockable menuitem
                citem            = new Gtk.MenuItem(Catalog.GetString("Dock"));
                citem.Activated += delegate { Status = DockItemStatus.Dockable; };
                menu.Append(citem);
            }

            // Floating menuitem
            if ((Behavior & DockItemBehavior.NeverFloating) == 0 && Status != DockItemStatus.Floating)
            {
                citem            = new Gtk.MenuItem(Catalog.GetString("Undock"));
                citem.Activated += delegate { Status = DockItemStatus.Floating; };
                menu.Append(citem);
            }

            if (menu.Children.Length == 0)
            {
                menu.Destroy();
                return;
            }

            ShowingContextMemu = true;

            menu.ShowAll();
            menu.Hidden += (o, e) => {
                ShowingContextMemu = false;
            };
            menu.Popup(null, null, null, 3, time);
        }
Exemplo n.º 20
0
		public override void OnNoteOpened ()
		{
			menu = new Gtk.Menu ();
			menu.Hidden += OnMenuHidden;
			menu.ShowAll ();
			menu_item = new Gtk.ImageMenuItem (
			        Catalog.GetString ("What links here?"));
			menu_item.Image = new Gtk.Image (Gtk.Stock.JumpTo, Gtk.IconSize.Menu);
			menu_item.Submenu = menu;
			menu_item.Activated += OnMenuItemActivated;
			menu_item.Show ();
			AddPluginMenuItem (menu_item);
		}
Exemplo n.º 21
0
 public override void OnNoteOpened()
 {
     menu         = new Gtk.Menu();
     menu.Hidden += OnMenuHidden;
     menu.ShowAll();
     menu_item = new Gtk.ImageMenuItem(
         Catalog.GetString("What links here?"));
     menu_item.Image      = new Gtk.Image(Gtk.Stock.JumpTo, Gtk.IconSize.Menu);
     menu_item.Submenu    = menu;
     menu_item.Activated += OnMenuItemActivated;
     menu_item.Show();
     AddPluginMenuItem(menu_item);
 }
Exemplo n.º 22
0
        protected virtual void OnTabMenuShown(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            foreach (var child in _TabMenu.Children)
            {
                _TabMenu.Remove(child);
            }
            var closeItem = new Gtk.ImageMenuItem(Gtk.Stock.Close, null);

            closeItem.Activated += OnTabMenuCloseActivated;
            _TabMenu.Append(closeItem);
            _TabMenu.ShowAll();
        }
Exemplo n.º 23
0
        public override void OnNoteOpened()
        {
            if (menu == null)
            {
                menu = new Gtk.Menu();
                menu.ShowAll();
            }

            if (toolButton == null)
            {
                InitializeToolButton();
                UpdateButtonSensitivity(Note.ContainsTag(TemplateTag));
            }
        }
Exemplo n.º 24
0
        private void PopupContextMenu(IPrimaryToolDelegator mainTool, IDrawingEditor editor, ITool dt, MouseEvent ev)
        {
            m_contextMenu = new Gtk.Menu();
            Gtk.MenuItem editLabel = new Gtk.MenuItem("Edit label");

            editLabel.Activated += delegate(object sender, EventArgs e)
            {
                SimpleTextTool textTool = new SimpleTextTool(editor, this, dt, ev);
                mainTool.DelegateTool = textTool;
                textTool.StartEditing();
            };

            m_contextMenu.Add(editLabel);
            m_contextMenu.ShowAll();

            m_contextMenu.Popup();
        }
Exemplo n.º 25
0
        private void ShowPopup()
        {
            Gtk.Menu menu = new Gtk.Menu();

            Gtk.MenuItem deleteFile = new Gtk.MenuItem(GettextCatalog.GetString("Delete file"));
            deleteFile.Activated += new EventHandler(OnDeleteFiles);

            Gtk.MenuItem renameFile = new Gtk.MenuItem(GettextCatalog.GetString("Rename file"));
            renameFile.Activated += new EventHandler(OnRenameFile);
            renameFile.Sensitive  = false;

            menu.Append(deleteFile);
            menu.Append(renameFile);

            menu.Popup(null, null, null, 3, Gtk.Global.CurrentEventTime);
            menu.ShowAll();
        }
Exemplo n.º 26
0
        void OnOutputMessageTextViewPopulatePopup(object o, Gtk.PopulatePopupArgs args)
        {
            if (OutputMessageTextView.IsAtUrlTag)
            {
                return;
            }

            Gtk.Menu popup = args.Menu;

            popup.Append(new Gtk.SeparatorMenuItem());
            foreach (var menu_item in CreateContextMenuItems())
            {
                popup.Append(menu_item);
            }

            popup.ShowAll();
        }
Exemplo n.º 27
0
        public void PopupQuickFixMenu()
        {
            Gtk.Menu menu = new Gtk.Menu();

            Dictionary <Gtk.MenuItem, ContextAction> fixTable = new Dictionary <Gtk.MenuItem, ContextAction> ();
            int mnemonic = 1;

            foreach (ContextAction fix in fixes)
            {
                var escapedLabel = fix.GetMenuText(document, loc).Replace("_", "__");
                var label        = (mnemonic <= 10)
                                                ? "_" + (mnemonic++ % 10).ToString() + " " + escapedLabel
                                                : "  " + escapedLabel;
                Gtk.MenuItem menuItem = new Gtk.MenuItem(label);
                fixTable [menuItem] = fix;
                menuItem.Activated += delegate(object sender, EventArgs e) {
                    // ensure that the Ast is recent.
                    document.UpdateParseDocument();
                    var runFix = fixTable [(Gtk.MenuItem)sender];
                    runFix.Run(document, loc);

                    document.Editor.Document.CommitUpdateAll();
                    menu.Destroy();
                };
                menu.Add(menuItem);
            }
            menu.ShowAll();
            int dx, dy;

            this.ParentWindow.GetOrigin(out dx, out dy);
            dx += ((TextEditorContainer.EditorContainerChild)(this.document.Editor.Parent.Parent as TextEditorContainer) [this]).X;
            dy += ((TextEditorContainer.EditorContainerChild)(this.document.Editor.Parent.Parent as TextEditorContainer) [this]).Y - (int)document.Editor.VAdjustment.Value;

            menu.Popup(null, null, delegate(Gtk.Menu menu2, out int x, out int y, out bool pushIn) {
                x          = dx;
                y          = dy + Allocation.Height;
                pushIn     = false;
                menuPushed = true;
                QueueDraw();
            }, 0, Gtk.Global.CurrentEventTime);
            menu.SelectFirst(true);
            menu.Destroyed += delegate {
                menuPushed = false;
                QueueDraw();
            };
        }
        protected override bool OnPopupMenu()
        {
            Gtk.Menu mnu = new Gtk.Menu();

            Gtk.ImageMenuItem play = new Gtk.ImageMenuItem(Gtk.Stock.MediaPlay, null);
            play.Activated += delegate(object sender, EventArgs a) {
                _view.PlayAlbum((CS_AlbumInfo)this.Model[Selection.FirstIndex]);
            };

            Gtk.ImageMenuItem edit = new Gtk.ImageMenuItem(Gtk.Stock.Edit, null);
            edit.Activated += delegate(object sender, EventArgs a) {
                _view.EditSheet(((CS_AlbumInfo)this.Model[Selection.FirstIndex]).getSheet());
            };

            Gtk.ImageMenuItem show_file = new Gtk.ImageMenuItem("Show in filesystem");
            show_file.Image      = new Gtk.Image(Gtk.Stock.Directory, Gtk.IconSize.Menu);
            show_file.Activated += delegate(object sender, EventArgs a) {
                _view.OpenContainingFolder((CS_AlbumInfo)this.Model[Selection.FirstIndex]);
            };

            mnu.Append(play);
            mnu.Append(new Gtk.SeparatorMenuItem());
            mnu.Append(edit);
            mnu.Append(show_file);

            CueSheet s = ((CS_AlbumInfo)this.Model[Selection.FirstIndex]).getSheet();

            if (Mp3Split.DllPresent())
            {
                if (Mp3Split.IsSupported(s.musicFileName()))
                {
                    Gtk.ImageMenuItem split = new Gtk.ImageMenuItem("Split & Write to location");
                    split.Image      = new Gtk.Image(Gtk.Stock.Convert, Gtk.IconSize.Menu);
                    split.Activated += delegate(object sender, EventArgs a) {
                        _view.MusicFileToDevice(((CS_AlbumInfo)this.Model[Selection.FirstIndex]).getSheet());
                    };
                    mnu.Append(split);
                }
            }

            mnu.ShowAll();
            mnu.Popup();

            return(false);
        }
Exemplo n.º 29
0
		protected override void Run (RefactoringOptions options)
		{
			Gtk.Menu menu = new Gtk.Menu ();
			
			bool resolveDirect;
			List<string> namespaces = GetResolveableNamespaces (options, out resolveDirect);
			
			foreach (string ns in namespaces) {
				// remove used namespaces for conflict resolving.
				if (options.Document.CompilationUnit.IsNamespaceUsedAt (ns, options.ResolveResult.ResolvedExpression.Region.Start))
					continue;
				Gtk.MenuItem menuItem = new Gtk.MenuItem (string.Format (GettextCatalog.GetString ("Add using '{0}'"), ns));
				CurrentRefactoryOperationsHandler.ResolveNameOperation resolveNameOperation = new CurrentRefactoryOperationsHandler.ResolveNameOperation (options.Dom, options.Document, options.ResolveResult, ns);
				menuItem.Activated += delegate {
					resolveNameOperation.AddImport ();
				};
				menu.Add (menuItem);
			}
			if (resolveDirect) {
				foreach (string ns in namespaces) {
					Gtk.MenuItem menuItem = new Gtk.MenuItem (string.Format (GettextCatalog.GetString ("Add '{0}'"), ns));
					CurrentRefactoryOperationsHandler.ResolveNameOperation resolveNameOperation = new CurrentRefactoryOperationsHandler.ResolveNameOperation (options.Dom, options.Document, options.ResolveResult, ns);
					menuItem.Activated += delegate {
						resolveNameOperation.ResolveName ();
					};
					menu.Add (menuItem);
				}
			}
			
			if (menu.Children != null && menu.Children.Length > 0) {
				menu.ShowAll ();
				
				ICompletionWidget widget = options.Document.GetContent<ICompletionWidget> ();
				CodeCompletionContext codeCompletionContext = widget.CreateCodeCompletionContext (options.GetTextEditorData ().Caret.Offset);

				menu.Popup (null, null, delegate (Gtk.Menu menu2, out int x, out int y, out bool pushIn) {
					x = codeCompletionContext.TriggerXCoord; 
					y = codeCompletionContext.TriggerYCoord; 
					pushIn = false;
				}, 0, Gtk.Global.CurrentEventTime);
				menu.SelectFirst (true);
			}
		}
Exemplo n.º 30
0
        private void _OnOutputMessageTextViewPopulatePopup(object o, Gtk.PopulatePopupArgs args)
        {
            if (OutputMessageTextView.IsAtUrlTag)
            {
                return;
            }

            Gtk.Menu popup = args.Menu;

            // minimum version of any command below
            if (Frontend.EngineProtocolVersion < new Version(0, 8, 11))
            {
                return;
            }

            popup.Append(new Gtk.SeparatorMenuItem());

            if (Frontend.EngineProtocolVersion >= new Version(0, 8, 12))
            {
                Gtk.ImageMenuItem whois_item = new Gtk.ImageMenuItem(_("Whois"));
                whois_item.Activated += _OnMenuWhoisItemActivated;
                popup.Append(whois_item);
            }

            if (Frontend.EngineProtocolVersion >= new Version(0, 8, 11))
            {
                Gtk.ImageMenuItem AddToContacts_item = new Gtk.ImageMenuItem(_("Add To Contacts"));
                AddToContacts_item.Activated += _OnMenuAddToContactsItemActivated;
                popup.Append(AddToContacts_item);
            }

            if (Frontend.EngineProtocolVersion >= new Version(0, 8, 12))
            {
                Gtk.ImageMenuItem invite_to_item      = new Gtk.ImageMenuItem(_("Invite to"));
                Gtk.Menu          invite_to_menu_item = new InviteToMenu(XmppProtocolManager,
                                                                         Frontend.MainWindow.ChatViewManager,
                                                                         PersonModel);
                invite_to_item.Submenu = invite_to_menu_item;
                popup.Append(invite_to_item);
            }

            popup.ShowAll();
        }
Exemplo n.º 31
0
 protected void OnRight(object sender, Gtk.ButtonPressEventArgs e)
 {
     if (e.Event.Button == 3)            // Botón derecho.
     {
         Gtk.TreePath RowPath;
         if (Exercises.GetPathAtPos(Convert.ToInt32(e.Event.X),
                                    Convert.ToInt32(e.Event.Y),
                                    out RowPath))
         {
             int          ActiveRow      = RowPath.Indices[0];
             Gtk.Menu     m              = new Gtk.Menu();
             Gtk.MenuItem DeleteExercise = new Gtk.MenuItem("Delete exercise");
             DeleteExercise.ButtonPressEvent += (o, a) => OnDelete(ActiveRow);
             m.Add(DeleteExercise);
             m.ShowAll();
             m.Popup();
         }
     }
 }
        protected override bool OnPopupMenu()
        {
            Gtk.Menu mnu=new Gtk.Menu();

            Gtk.ImageMenuItem play=new Gtk.ImageMenuItem(Gtk.Stock.MediaPlay,null);
            play.Activated+=delegate(object sender,EventArgs a) {
                _view.PlayAlbum((CS_AlbumInfo) this.Model[Selection.FirstIndex]);
            };

            Gtk.ImageMenuItem edit=new Gtk.ImageMenuItem(Gtk.Stock.Edit,null);
            edit.Activated+=delegate(object sender,EventArgs a) {
                _view.EditSheet(((CS_AlbumInfo) this.Model[Selection.FirstIndex]).getSheet ());
            };

            Gtk.ImageMenuItem show_file=new Gtk.ImageMenuItem("Show in filesystem");
            show_file.Image=new Gtk.Image(Gtk.Stock.Directory,Gtk.IconSize.Menu);
            show_file.Activated+=delegate(object sender, EventArgs a) {
                _view.OpenContainingFolder((CS_AlbumInfo) this.Model[Selection.FirstIndex]);
            };

            mnu.Append (play);
            mnu.Append (new Gtk.SeparatorMenuItem());
            mnu.Append (edit);
            mnu.Append (show_file);

            CueSheet s=((CS_AlbumInfo) this.Model[Selection.FirstIndex]).getSheet ();
            if (Mp3Split.DllPresent()) {
                if (Mp3Split.IsSupported(s.musicFileName ())) {
                    Gtk.ImageMenuItem split=new Gtk.ImageMenuItem("Split & Write to location");
                    split.Image=new Gtk.Image(Gtk.Stock.Convert,Gtk.IconSize.Menu);
                    split.Activated+=delegate(object sender,EventArgs a) {
                        _view.MusicFileToDevice(((CS_AlbumInfo) this.Model[Selection.FirstIndex]).getSheet ());
                    };
                    mnu.Append (split);
                }
            }

            mnu.ShowAll ();
            mnu.Popup();

            return false;
        }
Exemplo n.º 33
0
        // HERZUM SPRINT 2.3 TLAB-56 TLAB-57 TLAB-58 TLAB-59

        /*
         * private void PopupContextMenu(IPrimaryToolDelegator mainTool, IDrawingEditor editor, ITool dt, MouseEvent ev)
         * {
         *  m_contextMenu = new Gtk.Menu();
         *  Gtk.MenuItem editLabel = new Gtk.MenuItem("Edit label");
         *
         *  editLabel.Activated += delegate(object sender, EventArgs e)
         *  {
         *      SimpleTextTool textTool = new SimpleTextTool(editor, this, dt, ev);
         *      mainTool.DelegateTool = textTool;
         *      textTool.StartEditing();
         *  };
         *
         *  m_contextMenu.Add(editLabel);
         *  m_contextMenu.ShowAll();
         *
         *  m_contextMenu.Popup();
         * }
         */

        private void PopupContextMenu(IPrimaryToolDelegator mainTool, IDrawingEditor editor, ITool dt, MouseEvent ev)
        {
            m_contextMenu = new Gtk.Menu();
            Gtk.MenuItem editLabel = new Gtk.MenuItem("Edit label");
            Gtk.MenuItem copy      = new Gtk.MenuItem("Copy");
            Gtk.MenuItem cut       = new Gtk.MenuItem("Cut");
            // Gtk.MenuItem paste = new Gtk.MenuItem("Paste");

            editLabel.Activated += delegate(object sender, EventArgs e)
            {
                SimpleTextTool textTool = new SimpleTextTool(editor, this, dt, ev);
                mainTool.DelegateTool = textTool;
                textTool.StartEditing();
            };

            copy.Activated += delegate(object sender, EventArgs e)
            {
                Clipboard.Copy(ExperimentNode.Owner as BaseExperiment);
            };

            cut.Activated += delegate(object sender, EventArgs e)
            {
                Clipboard.Cut(ExperimentNode.Owner as BaseExperiment);
            };

            /*
             * paste.Activated += delegate(object sender, EventArgs e)
             * {
             *  Clipboard.Paste(ExperimentNode.Owner as BaseExperiment);
             *  ExperimentCanvasPad ecp = ExperimentCanvasPadFactory.GetExperimentCanvasPad(m_applicationContext, this);
             *  ecp.DisplayAddedSubgraph(ExperimentNode.Owner as BaseExperiment);
             * };
             */

            m_contextMenu.Add(editLabel);
            m_contextMenu.Add(copy);
            m_contextMenu.Add(cut);
            // m_contextMenu.Add(paste);
            m_contextMenu.ShowAll();

            m_contextMenu.Popup();
        }
Exemplo n.º 34
0
		public override void OnNoteOpened ()
		{
			menu = new Gtk.Menu ();
			menu.Hidden += OnMenuHidden;
			menu.ShowAll ();
			
			Gtk.Image tasqueImage = new Gtk.Image (TasqueIcon);
			tasqueImage.Show ();
			menuToolButton =
				new Gtk.MenuToolButton (tasqueImage, Catalog.GetString ("Tasque"));
			menuToolButton.Menu = menu;
			menuToolButton.Clicked += OnMenuToolButtonClicked;
			menuToolButton.ShowMenu += OnMenuItemActivated;
			menuToolButton.Sensitive = false;
			menuToolButton.Show ();
			AddToolItem (menuToolButton, -1);
			
			// Sensitize the Task button on text selection
			markSetTimeout = new InterruptableTimeout();
			markSetTimeout.Timeout += UpdateTaskButtonSensitivity;
			Note.Buffer.MarkSet += OnSelectionMarkSet;
		}
Exemplo n.º 35
0
		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;
		}
Exemplo n.º 36
0
		public void PopupQuickFixMenu ()
		{
			Gtk.Menu menu = new Gtk.Menu ();
			
			Dictionary<Gtk.MenuItem, ContextAction> fixTable = new Dictionary<Gtk.MenuItem, ContextAction> ();
			int mnemonic = 1;
			foreach (ContextAction fix in fixes) {
				var escapedLabel = fix.GetMenuText (document, loc).Replace ("_", "__");
				var label = (mnemonic <= 10)
						? "_" + (mnemonic++ % 10).ToString () + " " + escapedLabel
						: "  " + escapedLabel;
				Gtk.MenuItem menuItem = new Gtk.MenuItem (label);
				fixTable [menuItem] = fix;
				menuItem.Activated += delegate(object sender, EventArgs e) {
					// ensure that the Ast is recent.
					document.UpdateParseDocument ();
					var runFix = fixTable [(Gtk.MenuItem)sender];
					runFix.Run (document, loc);
					
					document.Editor.Document.CommitUpdateAll ();
					menu.Destroy ();
				};
				menu.Add (menuItem);
			}
			menu.ShowAll ();
			int dx, dy;
			this.ParentWindow.GetOrigin (out dx, out dy);
			dx += ((TextEditorContainer.EditorContainerChild)(this.document.Editor.Parent.Parent as TextEditorContainer) [this]).X;
			dy += ((TextEditorContainer.EditorContainerChild)(this.document.Editor.Parent.Parent as TextEditorContainer) [this]).Y - (int)document.Editor.VAdjustment.Value;
					
			menu.Popup (null, null, delegate (Gtk.Menu menu2, out int x, out int y, out bool pushIn) {
				x = dx; 
				y = dy + Allocation.Height; 
				pushIn = false;
				menuPushed = true;
				QueueDraw ();
			}, 0, Gtk.Global.CurrentEventTime);
			menu.SelectFirst (true);
			menu.Destroyed += delegate {
				menuPushed = false;
				QueueDraw ();
			};
		}
Exemplo n.º 37
0
        private void PopulateAlbums()
        {
            Gtk.Menu menu = new Gtk.Menu ();
            if (gallery.Version == GalleryVersion.Version1) {
                Gtk.MenuItem top_item = new Gtk.MenuItem (Catalog.GetString ("(TopLevel)"));
                menu.Append (top_item);
            }

            foreach (Album album in gallery.Albums) {
                System.Text.StringBuilder label_builder = new System.Text.StringBuilder ();

                for (int i=0; i < album.Parents.Count; i++) {
                    label_builder.Append ("  ");
                }

                label_builder.Append (album.Title);
                album_optionmenu.AppendText(label_builder.ToString());
            }

            album_optionmenu.Sensitive = true;
            menu.ShowAll ();
        }
Exemplo n.º 38
0
	void PopupQuickFixMenu (Gdk.EventButton evt)
		{
			var menu = new Gtk.Menu ();

			Gtk.Menu fixMenu = menu;
			ResolveResult resolveResult;
			ICSharpCode.NRefactory.CSharp.AstNode node;
			int items = 0;
			if (ResolveCommandHandler.ResolveAt (document, out resolveResult, out node)) {
				var possibleNamespaces = MonoDevelop.Refactoring.ResolveCommandHandler.GetPossibleNamespaces (
					document,
					node,
					ref resolveResult
				);
	
				bool addUsing = !(resolveResult is AmbiguousTypeResolveResult);
				if (addUsing) {
					foreach (var t in possibleNamespaces.Where (tp => tp.Item2)) {
						string ns = t.Item1;
						var menuItem = new Gtk.MenuItem (string.Format ("using {0};", ns));
						menuItem.Activated += delegate {
							new MonoDevelop.Refactoring.ResolveCommandHandler.AddImport (document, resolveResult, ns, true, node).Run ();
							menu.Destroy ();
						};
						menu.Add (menuItem);
						items++;
					}
				}
				
				bool resolveDirect = !(resolveResult is UnknownMemberResolveResult);
				if (resolveDirect) {
					foreach (var t in possibleNamespaces) {
						string ns = t.Item1;
						var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("{0}", ns + "." + document.Editor.GetTextBetween (node.StartLocation, node.EndLocation)));
						menuItem.Activated += delegate {
							new MonoDevelop.Refactoring.ResolveCommandHandler.AddImport (document, resolveResult, ns, false, node).Run ();
							menu.Destroy ();
						};
						menu.Add (menuItem);
						items++;
					}
				}
				if (menu.Children.Any () && fixes.Any ()) {
					fixMenu = new Gtk.Menu ();
					var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("Quick Fixes"));
					menuItem.Submenu = fixMenu;
					menu.Add (menuItem);
					items++;
				}
			}
			
			PopulateFixes (fixMenu, ref items);
			if (items == 0) {
				menu.Destroy ();
				return;
			}
			document.Editor.SuppressTooltips = true;
			document.Editor.Parent.HideTooltip ();
			menu.ShowAll ();
			menu.SelectFirst (true);
			menuPushed = true;
			menu.Hidden += delegate {
				document.Editor.SuppressTooltips = false;
			};
			menu.Destroyed += delegate {
				menuPushed = false;
				Hide ();
			};
			var container = document.Editor.Parent;
			var child = (TextEditor.EditorContainerChild)container [this];

			Gdk.Rectangle rect;
/*			if (child != null) {
				rect = new Gdk.Rectangle (child.X, child.Y + Allocation.Height - (int)document.Editor.VAdjustment.Value, 0, 0);
			} else {*/
				var p = container.LocationToPoint (loc);
				rect = new Gdk.Rectangle (p.X + container.Allocation.X , p.Y + (int)document.Editor.LineHeight + container.Allocation.Y, 0, 0);
			//}
			GtkWorkarounds.ShowContextMenu (menu, document.Editor.Parent, null, rect);
		}
Exemplo n.º 39
0
        public void Step1_SetWidget(Gtk.Widget widget)
        {
            // Add right-click context menu to control.
            var menu = new Gtk.Menu();
            var resetMenuItem = new Gtk.MenuItem("Reset Camera Offset");
            resetMenuItem.Activated += delegate(object sender, EventArgs e) {
                SetCameraOffset(0, 0);
            };
            menu.Add(resetMenuItem);

            // Handle mouse move events.
            widget.MotionNotifyEvent += delegate(object o, Gtk.MotionNotifyEventArgs args) {
                if (!m_enabled) return;
                if (!m_mouseDown) return;

                double x = args.Event.X;
                double y = args.Event.Y;
                double dx = x - m_mouseDownX;
                double dy = y - m_mouseDownY;

                SetCameraOffset(m_offsetDownX + dx, m_offsetDownY + dy);
            };
            widget.ButtonPressEvent += delegate(object o, Gtk.ButtonPressEventArgs args) {
                if (m_enablePopupMenu && (args.Event.Button & 2) == 2) {
                    menu.ShowAll();
                    menu.Popup();
                    return;
                }

                m_mouseDown = true;
                m_mouseDownX = args.Event.X;
                m_mouseDownY = args.Event.Y;
                m_offsetDownX = m_offsetX;
                m_offsetDownY = m_offsetY;
            };
            widget.ButtonReleaseEvent += delegate(object o, Gtk.ButtonReleaseEventArgs args) {
                m_mouseDown = false;
            };
        }
        private void PopupContextMenu(IPrimaryToolDelegator mainTool, IDrawingEditor editor, ITool dt, MouseEvent ev)
        {
            m_contextMenu = new Gtk.Menu();
            Gtk.MenuItem editLabel = new Gtk.MenuItem("Edit label");

            editLabel.Activated += delegate(object sender, EventArgs e) 
            {
                SimpleTextTool textTool = new SimpleTextTool(editor, this, dt, ev);
                mainTool.DelegateTool = textTool;
                textTool.StartEditing();
            };
    
            m_contextMenu.Add(editLabel);
            m_contextMenu.ShowAll();

            m_contextMenu.Popup();
        }
Exemplo n.º 41
0
        // HERZUM SPRINT 2.3 TLAB-56 TLAB-57 TLAB-58 TLAB-59
        /*
        private void PopupContextMenu(IPrimaryToolDelegator mainTool, IDrawingEditor editor, ITool dt, MouseEvent ev)
        {
            m_contextMenu = new Gtk.Menu();
            Gtk.MenuItem editLabel = new Gtk.MenuItem("Edit label");

            editLabel.Activated += delegate(object sender, EventArgs e) 
            {
                SimpleTextTool textTool = new SimpleTextTool(editor, this, dt, ev);
                mainTool.DelegateTool = textTool;
                textTool.StartEditing();
            };
    
            m_contextMenu.Add(editLabel);
            m_contextMenu.ShowAll();

            m_contextMenu.Popup();
        }
        */

        private void PopupContextMenu(IPrimaryToolDelegator mainTool, IDrawingEditor editor, ITool dt, MouseEvent ev)
        {
            m_contextMenu = new Gtk.Menu();
            Gtk.MenuItem editLabel = new Gtk.MenuItem("Edit label");
            Gtk.MenuItem copy = new Gtk.MenuItem("Copy");
            Gtk.MenuItem cut = new Gtk.MenuItem("Cut");
            // Gtk.MenuItem paste = new Gtk.MenuItem("Paste");

            editLabel.Activated += delegate(object sender, EventArgs e) 
            {
                SimpleTextTool textTool = new SimpleTextTool(editor, this, dt, ev);
                mainTool.DelegateTool = textTool;
                textTool.StartEditing();
            };

            copy.Activated += delegate(object sender, EventArgs e) 
            {
                Clipboard.Copy(ExperimentNode.Owner as BaseExperiment);
            };

            cut.Activated += delegate(object sender, EventArgs e) 
            {
                Clipboard.Cut(ExperimentNode.Owner as BaseExperiment);
            };

            /*
            paste.Activated += delegate(object sender, EventArgs e) 
            {
                Clipboard.Paste(ExperimentNode.Owner as BaseExperiment);
                ExperimentCanvasPad ecp = ExperimentCanvasPadFactory.GetExperimentCanvasPad(m_applicationContext, this);
                ecp.DisplayAddedSubgraph(ExperimentNode.Owner as BaseExperiment); 
            };
            */

            m_contextMenu.Add(editLabel);
            m_contextMenu.Add(copy);
            m_contextMenu.Add(cut);
            // m_contextMenu.Add(paste);
            m_contextMenu.ShowAll();

            m_contextMenu.Popup();
        }
Exemplo n.º 42
0
        private static void OnStatusIconPopupMenu(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            Gtk.Menu menu = new Gtk.Menu();

            Gtk.ImageMenuItem preferencesItem = new Gtk.ImageMenuItem(Gtk.Stock.Preferences, null);
            preferencesItem.Activated += delegate {
                try {
                    PreferencesDialog dialog = new PreferencesDialog(_MainWindow);
                    dialog.CurrentPage = PreferencesDialog.Page.Interface;
                    dialog.CurrentInterfacePage = PreferencesDialog.InterfacePage.Notification;
                } catch (Exception ex) {
                    ShowException(ex);
                }
            };
            menu.Add(preferencesItem);

            menu.Add(new Gtk.SeparatorMenuItem());

            Gtk.ImageMenuItem quitItem = new Gtk.ImageMenuItem(Gtk.Stock.Quit, null);
            quitItem.Activated += delegate {
                try {
                    Quit();
                } catch (Exception ex) {
                    ShowException(ex);
                }
            };
            menu.Add(quitItem);

            menu.ShowAll();
            menu.Popup();
        }
Exemplo n.º 43
0
 void UpdateRoutesButton()
 {
     var menu = new Gtk.Menu();
     foreach(var route in routesAtDay)
     {
         var name = String.Format("МЛ №{0} - {1}", route.Id, route.Driver.ShortName);
         var item = new MenuItemId<RouteList>(name);
         item.ID = route;
         item.Activated += AddToRLItem_Activated;
         menu.Append(item);
     }
     menu.ShowAll();
     menuAddToRL.Menu = menu;
 }
Exemplo n.º 44
0
		void nsIContextMenuListener2.OnShowContextMenu(uint aContextFlags, nsIContextMenuInfo info)
		{
			// if we don't have a target node, we can't do anything by default.  this happens in XUL forms (i.e. about:config)
			if (info.GetTargetNodeAttribute() == null)
				return;
			
			ContextMenu menu = new ContextMenu();
			
			// no default items are added when the context menu is disabled
			if (!this.NoDefaultContextMenu)
			{
				List<MenuItem> optionals = new List<MenuItem>();
				
				if (this.CanUndo || this.CanRedo)
				{
					optionals.Add(new MenuItem("Undo", delegate { Undo(); }));
					optionals.Add(new MenuItem("Redo", delegate { Redo(); }));
					
					optionals[0].Enabled = this.CanUndo;
					optionals[1].Enabled = this.CanRedo;
				}
				else
				{
					optionals.Add(new MenuItem("Back", delegate { GoBack(); }));
					optionals.Add(new MenuItem("Forward", delegate { GoForward(); }));
					
					optionals[0].Enabled = this.CanGoBack;
					optionals[1].Enabled = this.CanGoForward;
				}
				
				optionals.Add(new MenuItem("-"));
				
				if (this.CanCopyImageContents)
					optionals.Add(new MenuItem("Copy Image Contents", delegate { CopyImageContents(); }));
				
				if (this.CanCopyImageLocation)
					optionals.Add(new MenuItem("Copy Image Location", delegate { CopyImageLocation(); }));
				
				if (this.CanCopyLinkLocation)
					optionals.Add(new MenuItem("Copy Link Location", delegate { CopyLinkLocation(); }));
				
				if (this.CanCopySelection)
					optionals.Add(new MenuItem("Copy Selection", delegate { CopySelection(); }));
				
				MenuItem mnuSelectAll = new MenuItem("Select All");
				mnuSelectAll.Click += delegate { SelectAll(); };

				GeckoDomDocument doc = GeckoDomDocument.CreateDomDocumentWraper(info.GetTargetNodeAttribute().GetOwnerDocumentAttribute());

				string viewSourceUrl = (doc == null) ? null : Convert.ToString(doc.Uri);
				
				MenuItem mnuViewSource = new MenuItem("View Source");
				mnuViewSource.Enabled = !string.IsNullOrEmpty(viewSourceUrl);
				mnuViewSource.Click += delegate { ViewSource(viewSourceUrl); };

				MenuItem mnuOpenInSystemBrowser = new MenuItem("View In System Browser");//nice for debugging with firefox/firebug
				mnuOpenInSystemBrowser.Enabled = !string.IsNullOrEmpty(viewSourceUrl);
				mnuOpenInSystemBrowser.Click += delegate { ViewInSystemBrowser(viewSourceUrl); };


				string properties = (doc != null && doc.Uri == Document.Uri) ? "Page Properties" : "IFRAME Properties";
				
				MenuItem mnuProperties = new MenuItem(properties);
				mnuProperties.Enabled = doc != null;
				mnuProperties.Click += delegate { ShowPageProperties(doc); };
				
				menu.MenuItems.AddRange(optionals.ToArray());
				menu.MenuItems.Add(mnuSelectAll);
				menu.MenuItems.Add("-");
				menu.MenuItems.Add(mnuViewSource);
				menu.MenuItems.Add(mnuOpenInSystemBrowser);
				menu.MenuItems.Add(mnuProperties);
			}

			// get image urls
			Uri backgroundImageSrc = null, imageSrc = null;
			nsIURI src;
			try
			{
				src = info.GetBackgroundImageSrcAttribute();
				backgroundImageSrc = src.ToUri();
				Marshal.ReleaseComObject( src );
			}
			catch (COMException comException)
			{
				if ((comException.ErrorCode & 0xFFFFFFFF) != 0x80004005)
					throw comException;
			}

			try
			{
				src = info.GetImageSrcAttribute();
				if ( src != null )
				{
					imageSrc = src.ToUri();
					Marshal.ReleaseComObject( src );
				}
			}
			catch (COMException comException)
			{
				if ((comException.ErrorCode & 0xFFFFFFFF) != 0x80004005)
					throw comException;
			}
			
			// get associated link.  note that this needs to be done manually because GetAssociatedLink returns a non-zero
			// result when no associated link is available, so an exception would be thrown by nsString.Get()
			string associatedLink = null;
			try
			{
				using (nsAString str = new nsAString())
				{
					info.GetAssociatedLinkAttribute(str);
					associatedLink = str.ToString();
				}
			}
			catch (COMException comException) { }			
			
			GeckoContextMenuEventArgs e = new GeckoContextMenuEventArgs(
				PointToClient(MousePosition), menu, associatedLink, backgroundImageSrc, imageSrc,
				GeckoNode.Create(Xpcom.QueryInterface<nsIDOMNode>(info.GetTargetNodeAttribute()))
				);
			
			OnShowContextMenu(e);
			
			if (e.ContextMenu != null && e.ContextMenu.MenuItems.Count > 0)
			{
#if GTK
				// When using GTK we can't use SWF to display the context menu: SWF displays
				// the context menu and then tries to track the mouse so that it knows when to
				// close the context menu. However, GTK intercepts the mouse click before SWF gets
				// it, so the menu never closes. Instead we display a GTK menu and translate
				// the SWF menu items into Gtk.MenuItems.
				// TODO: currently this code only handles text menu items. Would be nice to also
				// translate images etc.
				var popupMenu = new Gtk.Menu();

				foreach (MenuItem swfMenuItem in e.ContextMenu.MenuItems)
				{
					var gtkMenuItem = new Gtk.MenuItem(swfMenuItem.Text);
					gtkMenuItem.Sensitive = swfMenuItem.Enabled;
					MenuItem origMenuItem = swfMenuItem;
					gtkMenuItem.Activated += (sender, ev) => origMenuItem.PerformClick();
					popupMenu.Append(gtkMenuItem);
				}
				popupMenu.ShowAll();
				popupMenu.Popup();
#else
				e.ContextMenu.Show(this, e.Location);
#endif
			}
		}
Exemplo n.º 45
0
		Gtk.Menu GetRightClickMenu ()
		{
			if (tray.TomboyTrayMenu != null)
				tray.TomboyTrayMenu.Hide ();

			if (context_menu != null) {
				context_menu.Hide ();
				return context_menu;
			}

			context_menu = new Gtk.Menu ();

			Gtk.AccelGroup accel_group = new Gtk.AccelGroup ();
			context_menu.AccelGroup = accel_group;

			Gtk.ImageMenuItem item;

			sync_menu_item = new Gtk.ImageMenuItem (Catalog.GetString ("S_ynchronize Notes"));
			sync_menu_item.Image = new Gtk.Image (Gtk.Stock.Convert, Gtk.IconSize.Menu);
			UpdateMenuItems();
			Preferences.SettingChanged += Preferences_SettingChanged;
			sync_menu_item.Activated += SyncNotes;
			context_menu.Append (sync_menu_item);

			context_menu.Append (new Gtk.SeparatorMenuItem ());

			item = new Gtk.ImageMenuItem (Catalog.GetString ("_Preferences"));
			item.Image = new Gtk.Image (Gtk.Stock.Preferences, Gtk.IconSize.Menu);
			item.Activated += ShowPreferences;
			context_menu.Append (item);

			item = new Gtk.ImageMenuItem (Catalog.GetString ("_Help"));
			item.Image = new Gtk.Image (Gtk.Stock.Help, Gtk.IconSize.Menu);
			item.Activated += ShowHelpContents;
			context_menu.Append (item);

			item = new Gtk.ImageMenuItem (Catalog.GetString ("_About Tomboy"));
			item.Image = new Gtk.Image (Gtk.Stock.About, Gtk.IconSize.Menu);
			item.Activated += ShowAbout;
			context_menu.Append (item);

			context_menu.Append (new Gtk.SeparatorMenuItem ());

			item = new Gtk.ImageMenuItem (Catalog.GetString ("_Quit"));
			item.Image = new Gtk.Image (Gtk.Stock.Quit, Gtk.IconSize.Menu);
			item.Activated += Quit;
			context_menu.Append (item);

			context_menu.ShowAll ();
			return context_menu;
		}
		private void PopulateAlbumOptionMenu (PicasaWeb picasa)
		{
			if (picasa != null) {
				try {
					albums = picasa.GetAlbums();
				} catch {
					Console.WriteLine("Can't get the albums");
					albums = null;
					picasa = null;
				}
			}

			Gtk.Menu menu = new Gtk.Menu ();

			bool disconnected = picasa == null || !account.Connected || albums == null;

			if (disconnected || albums.Count == 0) {
				string msg = disconnected ? Catalog.GetString ("(Not Connected)")
					: Catalog.GetString ("(No Albums)");

				Gtk.MenuItem item = new Gtk.MenuItem (msg);
				menu.Append (item);

				export_button.Sensitive = false;
				album_optionmenu.Sensitive = false;
				album_button.Sensitive = false;

				if (disconnected)
					album_button.Sensitive = false;
			} else {
				foreach (PicasaAlbum album in albums.AllValues) {
					System.Text.StringBuilder label_builder = new System.Text.StringBuilder ();

					label_builder.Append (album.Title);
					label_builder.Append (" (" + album.PicturesCount + ")");

					Gtk.MenuItem item = new Gtk.MenuItem (label_builder.ToString ());
					((Gtk.Label)item.Child).UseUnderline = false;
					menu.Append (item);
				}

				export_button.Sensitive = items.Length > 0;
				album_optionmenu.Sensitive = true;
				album_button.Sensitive = true;
			}

			menu.ShowAll ();
			album_optionmenu.Menu = menu;
		}
Exemplo n.º 47
0
        private void PopulateAlbums()
        {
            Gtk.Menu menu = new Gtk.Menu ();
            if (gallery.Version == GalleryVersion.Version1) {
                Gtk.MenuItem top_item = new Gtk.MenuItem (Catalog.GetString ("(TopLevel)"));
                menu.Append (top_item);
            }

            foreach (Album album in gallery.Albums) {
                System.Text.StringBuilder label_builder = new System.Text.StringBuilder ();

                for (int i=0; i < album.Parents.Count; i++) {
                    label_builder.Append ("  ");
                }
                label_builder.Append (album.Title);

                Gtk.MenuItem item = new Gtk.MenuItem (label_builder.ToString ());
                ((Gtk.Label)item.Child).UseUnderline = false;
                menu.Append (item);

                AlbumPermission create_sub = album.Perms & AlbumPermission.CreateSubAlbum;

                if (create_sub == 0)
                    item.Sensitive = false;
            }

            album_optionmenu.Sensitive = true;
            menu.ShowAll ();
            album_optionmenu.Menu = menu;
        }
Exemplo n.º 48
0
        void IMenuItemContainer.ShowContextMenu(ActionItem aitem)
        {
            ActionMenuItem menuItem = aitem as ActionMenuItem;

            Gtk.Menu m = new Gtk.Menu ();
            Gtk.MenuItem item = new Gtk.ImageMenuItem (Gtk.Stock.Cut, null);
            m.Add (item);
            item.Activated += delegate (object s, EventArgs a) {
                Cut (menuItem);
            };
            item.Visible = false;	// No copy & paste for now
            item = new Gtk.ImageMenuItem (Gtk.Stock.Copy, null);
            m.Add (item);
            item.Activated += delegate (object s, EventArgs a) {
                Copy (menuItem);
            };
            item.Visible = false;	// No copy & paste for now
            item = new Gtk.ImageMenuItem (Gtk.Stock.Paste, null);
            m.Add (item);
            item.Activated += delegate (object s, EventArgs a) {
                Paste (menuItem);
            };
            item.Visible = false;	// No copy & paste for now
            item = new Gtk.ImageMenuItem (Gtk.Stock.Delete, null);
            m.Add (item);
            item.Activated += delegate (object s, EventArgs a) {
                Delete (menuItem);
            };
            m.ShowAll ();
            m.Popup ();
        }
Exemplo n.º 49
0
        private void ShowPopup()
        {
            if ((presets == null) || (presets.Length == 0))
                return;

            EventHandler onActivated = delegate(object sender, EventArgs e) {
                Gtk.MenuItem item = (Gtk.MenuItem)sender;

                SetPlaceholderText(false);

                if (Text.Length > 0) {
                    if ((!Text.TrimEnd().EndsWith(" or")) && (!Text.TrimEnd().EndsWith(" OR")) &&
                        (!Text.TrimEnd().EndsWith(" and")) && (!Text.TrimEnd().EndsWith(" AND"))) {

                        if (!Text.EndsWith(" "))
                            Text += " ";

                        Text += "and ";
                    } else {
                        if (!Text.EndsWith(" "))
                            Text += " ";
                    }
                }

                var p = (SearchEntryPreset)item.Data["preset"];

                if (!string.IsNullOrEmpty(p.Value)) {
                    Text += p.Value;

                    if (!string.IsNullOrEmpty(p.Suggestion)) {
                        Text += " " + p.Suggestion;

                        GrabFocus();
                        SelectRegion(Text.Length - p.Suggestion.Length, Text.Length);
                    } else {
                        GrabFocus();
                        SelectRegion(Text.Length, Text.Length);
                    }
                }
            };

            if (presetsChanged) {

                if (popup != null)
                    popup.Dispose();

                popup = new Gtk.Menu();

                foreach (var p in presets) {
                    Gtk.MenuItem item = new Gtk.MenuItem(p.Caption);
                    item.Activated += onActivated;
                    item.Data["preset"] = p;

                    popup.Append(item);
                }

                popup.ShowAll();
                presetsChanged = false;
            }

            popup.Popup();
        }
Exemplo n.º 50
0
		void PopupQuickFixMenu (Gdk.EventButton evt)
		{
			var menu = new Gtk.Menu ();

			Gtk.Menu fixMenu = menu;
			ResolveResult resolveResult;
			ICSharpCode.NRefactory.CSharp.AstNode node;
			if (ResolveCommandHandler.ResolveAt (document, out resolveResult, out node)) {
				var possibleNamespaces = MonoDevelop.Refactoring.ResolveCommandHandler.GetPossibleNamespaces (
					document,
					node,
					resolveResult
				);
	
				bool addUsing = !(resolveResult is AmbiguousTypeResolveResult);
				if (addUsing) {
					foreach (string ns_ in possibleNamespaces) {
						string ns = ns_;
						var menuItem = new Gtk.MenuItem (string.Format ("using {0};", ns));
						menuItem.Activated += delegate {
							new MonoDevelop.Refactoring.ResolveCommandHandler.AddImport (document, resolveResult, ns, true).Run ();
							menu.Destroy ();
						};
						menu.Add (menuItem);
					}
				}
				
				bool resolveDirect = !(resolveResult is UnknownMemberResolveResult);
				if (resolveDirect) {
					foreach (string ns in possibleNamespaces) {
						var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("{0}", ns + "." + document.Editor.GetTextBetween (node.StartLocation, node.EndLocation)));
						menuItem.Activated += delegate {
							new MonoDevelop.Refactoring.ResolveCommandHandler.AddImport (document, resolveResult, ns, false).Run ();
							menu.Destroy ();
						};
						menu.Add (menuItem);
					}
				}
				if (menu.Children.Any () && fixes.Any ()) {
					fixMenu = new Gtk.Menu ();
					var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("Quick Fixes"));
					menuItem.Submenu = fixMenu;
					menu.Add (menuItem);
				}
			}
			
			PopulateFixes (fixMenu);
			
			menu.ShowAll ();
			menu.SelectFirst (true);
			menuPushed = true;
			menu.Destroyed += delegate {
				menuPushed = false;
				Hide ();
			};
			var container = (TextEditorContainer)document.Editor.Parent.Parent;
			var child = (TextEditorContainer.EditorContainerChild)container [this];
			GtkWorkarounds.ShowContextMenu (menu, document.Editor.Parent, null, new Gdk.Rectangle (child.X, child.Y + Allocation.Height - (int)document.Editor.VAdjustment.Value, 0, 0));
		}
Exemplo n.º 51
0
        public void ShowContextMenu(ActionItem aitem)
        {
            ActionMenuItem menuItem = (ActionMenuItem) aitem;

            Gtk.Menu m = new Gtk.Menu ();
            Gtk.MenuItem item = new Gtk.MenuItem (Catalog.GetString ("Insert Before"));
            m.Add (item);
            item.Activated += delegate (object s, EventArgs a) {
                InsertActionAt (menuItem, false, false);
            };
            item = new Gtk.MenuItem (Catalog.GetString ("Insert After"));
            m.Add (item);
            item.Activated += delegate (object s, EventArgs a) {
                InsertActionAt (menuItem, true, false);
            };

            m.Add (new Gtk.SeparatorMenuItem ());

            item = new Gtk.ImageMenuItem (Gtk.Stock.Cut, null);
            m.Add (item);
            item.Activated += delegate (object s, EventArgs a) {
                menuItem.Cut ();
            };
            item.Visible = false;	// No copy & paste for now
            item = new Gtk.ImageMenuItem (Gtk.Stock.Copy, null);
            m.Add (item);
            item.Activated += delegate (object s, EventArgs a) {
                menuItem.Copy ();
            };
            item.Visible = false;	// No copy & paste for now
            item = new Gtk.ImageMenuItem (Gtk.Stock.Paste, null);
            m.Add (item);
            item.Activated += delegate (object s, EventArgs a) {
                Paste (menuItem);
            };
            item.Visible = false;	// No copy & paste for now
            item = new Gtk.ImageMenuItem (Gtk.Stock.Delete, null);
            m.Add (item);
            item.Activated += delegate (object s, EventArgs a) {
                menuItem.Delete ();
            };
            m.ShowAll ();
            m.Popup ();
        }
Exemplo n.º 52
0
        public ChatView(ChatModel chat)
        {
            Trace.Call(chat);

            _ChatModel = chat;

            IsAutoScrolling = true;
            MessageTextView tv = new MessageTextView();
            _EndMark = tv.Buffer.CreateMark("end", tv.Buffer.EndIter, false);
            tv.ShowTimestamps = true;
            tv.ShowMarkerline = true;
            tv.Editable = false;
            tv.CursorVisible = true;
            tv.WrapMode = Gtk.WrapMode.Char;
            tv.MessageAdded += OnMessageTextViewMessageAdded;
            tv.MessageHighlighted += OnMessageTextViewMessageHighlighted;
            tv.PopulatePopup += OnMessageTextViewPopulatePopup;
            tv.SizeRequested += delegate {
                AutoScroll();
            };
            _OutputMessageTextView = tv;

            Gtk.ScrolledWindow sw = new Gtk.ScrolledWindow();
            _OutputScrolledWindow = sw;
            //sw.HscrollbarPolicy = Gtk.PolicyType.Never;
            sw.HscrollbarPolicy = Gtk.PolicyType.Automatic;
            sw.VscrollbarPolicy = Gtk.PolicyType.Always;
            sw.ShadowType = Gtk.ShadowType.In;
            sw.Vadjustment.ValueChanged += delegate {
                CheckAutoScroll();
            };
            sw.Add(_OutputMessageTextView);

            // popup menu
            _TabMenu = new Gtk.Menu();

            Gtk.ImageMenuItem close_item = new Gtk.ImageMenuItem(Gtk.Stock.Close, null);
            close_item.Activated += new EventHandler(OnTabMenuCloseActivated);
            _TabMenu.Append(close_item);
            _TabMenu.ShowAll();

            //FocusChild = _OutputTextView;
            //CanFocus = false;

            _TabLabel = new Gtk.Label();

            TabImage = DefaultTabImage;
            _TabHBox = new Gtk.HBox();
            _TabHBox.PackEnd(new Gtk.Fixed(), true, true, 0);
            _TabHBox.PackEnd(_TabLabel, false, false, 0);
            _TabHBox.PackStart(TabImage, false, false, 2);
            _TabHBox.ShowAll();

            _TabEventBox = new Gtk.EventBox();
            _TabEventBox.VisibleWindow = false;
            _TabEventBox.ButtonPressEvent += new Gtk.ButtonPressEventHandler(OnTabButtonPress);
            _TabEventBox.Add(_TabHBox);
            _TabEventBox.ShowAll();

            _ThemeSettings = new ThemeSettings();

            // OPT-TODO: this should use a TaskStack instead of TaskQueue
            _LastSeenHighlightQueue = new TaskQueue("LastSeenHighlightQueue("+ID+")");
            _LastSeenHighlightQueue.AbortedEvent += OnLastSeenHighlightQueueAbortedEvent;
            _LastSeenHighlightQueue.ExceptionEvent += OnLastSeenHighlightQueueExceptionEvent;
        }
Exemplo n.º 53
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;
		}
Exemplo n.º 54
0
		public void PopulateFixes (Gtk.Menu menu, ref int items)
		{
			int mnemonic = 1;
			foreach (var fix_ in fixes.OrderByDescending (i => GetUsage (i.IdString))) {
				var fix = fix_;
				var escapedLabel = fix.Title.Replace ("_", "__");
				var label = (mnemonic <= 10)
					? "_" + (mnemonic++ % 10).ToString () + " " + escapedLabel
						: "  " + escapedLabel;
				var thisInstanceMenuItem = new Gtk.MenuItem (label);
				thisInstanceMenuItem.Activated += new ContextActionRunner (fix, document, loc).Run;
				thisInstanceMenuItem.Activated += delegate {
					ConfirmUsage (fix.IdString);
					menu.Destroy ();
				};
				menu.Add (thisInstanceMenuItem);
				items++;
			}
			var first = true;
			var alreadyInserted = new HashSet<BaseCodeIssueProvider> ();
			foreach (var analysisFix_ in fixes.OfType <AnalysisContextActionProvider.AnalysisCodeAction>().Where (f => f.Result is InspectorResults)) {
				var analysisFix = analysisFix_;
				var ir = analysisFix.Result as InspectorResults;
				if (ir == null)
					continue;
			
				if (first) {
					menu.Add (new Gtk.SeparatorMenuItem ());
					first = false;
				}
				if (alreadyInserted.Contains (ir.Inspector))
					continue;
				alreadyInserted.Add (ir.Inspector);

				var subMenu = new Gtk.Menu ();
				if (analysisFix.SupportsBatchRunning) {
					var batchRunMenuItem = new Gtk.MenuItem (GettextCatalog.GetString ("Fix all in this file"));
					batchRunMenuItem.Activated += delegate {
						ConfirmUsage (analysisFix.IdString);
						menu.Destroy ();
					};
					batchRunMenuItem.Activated += new ContextActionRunner (analysisFix, document, loc).BatchRun;
					subMenu.Add (batchRunMenuItem);
					subMenu.Add (new Gtk.SeparatorMenuItem ());
				}

				var inspector = ir.Inspector;
				if (inspector.CanSuppressWithAttribute) {
					var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("_Suppress with attribute"));
					menuItem.Activated += delegate {
						inspector.SuppressWithAttribute (document, analysisFix.DocumentRegion); 
					};
					subMenu.Add (menuItem);
				}

				if (inspector.CanDisableWithPragma) {
					var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("_Suppress with #pragma"));
					menuItem.Activated += delegate {
						inspector.DisableWithPragma (document, analysisFix.DocumentRegion); 
					};
					subMenu.Add (menuItem);
				}

				if (inspector.CanDisableOnce) {
					var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("_Disable once with comment"));
					menuItem.Activated += delegate {
						inspector.DisableOnce (document, analysisFix.DocumentRegion); 
					};
					subMenu.Add (menuItem);
				}

				if (inspector.CanDisableAndRestore) {
					var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("Disable _and restore with comments"));
					menuItem.Activated += delegate {
						inspector.DisableAndRestore (document, analysisFix.DocumentRegion); 
					};
					subMenu.Add (menuItem);
				}
				var label = GettextCatalog.GetString ("_Options for \"{0}\"", InspectorResults.GetTitle (ir.Inspector));
				var subMenuItem = new Gtk.MenuItem (label);

				var optionsMenuItem = new Gtk.MenuItem (GettextCatalog.GetString ("_Configure inspection severity"));
				optionsMenuItem.Activated += analysisFix.ShowOptions;
				optionsMenuItem.Activated += delegate {
					menu.Destroy ();
				};
				subMenu.Add (optionsMenuItem);
				subMenuItem.Submenu = subMenu;
				menu.Add (subMenuItem);
				items++;
			}

			foreach (var fix_ in fixes.Where (f => f.BoundToIssue != null)) {
				var fix = fix_;
				foreach (var inspector_ in RefactoringService.GetInspectors (document.Editor.MimeType).Where (i => i.GetSeverity () != Severity.None)) {
					var inspector = inspector_;

					if (inspector.IdString.IndexOf (fix.BoundToIssue.FullName, StringComparison.Ordinal) < 0)
						continue;
					if (first) {
						menu.Add (new Gtk.SeparatorMenuItem ());
						first = false;
					}
					if (alreadyInserted.Contains (inspector))
						continue;
					alreadyInserted.Add (inspector);
					
					var label = GettextCatalog.GetString ("_Options for \"{0}\"", InspectorResults.GetTitle (inspector));
					var subMenuItem = new Gtk.MenuItem (label);
					Gtk.Menu subMenu = new Gtk.Menu ();
					if (inspector.CanSuppressWithAttribute) {
						var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("_Suppress with attribute"));
						menuItem.Activated += delegate {
							inspector.SuppressWithAttribute (document, fix.DocumentRegion); 
						};
						subMenu.Add (menuItem);
					}

					if (inspector.CanDisableWithPragma) {
						var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("_Suppress with #pragma"));
						menuItem.Activated += delegate {
							inspector.DisableWithPragma (document, fix.DocumentRegion); 
						};
						subMenu.Add (menuItem);
					}

					if (inspector.CanDisableOnce) {
						var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("_Disable once with comment"));
						menuItem.Activated += delegate {
							inspector.DisableOnce (document, fix.DocumentRegion); 
						};
						subMenu.Add (menuItem);
					}

					if (inspector.CanDisableAndRestore) {
						var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("Disable _and restore with comments"));
						menuItem.Activated += delegate {
							inspector.DisableAndRestore (document, fix.DocumentRegion); 
						};
						subMenu.Add (menuItem);
					}

					var confItem = new Gtk.MenuItem (GettextCatalog.GetString ("_Configure inspection severity"));
					confItem.Activated += delegate {
						MessageService.RunCustomDialog (new CodeIssueOptionsDialog (inspector), MessageService.RootWindow);
						menu.Destroy ();
					};
					subMenu.Add (confItem);

					subMenuItem.Submenu = subMenu;
					subMenu.ShowAll (); 
					menu.Add (subMenuItem);
					break;
				}

				items++;
			}
		}
Exemplo n.º 55
0
 private void BuildPopup()
 {
     popup = new Gtk.Menu();
     popup.Append( this.actAdd.CreateMenuItem() );
     popup.Append( this.actRemove.CreateMenuItem() );
     popup.Append( this.actModify.CreateMenuItem() );
     popup.Append( this.actSettings.CreateMenuItem() );
     popup.ShowAll();
 }
Exemplo n.º 56
0
		public override void OnNoteOpened ()
		{
			if (menu == null) {
				menu = new Gtk.Menu ();
				menu.ShowAll ();
			}
			
			if (toolButton == null) {
				InitializeToolButton ();
				UpdateButtonSensitivity (Note.ContainsTag (TemplateTag));
			}
		}
Exemplo n.º 57
0
		void PopupQuickFixMenu (Gdk.EventButton evt)
		{
			var menu = new Gtk.Menu ();

			var caretOffset = document.Editor.Caret.Offset;
			Gtk.Menu fixMenu = menu;
			DomRegion region;
			var resolveResult = document.GetLanguageItem (caretOffset, out region);
			if (resolveResult != null) {
				var possibleNamespaces = MonoDevelop.Refactoring.ResolveCommandHandler.GetPossibleNamespaces (document, resolveResult);
	
				bool addUsing = !(resolveResult is AmbiguousTypeResolveResult);
				if (addUsing) {
					foreach (string ns_ in possibleNamespaces) {
						string ns = ns_;
						var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("Import Namespace {0}", ns));
						menuItem.Activated += delegate {
							new MonoDevelop.Refactoring.ResolveCommandHandler.AddImport (document, resolveResult, ns, true).Run ();
						};
						menu.Add (menuItem);
					}
				}
				
				bool resolveDirect = !(resolveResult is UnknownMemberResolveResult);
				if (resolveDirect) {
					foreach (string ns in possibleNamespaces) {
						var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("Use {0}", ns + "." + document.Editor.GetTextBetween (region.Begin, region.End)));
						menuItem.Activated += delegate {
							new MonoDevelop.Refactoring.ResolveCommandHandler.AddImport (document, resolveResult, ns, false).Run ();
						};
						menu.Add (menuItem);
					}
				}
				if (menu.Children.Any () && fixes.Any ()) {
					fixMenu = new Gtk.Menu ();
					var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("Quick Fixes"));
					menuItem.Submenu = fixMenu;
					menu.Add (menuItem);
				}
			}
			
			PopulateFixes (fixMenu);
			
			menu.ShowAll ();
			menu.SelectFirst (true);
			menuPushed = true;
			menu.Destroyed += delegate {
				menuPushed = false;
			};
			var container = (TextEditorContainer)document.Editor.Parent.Parent;
			var child = (TextEditorContainer.EditorContainerChild)container [this];
			GtkWorkarounds.ShowContextMenu (menu, document.Editor.Parent, null, new Gdk.Rectangle (child.X, child.Y + Allocation.Height - (int)document.Editor.VAdjustment.Value, 0, 0));
		}
Exemplo n.º 58
0
        private void PopulateAlbumOptionMenu(Gallery gallery)
        {
            System.Collections.ArrayList albums = null;
            if (gallery != null) {
                //gallery.FetchAlbumsPrune ();
                try {
                    gallery.FetchAlbums ();
                    albums = gallery.Albums;
                } catch (GalleryCommandException e) {
                    gallery.PopupException (e, export_dialog);
                    return;
                }
            }

            Gtk.Menu menu = new Gtk.Menu ();

            bool disconnected = gallery == null || !account.Connected || albums == null;

            if (disconnected || albums.Count == 0) {
                string msg = disconnected ? Catalog.GetString ("(Not Connected)")
                    : Catalog.GetString ("(No Albums)");

                Gtk.MenuItem item = new Gtk.MenuItem (msg);
                menu.Append (item);

                export_button.Sensitive = false;
                album_optionmenu.Sensitive = false;
                album_button.Sensitive = false;

                if (disconnected)
                    album_button.Sensitive = false;
            } else {
                foreach (Album album in albums) {
                    System.Text.StringBuilder label_builder = new System.Text.StringBuilder ();

                    for (int i=0; i < album.Parents.Count; i++) {
                        label_builder.Append ("  ");
                    }
                    label_builder.Append (album.Title);

                    Gtk.MenuItem item = new Gtk.MenuItem (label_builder.ToString ());
                    ((Gtk.Label)item.Child).UseUnderline = false;
                    menu.Append (item);

                        AlbumPermission add_permission = album.Perms & AlbumPermission.Add;

                    if (add_permission == 0)
                        item.Sensitive = false;
                }

                export_button.Sensitive = items.Length > 0;
                album_optionmenu.Sensitive = true;
                album_button.Sensitive = true;
            }

            menu.ShowAll ();
            album_optionmenu.Menu = menu;
        }
Exemplo n.º 59
0
		internal void ShowDockPopupMenu (uint time)
		{
			Gtk.Menu menu = new Gtk.Menu ();
			
			// Hide menuitem
			if ((Behavior & DockItemBehavior.CantClose) == 0) {
				Gtk.MenuItem mitem = new Gtk.MenuItem (Catalog.GetString("Hide"));
				mitem.Activated += delegate { Visible = false; };
				menu.Append (mitem);
			}

			Gtk.MenuItem citem;

			// Auto Hide menuitem
			if ((Behavior & DockItemBehavior.CantAutoHide) == 0 && Status != DockItemStatus.AutoHide) {
				citem = new Gtk.MenuItem (Catalog.GetString("Minimize"));
				citem.Activated += delegate { Status = DockItemStatus.AutoHide; };
				menu.Append (citem);
			}

			if (Status != DockItemStatus.Dockable) {
				// Dockable menuitem
				citem = new Gtk.MenuItem (Catalog.GetString("Dock"));
				citem.Activated += delegate { Status = DockItemStatus.Dockable; };
				menu.Append (citem);
			}

			// Floating menuitem
			if ((Behavior & DockItemBehavior.NeverFloating) == 0 && Status != DockItemStatus.Floating) {
				citem = new Gtk.MenuItem (Catalog.GetString("Undock"));
				citem.Activated += delegate { Status = DockItemStatus.Floating; };
				menu.Append (citem);
			}

			if (menu.Children.Length == 0) {
				menu.Destroy ();
				return;
			}

			ShowingContextMemu = true;

			menu.ShowAll ();
			menu.Hidden += (o,e) => {
				ShowingContextMemu = false;
			};
			menu.Popup (null, null, null, 3, time);
		}
Exemplo n.º 60
0
        private void PopulateGalleryOptionMenu(GalleryAccountManager manager, GalleryAccount changed_account)
        {
            Gtk.Menu menu = new Gtk.Menu ();
            this.account = changed_account;
            int pos = -1;

            accounts = manager.GetAccounts ();
            if (accounts == null || accounts.Count == 0) {
                Gtk.MenuItem item = new Gtk.MenuItem (Catalog.GetString ("(No Gallery)"));
                menu.Append (item);
                gallery_optionmenu.Sensitive = false;
                edit_button.Sensitive = false;
            } else {
                int i = 0;
                foreach (GalleryAccount account in accounts) {
                    if (account == changed_account)
                        pos = i;

                    Gtk.MenuItem item = new Gtk.MenuItem (account.Name);
                    menu.Append (item);
                    i++;
                }
                gallery_optionmenu.Sensitive = true;
                edit_button.Sensitive = true;
            }

            menu.ShowAll ();
            gallery_optionmenu.Menu = menu;
            gallery_optionmenu.SetHistory ((uint)pos);
        }