AddScrolledWindow() public static method

public static AddScrolledWindow ( Gtk.Widget widget ) : Gtk.ScrolledWindow
widget Gtk.Widget
return Gtk.ScrolledWindow
Ejemplo n.º 1
0
        public UserBrowserPage()
        {
            // Create the files tree
            filesList = new TreeView();
            filesList.RowActivated     += on_filesList_row_activated;
            filesList.ButtonPressEvent += filesList_ButtonPressEvent;

            // Create the navigation bar
            Alignment navigationBarAlignment = new Alignment(0, 0, 1, 1);

            navigationBarAlignment.TopPadding    = 3;
            navigationBarAlignment.BottomPadding = 3;
            navigationBar = new NavigationBar();
            navigationBar.PathButtonClicked += on_navigationBar_PathButtonClicked;
            navigationBarAlignment.Add(navigationBar);
            base.PackStart(navigationBarAlignment, false, false, 0);
            navigationBarAlignment.ShowAll();

            // Load some images
            stockDirectoryPixbuf = Gui.LoadIcon(16, "folder");
            stockFilePixbuf      = Gui.LoadIcon(16, "text-x-generic");
            networkIcon          = Gui.LoadIcon(16, "stock_internet");

            // Set up the file list
            filesList.Selection.Changed += filesList_Selection_Changed;
            filesList.Selection.Mode     = SelectionMode.Browse;

            /*
             * filesList.Selection.Mode = SelectionMode.Multiple;
             * filesList.RubberBanding = true;
             */

            filesListStore  = new ListStore(typeof(IDirectoryItem));
            filesList.Model = filesListStore;

            TreeViewColumn column;

            // Add Name column
            column           = new TreeViewColumn();
            column.Title     = "Name";
            column.Resizable = true;

            Gtk.CellRendererPixbuf fileListRowIcon = new Gtk.CellRendererPixbuf();
            column.PackStart(fileListRowIcon, false);
            column.SetCellDataFunc(fileListRowIcon, new TreeCellDataFunc(FileNameIconFunc));

            Gtk.CellRendererText fileListRowText = new Gtk.CellRendererText();
            column.PackStart(fileListRowText, true);
            column.SetCellDataFunc(fileListRowText, new TreeCellDataFunc(FileNameTextFunc));

            filesList.AppendColumn(column);

            // Add Size Column
            column           = filesList.AppendColumn("Size", new CellRendererText(), new TreeCellDataFunc(FileSizeFunc));
            column.Resizable = true;

            // Add Type Column
            column           = filesList.AppendColumn("Type", new CellRendererText(), new TreeCellDataFunc(FileTypeFunc));
            column.Resizable = true;

            // Add InfoHash Column
            column           = filesList.AppendColumn("Info Hash", new CellRendererText(), new TreeCellDataFunc(FileInfoHashFunc));
            column.Resizable = true;

            base.PackStart(Gui.AddScrolledWindow(filesList), true, true, 0);
            filesList.ShowAll();

            waitingBoxAlignment = new Alignment(0.5f, 0.5f, 0, 0);
            VBox waitingBox = new VBox();

            waitProgressBar = new ProgressBar();
            waitLabel       = new Label();
            waitingBox.PackStart(waitProgressBar, false, false, 0);
            waitingBox.PackStart(waitLabel, false, false, 0);
            waitingBoxAlignment.Add(waitingBox);
            this.PackStart(waitingBoxAlignment, true, true, 0);

            Core.NetworkAdded += Core_NetworkAdded;
            foreach (Network network in Core.Networks)
            {
                Core_NetworkAdded(network);
            }

            resultPopupMenu = new Menu();

            ImageMenuItem item = new ImageMenuItem("Download");

            item.Image      = new Image(Gui.LoadIcon(16, "go-down"));
            item.Activated += on_mnuFileDownload_activate;
            resultPopupMenu.Append(item);

            item            = new ImageMenuItem(Gtk.Stock.Properties, null);
            item.Activated += filePropertiesMenuItem_Activated;
            resultPopupMenu.Append(item);

            NavigateTo("/");
        }
