private void RemoveButtonClicked(object o, EventArgs args) { FilterWidget parent = (FilterWidget)this.Parent; parent.RemoveFilter(this.Filter); }
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); }
private void AddButtonClicked(object o, EventArgs args) { FilterWidget parent = (FilterWidget)this.Parent; parent.AddFilter(new FileSearchFilter()); }
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 += (NewResultsEventHandler)DispatchService.GuiDispatch(new NewResultsEventHandler(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); }