Exemplo n.º 1
0
        /// <summary>Populate the main menu tool strip.</summary>
        /// <param name="menuDescriptions">Descriptions for each item.</param>
        public void Populate(List <MenuDescriptionArgs> menuDescriptions)
        {
            accelerators = new AccelGroup();
            foreach (Widget child in toolStrip.Children)
            {
                toolStrip.Remove(child);
                child.Dispose();
            }
            foreach (MenuDescriptionArgs description in menuDescriptions)
            {
                Gtk.Image            image  = null;
                Gdk.Pixbuf           pixbuf = null;
                ManifestResourceInfo info   = Assembly.GetExecutingAssembly().GetManifestResourceInfo(description.ResourceNameForImage);

                if (info != null)
                {
                    pixbuf = new Gdk.Pixbuf(null, description.ResourceNameForImage, 20, 20);
                    image  = new Gtk.Image(pixbuf);
                }
                ToolItem item = new ToolItem();
                item.Expand = true;

                if (description.OnClick == null)
                {
                    Label toolbarlabel = new Label();
                    if (description.RightAligned)
                    {
                        toolbarlabel.Xalign = 1.0F;
                    }
                    toolbarlabel.Xpad        = 10;
                    toolbarlabel.Text        = description.Name;
                    toolbarlabel.TooltipText = description.ToolTip;
                    toolbarlabel.Visible     = !String.IsNullOrEmpty(toolbarlabel.Text);
                    item.Add(toolbarlabel);
                    toolStrip.Add(item);
                    toolStrip.ShowAll();
                }
                else
                {
                    ToolButton button = new ToolButton(image, description.Name);
                    button.Homogeneous = false;
                    button.LabelWidget = new Label(description.Name);
                    button.Clicked    += description.OnClick;
                    if (!string.IsNullOrWhiteSpace(description.ShortcutKey))
                    {
                        Gtk.Accelerator.Parse(description.ShortcutKey, out uint key, out Gdk.ModifierType modifier);
                        button.AddAccelerator("clicked", accelerators, key, modifier, AccelFlags.Visible);
                    }
                    item = button;
                }
                toolStrip.Add(item);
            }
            Window mainWindow = GetMainWindow();

            if (mainWindow != null)
            {
                mainWindow.AddAccelGroup(accelerators);
            }
            toolStrip.ShowAll();
        }
Exemplo n.º 2
0
        public App(Settings set, DebugManager mgr, string argsOverride)
        {
            settings  = set;
            debugPane = new DebugPane(set, mgr);

            AccelGroup agr = new AccelGroup();

            menu = new AppMenu(mgr, agr, set, mainWin, debugPane,
                               argsOverride);
            toolbar = new AppToolbar(mgr, debugPane);

            VBox vb = new VBox(false, 3);

            mainWin.Resize(settings.WindowWidth, settings.WindowHeight);
            mainWin.DeleteEvent += (obj, evt) => Application.Quit();
            mainWin.AddAccelGroup(agr);

            vb.PackStart(menu.View, false, false, 0);
            vb.PackStart(toolbar.View, false, false, 0);
            vb.PackEnd(debugPane.View, true, true, 0);
            mainWin.Add(vb);

            mainWin.DeleteEvent += OnDeleteEvent;
            mainWin.ShowAll();
        }