Ejemplo n.º 2
0
        public SearchResultsPage(FileSearch search)
        {
            VPaned         paned;
            TreeViewColumn column;
            ToolItem       spacerItem;
            ToolItem       filterItem;
            Alignment      filterAlignment;
            ToolButton     searchAgainToolButton;

            this.search = search;

            downloadToolButton             = new ToolButton(new Image("gtk-save", IconSize.LargeToolbar), "Download");
            downloadToolButton.IsImportant = true;
            downloadToolButton.Sensitive   = false;
            downloadToolButton.Clicked    += DownloadToolButtonClicked;

            searchAgainToolButton             = new ToolButton(new Image("gtk-refresh", IconSize.LargeToolbar), "Search Again");
            searchAgainToolButton.IsImportant = true;
            searchAgainToolButton.Clicked    += SearchAgainToolButtonClicked;

            spacerItem        = new ToolItem();
            spacerItem.Expand = true;

            filterButton          = new ToggleButton("Filter Results");
            filterButton.Image    = new Image(Gui.LoadIcon(16, "application-x-executable"));
            filterButton.Toggled += delegate(object o, EventArgs args) {
                this.ShowFilter = filterButton.Active;
            };

            filterAlignment = new Alignment(0.5f, 0.5f, 0, 0);
            filterAlignment.Add(filterButton);

            filterItem = new ToolItem();
            filterItem.Add(filterAlignment);

            browseToolButton             = new ToolButton(new Image("gtk-open", IconSize.LargeToolbar), "Browse");
            browseToolButton.IsImportant = true;
            browseToolButton.Sensitive   = false;
            browseToolButton.Clicked    += BrowseToolButtonClicked;

            toolbar = new Toolbar();
            toolbar.ToolbarStyle = ToolbarStyle.BothHoriz;
            toolbar.Insert(downloadToolButton, -1);
            toolbar.Insert(browseToolButton, -1);
            toolbar.Insert(spacerItem, -1);
            toolbar.Insert(filterItem, -1);
            toolbar.Insert(new SeparatorToolItem(), -1);
            toolbar.Insert(searchAgainToolButton, -1);
            toolbar.ShowAll();

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

            resultCountByTypeCache = new Dictionary <FilterType, int>();

            Gdk.Pixbuf audioPixbuf = Gui.LoadIcon(16, "audio-x-generic");
            Gdk.Pixbuf videoPixbuf = Gui.LoadIcon(16, "video-x-generic");
            Gdk.Pixbuf imagePixbuf = Gui.LoadIcon(16, "image-x-generic");
            Gdk.Pixbuf docPixbuf   = Gui.LoadIcon(16, "x-office-document");
            unknownPixbuf = Gui.LoadIcon(16, "text-x-generic");
            folderPixbuf  = Gui.LoadIcon(16, "folder");

            typeStore = new ListStore(typeof(Gdk.Pixbuf), typeof(string), typeof(FilterType));
            typeStore.AppendValues(null, "All Results", FilterType.All);
            typeStore.AppendValues(null, "-");
            typeStore.AppendValues(audioPixbuf, "Audio", FilterType.Audio);
            typeStore.AppendValues(videoPixbuf, "Video", FilterType.Video);
            typeStore.AppendValues(imagePixbuf, "Images", FilterType.Image);
            typeStore.AppendValues(docPixbuf, "Documents", FilterType.Document);
            typeStore.AppendValues(folderPixbuf, "Folders", FilterType.Folder);
            typeStore.AppendValues(unknownPixbuf, "Other", FilterType.Other);

            typeTree = new TreeView();
            typeTree.HeadersVisible   = false;
            typeTree.RowSeparatorFunc = delegate(TreeModel m, TreeIter i) {
                string text = (string)m.GetValue(i, 1);
                return(text == "-");
            };
            typeTree.Selection.Changed += TypeSelectionChanged;

            typeTree.Model = typeStore;

            CellRendererPixbuf pixbufCell    = new CellRendererPixbuf();
            CellRendererText   textCell      = new CellRendererText();
            CellRendererText   countTextCell = new CellRendererText();

            countTextCell.Sensitive = false;
            countTextCell.Alignment = Pango.Alignment.Right;
            countTextCell.Xalign    = 1;

            column = new TreeViewColumn();
            column.PackStart(pixbufCell, false);
            column.PackStart(textCell, true);
            column.PackStart(countTextCell, false);
            column.AddAttribute(pixbufCell, "pixbuf", 0);
            column.AddAttribute(textCell, "text", 1);
            column.SetCellDataFunc(countTextCell, new TreeCellDataFunc(TypeCountCellFunc));

            typeTree.AppendColumn(column);

            TreeView artistTree = new TreeView();

            artistTree.HeadersVisible = false;

            TreeView albumTree = new TreeView();

            albumTree.HeadersVisible = false;

            HBox topBox = new HBox();

            topBox.PackStart(Gui.AddScrolledWindow(typeTree), true, true, 0);
            topBox.PackStart(Gui.AddScrolledWindow(artistTree), true, true, 1);
            topBox.PackStart(Gui.AddScrolledWindow(albumTree), true, true, 0);
            topBox.Homogeneous = true;

            resultsStore              = new ListStore(typeof(SearchResult));
            resultsStore.RowInserted += delegate {
                Refilter();
            };
            resultsStore.RowDeleted += delegate {
                Refilter();
            };
            resultsTree = new TreeView();
            resultsTree.RowActivated      += resultsTree_RowActivated;
            resultsTree.ButtonPressEvent  += resultsTree_ButtonPressEvent;
            resultsTree.Selection.Changed += ResultsTreeSelectionChanged;

            imageColumns      = new List <TreeViewColumn>();
            audioColumns      = new List <TreeViewColumn>();
            videoColumns      = new List <TreeViewColumn>();
            fileOnlyColumns   = new List <TreeViewColumn>();
            folderOnlyColumns = new List <TreeViewColumn>();

            column              = new TreeViewColumn();
            column.Title        = "File Name";
            column.Clickable    = true;
            column.Sizing       = TreeViewColumnSizing.Autosize;
            column.Resizable    = true;
            column.SortColumnId = 0;
            //resultsTree.ExpanderColumn = column;

            CellRenderer cell = new CellRendererPixbuf();

            column.PackStart(cell, false);
            column.SetCellDataFunc(cell, new TreeCellDataFunc(IconFunc));

            cell = new CellRendererText();
            column.PackStart(cell, true);
            column.SetCellDataFunc(cell, new TreeCellDataFunc(FileNameFunc));

            resultsTree.AppendColumn(column);

            column              = resultsTree.AppendColumn("Codec", new CellRendererText(), new TreeCellDataFunc(CodecFunc));
            column.Clickable    = true;
            column.Sizing       = TreeViewColumnSizing.Fixed;
            column.FixedWidth   = 120;
            column.Resizable    = true;
            column.SortColumnId = 1;
            videoColumns.Add(column);

            column              = resultsTree.AppendColumn("Format", new CellRendererText(), new TreeCellDataFunc(FormatFunc));
            column.Clickable    = true;
            column.Sizing       = TreeViewColumnSizing.Fixed;
            column.FixedWidth   = 90;
            column.Resizable    = true;
            column.SortColumnId = 2;
            imageColumns.Add(column);

            column              = resultsTree.AppendColumn("Resolution", new CellRendererText(), new TreeCellDataFunc(ResolutionFunc));
            column.Clickable    = true;
            column.Sizing       = TreeViewColumnSizing.Fixed;
            column.FixedWidth   = 90;
            column.Resizable    = true;
            column.SortColumnId = 3;
            videoColumns.Add(column);
            imageColumns.Add(column);

            column              = resultsTree.AppendColumn("Artist", new CellRendererText(), new TreeCellDataFunc(ArtistFunc));
            column.Clickable    = true;
            column.Sizing       = TreeViewColumnSizing.Fixed;
            column.FixedWidth   = 110;
            column.Resizable    = true;
            column.SortColumnId = 4;
            audioColumns.Add(column);

            column              = resultsTree.AppendColumn("Album", new CellRendererText(), new TreeCellDataFunc(AlbumFunc));
            column.Clickable    = true;
            column.Sizing       = TreeViewColumnSizing.Fixed;
            column.FixedWidth   = 110;
            column.Resizable    = true;
            column.SortColumnId = 5;
            audioColumns.Add(column);

            column              = resultsTree.AppendColumn("Bitrate", new CellRendererText(), new TreeCellDataFunc(BitrateFunc));
            column.Clickable    = true;
            column.Sizing       = TreeViewColumnSizing.Fixed;
            column.FixedWidth   = 70;
            column.Resizable    = true;
            column.SortColumnId = 6;
            audioColumns.Add(column);

            column              = resultsTree.AppendColumn("Size", new CellRendererText(), new TreeCellDataFunc(SizeFunc));
            column.Clickable    = true;
            column.Sizing       = TreeViewColumnSizing.Fixed;
            column.FixedWidth   = 70;
            column.SortColumnId = 7;
            column.Resizable    = true;
            fileOnlyColumns.Add(column);

            column              = resultsTree.AppendColumn("Sources", new CellRendererText(), new TreeCellDataFunc(SourcesFunc));
            column.Clickable    = true;
            column.Sizing       = TreeViewColumnSizing.Fixed;
            column.FixedWidth   = 85;
            column.SortColumnId = 8;
            column.Resizable    = true;
            fileOnlyColumns.Add(column);

            column              = resultsTree.AppendColumn("User", new CellRendererText(), new TreeCellDataFunc(UserFunc));
            column.Clickable    = true;
            column.Sizing       = TreeViewColumnSizing.Fixed;
            column.FixedWidth   = 85;
            column.SortColumnId = 8;
            column.Resizable    = true;
            folderOnlyColumns.Add(column);

            column              = resultsTree.AppendColumn("Full Path", new CellRendererText(), new TreeCellDataFunc(FullPathFunc));
            column.Clickable    = true;
            column.Resizable    = true;
            column.SortColumnId = 9;

            column              = resultsTree.AppendColumn("Info Hash", new CellRendererText(), new TreeCellDataFunc(InfoHashFunc));
            column.Clickable    = true;
            column.Resizable    = true;
            column.SortColumnId = 10;
            fileOnlyColumns.Add(column);

            resultsFilter             = new TreeModelFilter(resultsStore, null);
            resultsFilter.VisibleFunc = resultsFilterFunc;

            resultsSort = new TreeModelSort(resultsFilter);
            for (int x = 0; x < resultsTree.Columns.Length; x++)
            {
                resultsSort.SetSortFunc(x, resultsSortFunc);
            }
            resultsTree.Model = resultsSort;

            ScrolledWindow resultsTreeSW = new ScrolledWindow();

            resultsTreeSW.Add(resultsTree);

            paned = new VPaned();
            paned.Add1(topBox);
            paned.Add2(resultsTreeSW);
            paned.Position = 160;
            paned.ShowAll();

            filterWidget = new FilterWidget(search);
            filterWidget.FiltersChanged += filterWidget_FiltersChanged;
            filterWidget.Hidden         += filterWidget_Hidden;

            this.PackStart(filterWidget, false, false, 0);
            this.PackStart(paned, true, true, 0);

            TypeSelectionChanged(typeTree, EventArgs.Empty);

            search.NewResults     += (EventHandler <SearchResultsEventArgs>)DispatchService.GuiDispatch(new EventHandler <SearchResultsEventArgs>(search_NewResults));
            search.ClearedResults += (EventHandler)DispatchService.GuiDispatch(new EventHandler(search_ClearedResults));

            resultPopupMenu = new Menu();

            browseResultMenuItem            = new ImageMenuItem("Browse");
            browseResultMenuItem.Image      = new Image(Gui.LoadIcon(16, "document-open"));
            browseResultMenuItem.Activated += BrowseToolButtonClicked;
            resultPopupMenu.Append(browseResultMenuItem);

            downloadResultMenuItem            = new ImageMenuItem("Download");
            downloadResultMenuItem.Image      = new Image(Gui.LoadIcon(16, "go-down"));
            downloadResultMenuItem.Activated += DownloadToolButtonClicked;
            resultPopupMenu.Append(downloadResultMenuItem);

            resultPropertiesMenuItem            = new ImageMenuItem(Gtk.Stock.Properties, null);
            resultPropertiesMenuItem.Activated += FilePropertiesButtonClicked;
            resultPopupMenu.Append(resultPropertiesMenuItem);
        }