Inheritance: Gtk.VBox
コード例 #1
0
 private void sidebar_ItemAdded(MainSidebar sidebar, ISidebarItem newItem)
 {
     if (newItem.PageWidget != null)
     {
         /* int pageNum = */ pageNotebook.AppendPage(newItem.PageWidget, null);
         newItem.PageWidget.Show();
     }
 }
コード例 #2
0
 private void sidebar_SelectedItemChanged(MainSidebar sidebar, ISidebarItem selectedItem)
 {
     if (selectedItem != null && selectedItem.PageWidget != null)
     {
         int pageNum = pageNotebook.PageNum(selectedItem.PageWidget);
         pageNotebook.CurrentPage = pageNum;
         pageNotebook.CurrentPageWidget.GrabFocus();
     }
 }
コード例 #3
0
ファイル: MainWindow.cs プロジェクト: codebutler/meshwork
        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 = String.Format ("{0} (BETA) {1} (Protocol Version: {2})",
                                      attr.Title, asmName.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 (Common.OSName == "Darwin") {
                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
            Core.ShareBuilder.StartedIndexing  += (EventHandler)DispatchService.GuiDispatch(new EventHandler(sb_StartedIndexing));
            Core.ShareBuilder.FinishedIndexing += (EventHandler)DispatchService.GuiDispatch(new EventHandler(sb_FinishedIndexing));
            Core.ShareBuilder.StoppedIndexing  += (EventHandler)DispatchService.GuiDispatch(new EventHandler(sb_StoppedIndexing));
            Core.ShareBuilder.ErrorIndexing    += (ErrorEventHandler)DispatchService.GuiDispatch(new ErrorEventHandler(sb_ErrorIndexing));
            Core.ShareHasher.StartedHashingFile += (ShareHasherTaskEventHandler)DispatchService.GuiDispatch(new ShareHasherTaskEventHandler(sh_StartedFinished));
            Core.ShareHasher.FinishedHashingFile += (ShareHasherTaskEventHandler)DispatchService.GuiDispatch(new ShareHasherTaskEventHandler(sh_StartedFinished));
            Core.ShareHasher.QueueChanged += (EventHandler)DispatchService.GuiDispatch(new EventHandler(sh_QueueChanged));

            Core.FileSearchManager.SearchAdded   += (FileSearchEventHandler)DispatchService.GuiDispatch(new FileSearchEventHandler(FileSearchManager_SearchAdded));
            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;
        }
コード例 #4
0
ファイル: MainWindow.cs プロジェクト: codebutler/meshwork
 private void sidebar_SelectedItemChanged(MainSidebar sidebar, ISidebarItem selectedItem)
 {
     if (selectedItem != null && selectedItem.PageWidget != null) {
         int pageNum = pageNotebook.PageNum(selectedItem.PageWidget);
         pageNotebook.CurrentPage = pageNum;
         pageNotebook.CurrentPageWidget.GrabFocus();
     }
 }
コード例 #5
0
ファイル: MainWindow.cs プロジェクト: codebutler/meshwork
 private void sidebar_ItemAdded(MainSidebar sidebar, ISidebarItem newItem)
 {
     if (newItem.PageWidget != null) {
         /* int pageNum = */ pageNotebook.AppendPage(newItem.PageWidget, null);
         newItem.PageWidget.Show();
     }
 }
コード例 #6
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 = String.Format("{0} (BETA) {1} (Protocol Version: {2})",
                                         attr.Title, asmName.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 (Common.OSName == "Darwin")
            {
                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
            Core.ShareBuilder.StartedIndexing    += (EventHandler)DispatchService.GuiDispatch(new EventHandler(sb_StartedIndexing));
            Core.ShareBuilder.FinishedIndexing   += (EventHandler)DispatchService.GuiDispatch(new EventHandler(sb_FinishedIndexing));
            Core.ShareBuilder.StoppedIndexing    += (EventHandler)DispatchService.GuiDispatch(new EventHandler(sb_StoppedIndexing));
            Core.ShareBuilder.ErrorIndexing      += (EventHandler <ErrorEventArgs>)DispatchService.GuiDispatch(new EventHandler <ErrorEventArgs>(sb_ErrorIndexing));
            Core.ShareHasher.StartedHashingFile  += (EventHandler <FilenameEventArgs>)DispatchService.GuiDispatch(new EventHandler <FilenameEventArgs>(sh_StartedFinished));
            Core.ShareHasher.FinishedHashingFile += (EventHandler <FilenameEventArgs>)DispatchService.GuiDispatch(new EventHandler <FilenameEventArgs>(sh_StartedFinished));
            Core.ShareHasher.QueueChanged        += (EventHandler)DispatchService.GuiDispatch(new EventHandler(sh_QueueChanged));

            Core.FileSearchManager.SearchAdded   += (EventHandler <FileSearchEventArgs>)DispatchService.GuiDispatch(new EventHandler <FileSearchEventArgs>(FileSearchManager_SearchAdded));
            Core.FileSearchManager.SearchRemoved += (EventHandler <FileSearchEventArgs>)DispatchService.GuiDispatch(new EventHandler <FileSearchEventArgs>(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;
        }