Fix #362058. Check for illegal length in PPT filter.
[beagle.git] / Renderers / HitRendererControl.cs
blobda9f6d8bd2a2a78cbe4c8f6914fb17e289ed71c3
1 //
2 // HitRendererControl.cs
3 //
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to deal
8 // in the Software without restriction, including without limitation the rights
9 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 // copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
13 // The above copyright notice and this permission notice shall be included in all
14 // copies or substantial portions of the Software.
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 // SOFTWARE.
25 using System;
26 using System.Collections;
28 namespace Beagle {
30 public class HitRendererControl : Gtk.HBox {
32 string name;
33 HitRenderer renderer;
35 Gtk.Label nameLabel;
36 Gtk.Label displayedLabel;
38 Gtk.Button prevButton;
39 Gtk.Button nextButton;
41 public HitRendererControl (string _name, string icon, HitRenderer r)
42 : base (false, 3)
44 name = _name;
45 renderer = r;
47 renderer.RefreshEvent += new HitRenderer.RefreshHandler (OnRefresh);
49 if (icon != null) {
50 Gtk.Widget iconW = DataBarn.GetImageWidget (icon);
51 if (iconW != null) {
52 this.PackStart (iconW, false, false, 3);
53 iconW.Show ();
57 nameLabel = new Gtk.Label ("");
58 this.PackStart (nameLabel, false, false, 3);
59 nameLabel.Show ();
62 nextButton = new Gtk.Button ("Next");
63 nextButton.Clicked += new EventHandler (OnNextClicked);
64 this.PackEnd (nextButton, false, false, 3);
66 displayedLabel = new Gtk.Label ("");
67 this.PackEnd (displayedLabel, false, false, 3);
68 displayedLabel.Show ();
70 prevButton = new Gtk.Button ("Prev");
71 prevButton.Clicked += new EventHandler (OnPrevClicked);
72 this.PackEnd (prevButton, false, false, 3);
74 // Initialize things
75 OnRefresh (null);
78 private void OnRefresh (HitRenderer signaller)
80 string str;
82 str = "<b>" + name + "</b>";
83 if (renderer.TotalCount > 0) {
84 str += " -- " + renderer.TotalCount + " match";
85 if (renderer.TotalCount > 1)
86 str += "es";
88 nameLabel.Markup = str;
91 str = "";
92 if (renderer.DisplayedCount > 1) {
93 str = String.Format ("{0} - {1} displayed",
94 renderer.FirstDisplayed + 1,
95 renderer.LastDisplayed + 1);
96 if (renderer.LastDisplayed + 1 < renderer.TotalCount) {
97 prevButton.Show ();
98 nextButton.Show ();
101 displayedLabel.Text = str;
103 prevButton.Sensitive = (renderer.FirstDisplayed > 0);
104 nextButton.Sensitive = (renderer.LastDisplayed + 1 < renderer.TotalCount
105 && renderer.TotalCount > 0);
108 private void OnPrevClicked (object o, EventArgs args)
110 renderer.DisplayPrev ();
113 private void OnNextClicked (object o, EventArgs args)
115 renderer.DisplayNext ();