public TestResultsPad()
        {
            title = "Test results";

            testService.TestSuiteChanged += new EventHandler (OnTestSuiteChanged);

            panel = new VBox ();

            Toolbar toolbar = new Toolbar ();
            toolbar.IconSize = IconSize.SmallToolbar;
            panel.PackStart (toolbar, false, false, 0);

            buttonSuccess = new ToggleToolButton ();
            buttonSuccess.Label = "Successful Tests";
            buttonSuccess.Active = false;
            buttonSuccess.IconWidget = new Gtk.Image (CircleImage.Success);
            buttonSuccess.IsImportant = true;
            buttonSuccess.Toggled += new EventHandler (OnShowSuccessfulToggled);
            buttonSuccess.SetTooltip (tips, "Show Successful Tests", "Show Successful Tests");
            toolbar.Insert (buttonSuccess, -1);

            buttonFailures = new ToggleToolButton ();
            buttonFailures.Label = "Failed Tests";
            buttonFailures.Active = true;
            buttonFailures.IconWidget = new Gtk.Image (CircleImage.Failure);
            buttonFailures.IsImportant = true;
            buttonFailures.Toggled += new EventHandler (OnShowFailuresToggled);
            buttonFailures.SetTooltip (tips, "Show Failed Tests", "Show Failed Tests");
            toolbar.Insert (buttonFailures, -1);

            buttonIgnored = new ToggleToolButton ();
            buttonIgnored.Label = "Ignored Tests";
            buttonIgnored.Active = true;
            buttonIgnored.IconWidget = new Gtk.Image (CircleImage.NotRun);
            buttonIgnored.Toggled += new EventHandler (OnShowIgnoredToggled);
            buttonIgnored.IsImportant = true;
            buttonIgnored.SetTooltip (tips, "Show Ignored Tests", "Show Ignored Tests");
            toolbar.Insert (buttonIgnored, -1);

            buttonOutput = new ToggleToolButton ();
            buttonOutput.Label = "Output";
            buttonOutput.Active = false;
            buttonOutput.IconWidget = Runtime.Gui.Resources.GetImage (MonoDevelop.Gui.Stock.OutputIcon, IconSize.SmallToolbar);
            buttonOutput.Toggled += new EventHandler (OnShowOutputToggled);
            buttonOutput.IsImportant = true;
            buttonOutput.SetTooltip (tips, "Show Output", "Show Output");
            toolbar.Insert (buttonOutput, -1);

            toolbar.Insert (new SeparatorToolItem (), -1);

            buttonStop = new ToolButton ("gtk-stop");
            toolbar.Insert (buttonStop, -1);

            toolbar.ToolbarStyle = ToolbarStyle.BothHoriz;
            toolbar.ShowArrow = false;

            // Results notebook

            book = new HPaned ();
            panel.PackStart (book, true, true, 0);

            // Failures tree
            failuresTreeView = new TreeView ();
            failuresTreeView.HeadersVisible = false;
            failuresStore = new TreeStore (typeof(Pixbuf), typeof (string), typeof(object));
            CellRendererPixbuf pr = new CellRendererPixbuf ();
            CellRendererText tr = new CellRendererText ();
            TreeViewColumn col = new TreeViewColumn ();
            col.PackStart (pr, false);
            col.AddAttribute (pr, "pixbuf", 0);
            col.PackStart (tr, false);
            col.AddAttribute (tr, "markup", 1);
            failuresTreeView.AppendColumn (col);
            failuresTreeView.Model = failuresStore;

            Gtk.ScrolledWindow sw = new Gtk.ScrolledWindow ();
            sw.Add(failuresTreeView);
            Frame frame = new Frame ();
            frame.Add (sw);
            book.Pack1 (frame, true, true);

            outputView = new TextView();
            outputView.Editable = false;
            sw = new Gtk.ScrolledWindow ();
            sw.Add(outputView);
            frame = new Frame ();
            frame.Add (sw);
            book.Pack2 (frame, true, true);
            outputViewScrolled = frame;

            // Run panel

            HBox runPanel = new HBox ();
            runPanel.BorderWidth = 5;

            infoSep = new VSeparator ();

            resultLabel.UseMarkup = true;
            runPanel.PackStart (resultLabel, false, false, 0);
            runPanel.PackStart (progressBar, false, false, 0);
            runPanel.PackStart (infoCurrent, true, true, 10);

            labels = new HBox (false, 10);

            infoFailed.UseMarkup = true;
            infoIgnored.UseMarkup = true;

            labels.PackStart (infoFailed, true, false, 0);
            labels.PackStart (infoIgnored, true, false, 0);

            runPanel.PackEnd (labels, false, false, 0);
            runPanel.PackEnd (infoSep, false, false, 10);

            panel.PackStart (runPanel, false, false, 0);
            progressBar.HeightRequest = infoFailed.SizeRequest().Height;

            buttonStop.Clicked += new EventHandler (OnStopClicked);
            failuresTreeView.ButtonReleaseEvent += new Gtk.ButtonReleaseEventHandler (OnPopupMenu);

            Control.ShowAll ();

            outputViewScrolled.Hide ();
        }
		void IPadContent.Initialize (IPadWindow window)
		{
			this.window = window;
			
			DockItemToolbar toolbar = window.GetToolbar (PositionType.Top);
			
			buttonSuccess = new ToggleButton ();
			buttonSuccess.Label = GettextCatalog.GetString ("Successful Tests");
			buttonSuccess.Active = false;
			buttonSuccess.Image = new ImageView (TestStatusIcon.Success);
			buttonSuccess.Image.Show ();
			buttonSuccess.Toggled += new EventHandler (OnShowSuccessfulToggled);
			buttonSuccess.TooltipText = GettextCatalog.GetString ("Show Successful Tests");
			toolbar.Add (buttonSuccess);

			buttonInconclusive = new ToggleButton ();
			buttonInconclusive.Label = GettextCatalog.GetString ("Inconclusive Tests");
			buttonInconclusive.Active = true;
			buttonInconclusive.Image = new ImageView (TestStatusIcon.Inconclusive);
			buttonInconclusive.Image.Show ();
			buttonInconclusive.Toggled += new EventHandler (OnShowInconclusiveToggled);
			buttonInconclusive.TooltipText = GettextCatalog.GetString ("Show Inconclusive Tests");
			toolbar.Add (buttonInconclusive);
			
			buttonFailures = new ToggleButton ();
			buttonFailures.Label = GettextCatalog.GetString ("Failed Tests");
			buttonFailures.Active = true;
			buttonFailures.Image = new ImageView (TestStatusIcon.Failure);
			buttonFailures.Image.Show ();
			buttonFailures.Toggled += new EventHandler (OnShowFailuresToggled);
			buttonFailures.TooltipText = GettextCatalog.GetString ("Show Failed Tests");
			toolbar.Add (buttonFailures);

			buttonIgnored = new ToggleButton ();
			buttonIgnored.Label = GettextCatalog.GetString ("Ignored Tests");
			buttonIgnored.Active = true;
			buttonIgnored.Image = new ImageView (TestStatusIcon.NotRun);
			buttonIgnored.Image.Show ();
			buttonIgnored.Toggled += new EventHandler (OnShowIgnoredToggled);
			buttonIgnored.TooltipText = GettextCatalog.GetString ("Show Ignored Tests");
			toolbar.Add (buttonIgnored);
			
			buttonOutput = new ToggleButton ();
			buttonOutput.Label = GettextCatalog.GetString ("Output");
			buttonOutput.Active = false;
			buttonOutput.Image = ImageService.GetImage (MonoDevelop.Ide.Gui.Stock.OutputIcon, IconSize.Menu);
			buttonOutput.Image.Show ();
			buttonOutput.Toggled += new EventHandler (OnShowOutputToggled);
			buttonOutput.TooltipText = GettextCatalog.GetString ("Show Output");
			toolbar.Add (buttonOutput);
			
			toolbar.Add (new SeparatorToolItem ());
			
			buttonRun = new Button ();
			buttonRun.Label = GettextCatalog.GetString ("Rerun Tests");
			buttonRun.Image = new Gtk.Image (Gtk.Stock.Execute, IconSize.Menu);
			buttonRun.Image.Show ();
			buttonRun.Sensitive = false;
			toolbar.Add (buttonRun);
			
			buttonStop = new Button (new Gtk.Image (Ide.Gui.Stock.Stop, Gtk.IconSize.Menu));
			toolbar.Add (buttonStop);
			toolbar.ShowAll ();
			
			buttonStop.Clicked += new EventHandler (OnStopClicked);
			buttonRun.Clicked += new EventHandler (OnRunClicked);
			
			// Run panel
			
			DockItemToolbar runPanel = window.GetToolbar (PositionType.Bottom);
			
			infoSep = new VSeparator ();
			
			resultLabel.UseMarkup = true;
			infoCurrent.Ellipsize = Pango.EllipsizeMode.Start;
			infoCurrent.WidthRequest = 0;
			runPanel.Add (resultLabel);
			runPanel.Add (progressBar);
			runPanel.Add (infoCurrent, true, 10);	
			
			labels = new HBox (false, 10);
			
			infoLabel.UseMarkup = true;

			labels.PackStart (infoLabel, true, false, 0);

			runPanel.Add (new Gtk.Label (), true);
			runPanel.Add (labels);
			runPanel.Add (infoSep, false, 10);
			
			progressBar.HeightRequest = infoLabel.SizeRequest ().Height;
			runPanel.ShowAll ();
			resultSummary = new UnitTestResult ();
			UpdateCounters ();
		}
		public Toolbox (ToolboxService toolboxService, IPadWindow container)
		{			
			this.toolboxService = toolboxService;
			
			#region Toolbar
			DockItemToolbar toolbar = container.GetToolbar (PositionType.Top);
		
			filterToggleButton = new ToggleButton ();
			filterToggleButton.Image = new Image (Gtk.Stock.Find, IconSize.Menu);
			filterToggleButton.Toggled += new EventHandler (toggleFiltering);
			filterToggleButton.TooltipText = GettextCatalog.GetString ("Show search box");
			toolbar.Add (filterToggleButton);
			
			catToggleButton = new ToggleButton ();
			catToggleButton.Image = new Image (ImageService.GetPixbuf ("md-design-categorise", IconSize.Menu));
			catToggleButton.Toggled += new EventHandler (toggleCategorisation);
			catToggleButton.TooltipText = GettextCatalog.GetString ("Show categories");
			toolbar.Add (catToggleButton);
			
			compactModeToggleButton = new ToggleButton ();
			compactModeToggleButton.Image = new Image (ImageService.GetPixbuf ("md-design-listboxtoggle", IconSize.Menu));
			compactModeToggleButton.Toggled += new EventHandler (ToggleCompactMode);
			compactModeToggleButton.TooltipText = GettextCatalog.GetString ("Use compact display");
			toolbar.Add (compactModeToggleButton);
	
			VSeparator sep = new VSeparator ();
			toolbar.Add (sep);
			
			Button toolboxAddButton = new Button (new Gtk.Image (Gtk.Stock.Add, IconSize.Menu));
			toolbar.Add (toolboxAddButton);
			toolboxAddButton.TooltipText = GettextCatalog.GetString ("Add toolbox items");
			toolboxAddButton.Clicked += new EventHandler (toolboxAddButton_Clicked);
			toolbar.ShowAll ();
			
			filterEntry = new Entry();
			filterEntry.WidthRequest = 150;
			filterEntry.Changed += new EventHandler (filterTextChanged);
			
			#endregion
			
			toolboxWidget = new ToolboxWidget ();
			toolboxWidget.SelectedItemChanged += delegate {
				selectedNode = this.toolboxWidget.SelectedItem != null ? this.toolboxWidget.SelectedItem.Tag as ItemToolboxNode : null;
				toolboxService.SelectItem (selectedNode);
			};
			this.toolboxWidget.DragBegin += delegate(object sender, Gtk.DragBeginArgs e) {
				
				if (this.toolboxWidget.SelectedItem != null) {
					this.toolboxWidget.HideTooltipWindow ();
					toolboxService.DragSelectedItem (this.toolboxWidget, e.Context);
				}
			};
			this.toolboxWidget.ActivateSelectedItem += delegate {
				toolboxService.UseSelectedItem ();
			};
			
			fontChanger = new MonoDevelop.Ide.Gui.PadFontChanger (toolboxWidget, toolboxWidget.SetCustomFont, toolboxWidget.QueueResize);
			
			this.toolboxWidget.ButtonReleaseEvent += OnButtonRelease;
			
			scrolledWindow = new MonoDevelop.Components.CompactScrolledWindow ();
			base.PackEnd (scrolledWindow, true, true, 0);
			base.FocusChain = new Gtk.Widget [] { scrolledWindow };
			
			//Initialise self
			scrolledWindow.ShadowType = ShadowType.None;
			scrolledWindow.VscrollbarPolicy = PolicyType.Automatic;
			scrolledWindow.HscrollbarPolicy = PolicyType.Never;
			scrolledWindow.WidthRequest = 150;
			scrolledWindow.Add (this.toolboxWidget);
			
			//update view when toolbox service updated
			toolboxService.ToolboxContentsChanged += delegate { Refresh (); };
			toolboxService.ToolboxConsumerChanged += delegate { Refresh (); };
			Refresh ();
			
			//set initial state
			filterToggleButton.Active = false;
			this.toolboxWidget.ShowCategories = catToggleButton.Active = true;
			compactModeToggleButton.Active = MonoDevelop.Core.PropertyService.Get ("ToolboxIsInCompactMode", false);
			this.toolboxWidget.IsListMode  = !compactModeToggleButton.Active;
			this.ShowAll ();
		}
		void IPadContent.Initialize (IPadWindow window)
		{
			toolbar = window.GetToolbar (PositionType.Top);
			toolbar.Add (switcherCombo);
			toolbar.ShowAll ();
			switcherCombo.Changed += new EventHandler (OnContentSwitched);
			OnContentSwitched (null, null);
			
			separator = new VSeparator ();
		}
    public DialogPersonPopup(int personID, string name, string rfid,
                             List <Task> tasks, List <StationCount> stationsCount, bool serverConnected, bool Autologout)
    {
        Glade.XML gladeXML;
        gladeXML = Glade.XML.FromAssembly(Util.GetGladePath() + "dialog_person_popup.glade", "dialog_person_popup", null);
        gladeXML.Autoconnect(this);

        //put an icon to window
        UtilGtk.IconWindow(dialog_person_popup);

        Visible         = true;
        this.Autologout = Autologout;

        //1) Show top of the window widgets
        label_name.Text      = "<b>" + name + "</b>";
        label_name.UseMarkup = true;
        label_rfid.Text      = rfid;

        Pixbuf pixbuf = new Pixbuf(null, Util.GetImagePath(false) + "image_close.png");

        image_close.Pixbuf = pixbuf;

        pixbuf = new Pixbuf(null, Util.GetImagePath(false) + "image_person_logout.png");
        image_person_logout.Pixbuf = pixbuf;

        pixbuf = new Pixbuf(null, Util.GetImagePath(false) + "gtk-apply.png");
        image_server_connected_yes.Pixbuf = pixbuf;
        pixbuf = new Pixbuf(null, Util.GetImagePath(false) + "gtk-cancel.png");
        image_server_connected_no.Pixbuf = pixbuf;

        if (serverConnected)
        {
            label_server_connected.Text        = "Server is connected";
            image_server_connected_yes.Visible = true;
            image_server_connected_no.Visible  = false;
        }
        else
        {
            label_server_connected.Text        = Constants.ServerDisconnectedMessage;
            image_server_connected_yes.Visible = false;
            image_server_connected_no.Visible  = true;
        }

        //string photoFile = Util.GetPhotoFileName(false, personID);
        string photoFile = Util.UserPhotoURL(false, personID);

        if (File.Exists(photoFile))
        {
            try {
                pixbuf = new Pixbuf(photoFile);                  //from a file
                image_person.Pixbuf = pixbuf;
            } catch {
                string extension = Util.GetMultimediaExtension(photoFile);
                //on windows there are problem using the fileNames that are not on temp
                string tempFileName = Path.Combine(Path.GetTempPath(),
                                                   Constants.PhotoSmallTemp + extension);
                File.Copy(photoFile, tempFileName, true);
                pixbuf = new Pixbuf(tempFileName);
                image_person.Pixbuf = pixbuf;
            }
        }

        //2) Show tasks stuff
        list_tasks_fixed                      = new List <Task>();
        list_hboxs_row                        = new List <Gtk.HBox>();
        list_buttons_start                    = new List <Gtk.Button>();
        list_buttons_done                     = new List <Gtk.Button>();
        list_buttons_done_id                  = new List <int>();
        taskActive                            = new Task();
        Fake_button_start_task                = new Gtk.Button();
        Fake_button_person_logout             = new Gtk.Button();
        Fake_button_person_autologout_changed = new Gtk.Button();

        checkbutton_autologout.Active = Autologout;

        bool task_parametrized_exist = false;

        pixbuf = new Pixbuf(null, Util.GetImagePath(false) + "image_capture_big.png");

        Gtk.HBox hboxRow;
        foreach (Task t in tasks)
        {
            hboxRow = new Gtk.HBox(false, 10);

            if (t.Laterality == "R,L")
            {
                Gtk.VBox vboxRL = new Gtk.VBox(false, 4);

                Task taskCopy = new Task(t.Id, t.PersonId, t.StationId, t.ExerciseId, t.ExerciseName,
                                         t.Sets, t.Nreps, t.Load, t.Speed, t.PercentMaxSpeed,
                                         "R", t.Comment);
                Gtk.HBox hboxStartAndLabel = createHBoxStartAndLabel(taskCopy, pixbuf);
                vboxRL.PackStart(hboxStartAndLabel, false, false, 0);

                taskCopy = new Task(t.Id, t.PersonId, t.StationId, t.ExerciseId, t.ExerciseName,
                                    t.Sets, t.Nreps, t.Load, t.Speed, t.PercentMaxSpeed,
                                    "L", t.Comment);
                hboxStartAndLabel = createHBoxStartAndLabel(taskCopy, pixbuf);
                vboxRL.PackStart(hboxStartAndLabel, false, false, 0);

                Gtk.VSeparator vsep = new Gtk.VSeparator();
                hboxRow.PackStart(vsep, false, false, 0);
                hboxRow.PackStart(vboxRL, false, false, 0);
            }
            else
            {
                Gtk.HBox hboxStartAndLabel = createHBoxStartAndLabel(t, pixbuf);
                hboxRow.PackStart(hboxStartAndLabel, false, false, 0);
            }

            task_parametrized_exist = true;

            //create button_done (shared on R,L)
            Gtk.Button button_done = new Gtk.Button("Fet!");
            button_done.Clicked += new EventHandler(button_done_clicked);
            hboxRow.PackEnd(button_done, false, false, 0);
            list_buttons_done.Add(button_done);
            list_buttons_done_id.Add(t.Id);
            list_hboxs_row.Add(hboxRow);

            vbox_tasks_parametrized.PackStart(hboxRow, false, false, 0);
        }

        if (!task_parametrized_exist)
        {
            Gtk.Label label = new Gtk.Label("There are no pending tasks on this station.");
            vbox_tasks_parametrized.PackStart(label, false, false, 0);
        }

        vbox_tasks_parametrized.ShowAll();

        //3) Show other stations tasks
        string sep            = "";
        string stationsString = "";

        foreach (StationCount sc in stationsCount)
        {
            stationsString += sep + sc.ToString();
            sep             = ", ";
        }

        if (stationsString == "")
        {
            label_other_stations.Text = "There are no tasks at other stations";
        }
        else
        {
            //label_other_stations.Text = "There are task at this stations:" + "\n\n" + stationsString;
            label_other_stations.Text = stationsString;
        }
    }
        private void BuildContents()
        {
            VBox box = new VBox();
            box.BorderWidth = 8;
            box.Spacing = 10;
            box.Show();

            header_label.Xalign = 0.0f;

            header_label.Show();
            description_label.Show();
            normal_controls_table.Show();
            advanced_controls_table.Show();

            advanced_expander.Add(advanced_controls_table);
            advanced_expander.Show();

            box.PackStart(header_label, false, false, 0);
            box.PackStart(description_label, false, false, 0);
            box.PackStart(normal_controls_table, false, false, 5);
            box.PackStart(advanced_expander, false, false, 0);

            if(sexpr_results != null) {
                ScrolledWindow scroll = new Gtk.ScrolledWindow();
                scroll.HscrollbarPolicy = PolicyType.Automatic;
                scroll.VscrollbarPolicy = PolicyType.Automatic;
                scroll.ShadowType = ShadowType.In;
                sexpr_results.WrapMode = WrapMode.Word;
                sexpr_results.SetSizeRequest(-1, 100);
                scroll.Add(sexpr_results);
                scroll.ShowAll();

                VSeparator sep = new VSeparator();
                sep.Show();

                Label label = new Label();
                label.Markup = "<b>S-Expr Results</b>";
                label.Xalign = 0.0f;
                label.Show();

                box.PackStart(sep, false, false, 0);
                box.PackStart(label, false, false, 0);
                box.PackStart(scroll, false, false, 0);
            }

            ContentArea.PackStart(box, false, false, 0);

            SetSizeRequest(350, -1);

            Gdk.Geometry limits = new Gdk.Geometry();
            int minimum_width, natural_width;
            GetPreferredWidth (out minimum_width, out natural_width);
            limits.MinWidth = minimum_width;
            limits.MaxWidth = Gdk.Screen.Default.Width;
            limits.MinHeight = -1;
            limits.MaxHeight = -1;
            SetGeometryHints(this, limits, Gdk.WindowHints.MaxSize | Gdk.WindowHints.MinSize);
        }
		public void Pack (Widget aWidget)
		{
			if (aWidget == null)
				return;
			
			if ((Count > 0) && (SeparatorLines == true)) {
				//System.Console.WriteLine("Separator");
				VSeparator vs = new VSeparator();
				vs.Show();
				widgets[Count-1].PackEnd (vs, false, false, 0);
			}

			widgets.Add (new HBox());
			widgets[Count-1].Spacing = 3;
			widgets[Count-1].Show();
			if (Homogeneous == true)
				mainbox.PackStart (widgets[Count-1], true, true, 0);
			else
				mainbox.PackStart (widgets[Count-1], false, false, 0);
			if (aWidget is HComboCell) {
				(aWidget as HComboCell).BorderWidth = 1;
				aWidget.Show();
				widgets[Count-1].PackStart (aWidget, true, true, 0);
			}
			else {
				HComboCell eb = new HComboCellWidget (aWidget);
				eb.BorderWidth = 1;
				aWidget.Show();
				eb.Show();
				widgets[Count-1].PackStart (eb, true, true, 0);
			}
			if (Count == 1)
				Selected = 0;
		}
		Gtk.Button MakeFontButton ()
		{
			Gtk.HBox font_box = new Gtk.HBox (false, 0);
			font_box.Show ();

			font_face = new Gtk.Label (null);
			font_face.UseMarkup = true;
			font_face.Show ();
			font_box.PackStart (font_face, true, true, 0);

			Gtk.VSeparator sep = new Gtk.VSeparator ();
			sep.Show ();
			font_box.PackStart (sep, false, false, 0);

			font_size = new Gtk.Label (null);
			font_size.Xpad = 4;
			font_size.Show ();
			font_box.PackStart (font_size, false, false, 0);

			Gtk.Button button = new Gtk.Button ();
			button.Clicked += OnFontButtonClicked;
			button.Add (font_box);
			button.Show ();

			string font_desc = (string) Preferences.Get (Preferences.CUSTOM_FONT_FACE);
			UpdateFontButton (font_desc);

			return button;
		}
        public SqlQueryView()
            : base()
        {
            control = new Frame ();
            control.Show ();

            VBox vbox = new VBox ();
            vbox.Show ();

            Tooltips tips = new Tooltips ();

            Toolbar toolbar = new Toolbar ();
            vbox.PackStart 	(toolbar, false, true, 0);
            toolbar.Show ();

            Image image = new Image ();
            image.Pixbuf = Gdk.Pixbuf.LoadFromResource ("MonoQuery.Execute");
            image.Show ();

            Button execute = new Button (image);
            execute.Clicked += new EventHandler (OnExecute);
            execute.Relief = ReliefStyle.None;
            tips.SetTip (execute, "Execute", "");
            toolbar.Add (execute);
            execute.Show ();

            image = new Image ();
            image.Pixbuf = Gdk.Pixbuf.LoadFromResource ("MonoQuery.RunFromCursor");
            image.Show ();

            Button run = new Button (image);
            run.Clicked += new EventHandler (OnRunFromCursor);
            run.Relief = ReliefStyle.None;
            tips.SetTip (run, "Run from cursor", "");
            toolbar.Add (run);
            run.Show ();

            image = new Image ();
            image.Pixbuf = Gdk.Pixbuf.LoadFromResource ("MonoQuery.Explain");
            image.Show ();

            Button explain = new Button (image);
            explain.Clicked += new EventHandler (OnExplain);
            explain.Relief = ReliefStyle.None;
            tips.SetTip (explain, "Explain query", "");
            toolbar.Add (explain);
            explain.Show ();

            image = new Image ();
            image.Pixbuf = Gdk.Pixbuf.LoadFromResource ("MonoQuery.Stop");
            image.Show ();

            Button stop = new Button (image);
            stop.Clicked += new EventHandler (OnStop);
            stop.Relief = ReliefStyle.None;
            stop.Sensitive = false;
            tips.SetTip (stop, "Stop", "");
            toolbar.Add (stop);
            stop.Show ();

            VSeparator sep = new VSeparator ();
            toolbar.Add (sep);
            sep.Show ();

            model = new ListStore (typeof (string), typeof (DbProviderBase));

            providers = new ComboBox ();
            providers.Model = model;
            CellRendererText ctext = new CellRendererText ();
            providers.PackStart (ctext, true);
            providers.AddAttribute (ctext, "text", 0);
            toolbar.Add (providers);
            providers.Show ();

            SourceLanguagesManager lm = new SourceLanguagesManager ();
            SourceLanguage lang = lm.GetLanguageFromMimeType ("text/x-sql");
            SourceBuffer buf = new SourceBuffer (lang);
            buf.Highlight = true;
            sourceView = new SourceView (buf);
            sourceView.ShowLineNumbers = true;
            sourceView.Show ();

            ScrolledWindow scroller = new ScrolledWindow ();
            scroller.Add (sourceView);
            scroller.Show ();
            vbox.PackStart (scroller, true, true, 0);

            control.Add (vbox);

            service = (MonoQueryService)
                ServiceManager.GetService (typeof (MonoQueryService));
            changedHandler
                 = (EventHandler) Runtime.DispatchService.GuiDispatch (
                    new EventHandler (OnProvidersChanged));
            service.Providers.Changed += changedHandler;

            foreach (DbProviderBase p in service.Providers) {
                model.AppendValues (p.Name, p);
            }
        }
		void DisposeSortingWidgets ()
		{
			groupToggleButton.Dispose ();
			groupToggleButton = null;

			sortAlphabeticallyToggleButton.Dispose ();
			sortAlphabeticallyToggleButton = null;

			preferencesButton.Dispose ();
			preferencesButton = null;

			separator.Dispose ();
			separator = null;

			toolbar = null;
		}
		void InitializeSortingWidgets (IPadWindow window)
		{
			groupToggleButton = new ToggleButton ();
			groupToggleButton.Image = new Image (ImageService.GetPixbuf ("md-design-categorise", IconSize.Menu));
			groupToggleButton.Toggled += new EventHandler (OnButtonGroupClicked);
			groupToggleButton.TooltipText = GettextCatalog.GetString ("Group entries by type");

			sortAlphabeticallyToggleButton = new ToggleButton ();
			sortAlphabeticallyToggleButton.Image = new Image (Gtk.Stock.SortAscending, IconSize.Menu);
			sortAlphabeticallyToggleButton.Toggled += new EventHandler (OnButtonSortAlphabeticallyClicked);
			sortAlphabeticallyToggleButton.TooltipText = GettextCatalog.GetString ("Sort entries alphabetically");

			preferencesButton = new DockToolButton (Gtk.Stock.Preferences);
			preferencesButton.Image = new Image (Gtk.Stock.Preferences, IconSize.Menu);
			preferencesButton.Clicked += new EventHandler (OnButtonPreferencesClicked);
			preferencesButton.TooltipText = GettextCatalog.GetString ("Open preferences dialog");

			separator = new VSeparator ();

			toolbar = window.GetToolbar (PositionType.Top);
			toolbar.Add (groupToggleButton);
			toolbar.Add (sortAlphabeticallyToggleButton);
			toolbar.Add (separator);
			toolbar.Add (preferencesButton);
			toolbar.ShowAll ();

			toolbar.Visible = false;
		}