Exemplo n.º 3
0
        private void ShowWindow()
        {
            Application.Init();

            Glade.XML gxml = new Glade.XML(null, "ImLogViewer.glade", "imviewer", null);
            gxml.Autoconnect(this);

            imviewer.Icon = IconTheme.Default.LoadIcon("system-search", 16, IconLookupFlags.NoSvg);

            conversation.PixelsAboveLines = 3;
            conversation.LeftMargin       = 4;
            conversation.RightMargin      = 4;

            TextTag boldtag = new TextTag("bold");

            boldtag.Weight = Pango.Weight.Bold;
            conversation.Buffer.TagTable.Add(boldtag);

            TextTag highlight = new TextTag("highlight");

            highlight.Background = "yellow";
            conversation.Buffer.TagTable.Add(highlight);

            tree_store = new TreeStore(new Type[] { typeof(string), typeof(string), typeof(object) });

            timelinetree.Model = tree_store;
            timelinetree.AppendColumn("Date", new CellRendererText(), "markup", 0);
            timelinetree.AppendColumn("Snippet", new CellRendererText(), "text", 1);
            timelinetree.Selection.Changed += OnConversationSelected;

            if (highlight_text != null)
            {
                search_entry.Text = highlight_text;
            }

            if (search_text != null)
            {
                Search(search_text);
            }

            search_entry.Activated += OnSearchClicked;
            search_button.Clicked  += OnSearchClicked;
            clear_button.Clicked   += OnClearClicked;
            imviewer.DeleteEvent   += new DeleteEventHandler(OnWindowDelete);

            AccelGroup      accel_group = new AccelGroup();
            GlobalKeybinder global_keys = new GlobalKeybinder(accel_group);

            global_keys.AddAccelerator(OnWindowClose, (uint)Gdk.Key.Escape, 0, Gtk.AccelFlags.Visible);
            imviewer.AddAccelGroup(accel_group);

            // Index the logs
            index_thread_notify = new ThreadNotify(new ReadyEvent(RepopulateTimeline));
            Thread t = new Thread(new ThreadStart(IndexLogs));

            t.Start();

            Application.Run();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Constructs the menu and related components.
        /// </summary>
        private Widget CreateMenu()
        {
            // Start by loading the UI from a resource
            UIManager ui = new UIManager();

            ui.AddUiFromResource("Wordplay.menu.xml");

            // Set up the actions
            ActionEntry[] entries = new[]
            {
                // "File" Menu
                new ActionEntry(
                    "GameMenu",
                    null,
                    Translate("Menu/Game"),
                    null,
                    null,
                    null),
                new ActionEntry(
                    "NewGame",
                    Stock.New,
                    Translate("Menu/NewGame"),
                    "<control>N",
                    "New",
                    OnNewGameAction),
                new ActionEntry(
                    "ShuffleBoard",
                    null,
                    Translate("Menu/ShuffleBoard"),
                    "<control>S",
                    "Shuffle",
                    OnShuffleBoardAction),
                new ActionEntry(
                    "Preferences",
                    null,
                    Translate("Menu/Preferences"),
                    "<control>P",
                    "Preferences",
                    OnPreferencesAction),
                new ActionEntry(
                    "HighScores",
                    null,
                    Translate("Menu/HighScores"),
                    "<control>H",
                    "HighScores",
                    OnHighScoresAction),
                new ActionEntry(
                    "Quit",
                    Stock.Quit,
                    Translate("Menu/Quit"),
                    "<control>Q",
                    "Quit",
                    OnQuitAction),
            };

            // Install the actions
            ActionGroup actions = new ActionGroup("group");

            actions.Add(entries);
            ui.InsertActionGroup(actions, 0);
            window.AddAccelGroup(ui.AccelGroup);

            // Construct the results
            return(ui.GetWidget("/MenuBar"));
        }
Exemplo n.º 5
0
        public MainWindow()
        {
            ToolItem        spacerItem;
            FileSearchEntry searchEntry;
            ToolItem        searchEntryItem;
            Alignment       searchEntryBox;

            object[] attrs = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), true);
            AssemblyTitleAttribute attr    = (AssemblyTitleAttribute)attrs[0];
            AssemblyName           asmName = Assembly.GetExecutingAssembly().GetName();

            string title = $"{attr.Title} (BETA) {asmName.Version} (Protocol Version: {Core.ProtocolVersion})";

            // Create the interface
            window = new Window(title);
            window.SetDefaultSize(850, 550);
            window.DeleteEvent    += on_win_delete;
            window.ConfigureEvent += on_MainWindow_configure_event;
            window.FocusInEvent   += window_FocusInEvent;

            ((ToggleAction)Runtime.BuiltinActions["ToggleMainToolbar"]).Active = Gui.Settings.ShowToolbar;
            Runtime.BuiltinActions["ToggleMainToolbar"].Activated += ToggleMainToolbar_Activated;

            ((ToggleAction)Runtime.BuiltinActions["ToggleMainStatusbar"]).Active = Gui.Settings.ShowStatusBar;
            Runtime.BuiltinActions["ToggleMainStatusbar"].Activated += ToggleMainStatusbar_Activated;
            window.AddAccelGroup(Runtime.UIManager.AccelGroup);

            mainVBox = new VBox();
            window.Add(mainVBox);
            mainVBox.Show();

            if (Runtime.Core.Platform.OSName == "macOS")
            {
                MenuBar menubar = (MenuBar)Runtime.UIManager.GetWidget("/OSXAppMenu");

                Imendio.MacIntegration.Menu.SetMenuBar(menubar);

                MenuItem preferencesItem = (MenuItem)Runtime.UIManager.GetWidget("/OSXAppMenu/NetworkMenu/Preferences");
                MenuItem aboutItem       = (MenuItem)Runtime.UIManager.GetWidget("/OSXAppMenu/NetworkMenu/About");

                IntPtr group = Imendio.MacIntegration.Menu.AddAppMenuGroup();

                Imendio.MacIntegration.Menu.AddAppMenuItem(group, aboutItem, "About Meshwork");

                group = Imendio.MacIntegration.Menu.AddAppMenuGroup();

                Imendio.MacIntegration.Menu.AddAppMenuItem(group, preferencesItem, "Preferences");

                MenuItem quitItem = (MenuItem)Runtime.UIManager.GetWidget("/OSXAppMenu/NetworkMenu/Quit");
                Imendio.MacIntegration.Menu.SetQuitMenuItem(quitItem);
            }
            else
            {
                MenuBar menubar = (MenuBar)Runtime.UIManager.GetWidget("/MainWindowMenuBar");
                mainVBox.PackStart(menubar, false, false, 0);
                menubar.Show();
            }

            toolbar = (Toolbar)Runtime.UIManager.GetWidget("/MainWindowToolbar");
            toolbar.ToolbarStyle = ToolbarStyle.BothHoriz;
            toolbar.IconSize     = IconSize.LargeToolbar;

            spacerItem        = new ToolItem();
            spacerItem.Expand = true;
            toolbar.Insert(spacerItem, -1);
            spacerItem.Show();

            searchEntry = new FileSearchEntry();

            searchEntryBox              = new Alignment(0.5f, 0.5f, 0, 0);
            searchEntryBox.LeftPadding  = 4;
            searchEntryBox.RightPadding = 1;
            searchEntryBox.Add(searchEntry);

            searchEntryItem = new ToolItem();
            searchEntryItem.Add(searchEntryBox);

            toolbar.Insert(searchEntryItem, -1);
            searchEntryItem.ShowAll();

            mainVBox.PackStart(toolbar, false, false, 0);

            mainPaned         = new HPaned();
            mainPaned.Mapped += delegate(object sender, EventArgs args) {
                // XXX: Remember the user's last setting instead
                mainPaned.Position = 190;

                // Set some colors
                //infoBoxSeparator.ModifyBg(StateType.Normal, GtkHelper.DarkenColor (mainbar.Style.Background(StateType.Normal), 2));
                //infoSwitcherTree.ModifyBase(StateType.Normal, infoSwitcherTree.Style.Base(StateType.Active));
                //infoSwitcherTree.ModifyBase(StateType.Active, infoBoxSeparator.Style.Base(StateType.Selected));
            };
            mainPaned.Show();
            mainVBox.PackStart(mainPaned, true, true, 0);

            // Create page notebook
            pageNotebook            = new Notebook();
            pageNotebook.ShowTabs   = false;
            pageNotebook.ShowBorder = false;
            mainPaned.Pack2(pageNotebook, true, true);
            pageNotebook.ShowAll();

            // Create sidebar
            sidebar                      = new MainSidebar();
            sidebar.ItemAdded           += sidebar_ItemAdded;
            sidebar.SelectedItemChanged += sidebar_SelectedItemChanged;
            sidebar.AddBuiltinItems();

            mainPaned.Pack1(sidebar, false, false);
            sidebar.ShowAll();

            CreateStatusbar();

            // Apply "view" settings
            toolbar.Visible   = Gui.Settings.ShowToolbar;
            statusBar.Visible = Gui.Settings.ShowStatusBar;

            // Hook up Core events
            Runtime.Core.ShareBuilder.StartedIndexing    += (EventHandler)DispatchService.GuiDispatch(new EventHandler(sb_StartedIndexing));
            Runtime.Core.ShareBuilder.FinishedIndexing   += (EventHandler)DispatchService.GuiDispatch(new EventHandler(sb_FinishedIndexing));
            Runtime.Core.ShareBuilder.StoppedIndexing    += (EventHandler)DispatchService.GuiDispatch(new EventHandler(sb_StoppedIndexing));
            Runtime.Core.ShareBuilder.ErrorIndexing      += (ErrorEventHandler)DispatchService.GuiDispatch(new ErrorEventHandler(sb_ErrorIndexing));
            Runtime.Core.ShareHasher.StartedHashingFile  += (ShareHasherTaskEventHandler)DispatchService.GuiDispatch(new ShareHasherTaskEventHandler(sh_StartedFinished));
            Runtime.Core.ShareHasher.FinishedHashingFile += (ShareHasherTaskEventHandler)DispatchService.GuiDispatch(new ShareHasherTaskEventHandler(sh_StartedFinished));
            Runtime.Core.ShareHasher.QueueChanged        += (EventHandler)DispatchService.GuiDispatch(new EventHandler(sh_QueueChanged));

            Runtime.Core.FileSearchManager.SearchAdded   += (FileSearchEventHandler)DispatchService.GuiDispatch(new FileSearchEventHandler(FileSearchManager_SearchAdded));
            Runtime.Core.FileSearchManager.SearchRemoved += (FileSearchEventHandler)DispatchService.GuiDispatch(new FileSearchEventHandler(FileSearchManager_SearchRemoved));

            window.Resize(Gui.Settings.WindowSize.Width, Gui.Settings.WindowSize.Height);
            window.Move(Gui.Settings.WindowPosition.X, Gui.Settings.WindowPosition.Y);

            SelectedPage = NetworkOverviewPage.Instance;
        }
Exemplo n.º 6
0
        public static Gtk.Window Create()
        {
            window = new Window("Menus");

            AccelGroup accel_group = new AccelGroup();

            window.AddAccelGroup(accel_group);

            VBox box1 = new VBox(false, 0);

            window.Add(box1);

            MenuBar menubar = new MenuBar();

            box1.PackStart(menubar, false, false, 0);

            Menu     menu     = Create_Menu(2, true);
            MenuItem menuitem = new MenuItem("foo");

            menuitem.Submenu = menu;
            menubar.Append(menuitem);

            menuitem         = new MenuItem("bar");
            menuitem.Submenu = Create_Menu(3, true);
            menubar.Append(menuitem);

            Image image = new Image(Stock.Help, IconSize.Menu);

            menuitem = new ImageMenuItem("Help");
            ((ImageMenuItem)menuitem).Image = image;
            menuitem.Submenu        = Create_Menu(4, true);
            menuitem.RightJustified = true;
            menubar.Append(menuitem);

            menubar = new MenuBar();
            box1.PackStart(menubar, false, true, 0);

            menu = Create_Menu(2, true);

            menuitem         = new MenuItem("Second menu bar");
            menuitem.Submenu = menu;
            menubar.Append(menuitem);

            VBox box2 = new VBox(false, 10);

            box2.BorderWidth = 10;
            box1.PackStart(box2, true, true, 0);

            menu            = Create_Menu(1, false);
            menu.AccelGroup = accel_group;

            menu.Append(new SeparatorMenuItem());

            menuitem = new CheckMenuItem("Accelerate Me");
            menu.Append(menuitem);
            menuitem.AddAccelerator("activate", accel_group, 0xFFBE, 0, AccelFlags.Visible);

            menuitem = new CheckMenuItem("Accelerator locked");
            menu.Append(menuitem);
            menuitem.AddAccelerator("activate", accel_group, 0xFFBF, 0, AccelFlags.Visible | AccelFlags.Locked);

            menuitem = new CheckMenuItem("Accelerator Frozen");
            menu.Append(menuitem);
            menuitem.AddAccelerator("activate", accel_group, 0xFFBF, 0, AccelFlags.Visible);
            menuitem.AddAccelerator("activate", accel_group, 0xFFC0, 0, AccelFlags.Visible);

            OptionMenu option_menu = new OptionMenu();

            option_menu.Menu = menu;
            option_menu.SetHistory(3);
            box2.PackStart(option_menu, true, true, 0);

            box1.PackStart(new HSeparator(), false, false, 0);

            box2             = new VBox(false, 10);
            box2.BorderWidth = 10;
            box1.PackStart(box2, false, true, 0);

            Button close_button = new Button(Stock.Close);

            close_button.Clicked += new EventHandler(Close_Button);
            box2.PackStart(close_button, true, true, 0);

            close_button.CanDefault = true;
            close_button.GrabDefault();

            window.ShowAll();
            return(window);
        }