static void StoreHistory(string propertyName, Gtk.ComboBoxEntry comboBox)
        {
            ListStore     store   = (ListStore)comboBox.Model;
            List <string> history = new List <string> ();
            TreeIter      iter;

            if (store.GetIterFirst(out iter))
            {
                do
                {
                    history.Add((string)store.GetValue(iter, 0));
                } while (store.IterNext(ref iter));
            }
            const int limit = 20;

            if (history.Count > limit)
            {
                history.RemoveRange(history.Count - (history.Count - limit), history.Count - limit);
            }
            if (history.Contains(comboBox.Entry.Text))
            {
                history.Remove(comboBox.Entry.Text);
            }
            history.Insert(0, comboBox.Entry.Text);
            PropertyService.Set(propertyName, string.Join(historySeparator.ToString(), history.ToArray()));
        }
Пример #2
0
        public static string GetComboBoxEntriesAsString(Gtk.ComboBoxEntry combo)

        {
            int index = 0;

            TreeIter iter;

            string[] entries = new string[combo.Model.IterNChildren()];



            if (combo.Model.IterChildren(out iter))

            {
                do

                {
                    entries[index] = (string)combo.Model.GetValue(iter, 0);

                    index++;
                }while (combo.Model.IterNext(ref iter));
            }



            return(string.Join(Constants.SEARCH_ENTRIES_SEPARATOR, entries));
        }
Пример #3
0
		public static Gtk.Window Create ()
		{
			window = new Window ("GtkComboBox");
			window.SetDefaultSize (200, 100);

			VBox box1 = new VBox (false, 0);
			window.Add (box1);

			VBox box2 = new VBox (false, 10);
			box2.BorderWidth = 10;
			box1.PackStart (box2, true, true, 0);

			ComboBoxEntry combo = new Gtk.ComboBoxEntry (new string[] {"Foo", "Bar"});
			combo.Changed += new EventHandler (OnComboActivated);
			combo.Entry.Changed += new EventHandler (OnComboEntryChanged);
			box2.PackStart (combo, true, true, 0);

			HSeparator separator = new HSeparator ();

			box1.PackStart (separator, false, false, 0);

			box2 = new VBox (false, 10);
			box2.BorderWidth = 10;
			box1.PackStart (box2, false, false, 0);

			Button button = new Button (Stock.Close);
			button.Clicked += new EventHandler (OnCloseClicked);
			button.CanDefault = true;
			
			box2.PackStart (button, true, true, 0);
			button.GrabDefault ();
			return window;
		}
Пример #4
0
        /// <summary>
        /// Fills the combo box entry.
        /// </summary>
        /// <param name='combo'>
        /// Combo.
        /// </param>
        /// <param name='items'>
        /// Items.
        /// </param>
        /// <param name='currentValue'>
        /// Current value.
        /// </param>
        /// <param name='editable'>
        /// Editable.
        /// </param>
        public static void FillComboBoxEntry(Gtk.ComboBoxEntry combo, List <string> items, string currentValue, bool isDecimal, bool editable)
        {
            combo.Model = new ListStore(typeof(string));

            var resultItems = new List <string>();

            if (editable)
            {
                // searching for value
                var present = false;
                foreach (var value in items)
                {
                    if (
                        (isDecimal && (SupportMethods.ToDecimal(value) == SupportMethods.ToDecimal(currentValue)))
                        ||
                        (!isDecimal && (value == currentValue))
                        )
                    {
                        present = true;
                        break;
                    }
                }

                // adding missing to first pos
                if (!present)
                {
                    resultItems.Add(currentValue);
                }

                foreach (var value in items)
                {
                    resultItems.Add(value);
                }
            }
            else
            {
                resultItems.Add(currentValue);
            }

            var index = 0;

            foreach (var value in resultItems)
            {
                combo.AppendText(value);

                if (
                    (isDecimal && (SupportMethods.ToDecimal(value) == SupportMethods.ToDecimal(currentValue)))
                    ||
                    (!isDecimal && (value == currentValue))
                    )
                {
                    combo.Active = index;
                }
                index++;
            }
        }
Пример #5
0
        //
        public void Initialize(EditSession session)
        {
            prop = session.Property;

            ICollection valuesCollection = prop.Converter.GetStandardValues();

            values = new TraceLab.Core.Components.EnumValue[valuesCollection.Count];
            valuesCollection.CopyTo(values, 0);

            //values = System.Enum.GetValues (prop.PropertyType);
            Hashtable names = new Hashtable();

            foreach (FieldInfo f in prop.PropertyType.GetFields())
            {
                DescriptionAttribute att = (DescriptionAttribute)Attribute.GetCustomAttribute(f, typeof(DescriptionAttribute));
                if (att != null)
                {
                    names [f.Name] = att.Description;
                }
                else
                {
                    names [f.Name] = f.Name;
                }
            }


            ebox = new Gtk.EventBox();
            ebox.Show();
            PackStart(ebox, true, true, 0);

            combo                     = Gtk.ComboBoxEntry.NewText();
            combo.Changed            += combo_Changed;
            combo.Entry.IsEditable    = false;
            combo.Entry.CanFocus      = false;
            combo.Entry.HasFrame      = false;
            combo.Entry.HeightRequest = combo.SizeRequest().Height;
            combo.Show();
            ebox.Add(combo);

            foreach (TraceLab.Core.Components.EnumValue value in values)
            {
                string str = prop.Converter.ConvertToString(value);
                if (names.Contains(str))
                {
                    str = (string)names [str];
                }
                combo.AppendText(str);
            }
        }
Пример #6
0
    public LendItemDialog(Item item, Database database)
    {
        this.database = database;
        this.item = item;
        this.Title = Mono.Posix.Catalog.GetString ("Lend");
        this.Modal = true;
        this.HasSeparator = false;

        VBox vBox = this.VBox;
        HBox hBox1 = new HBox ();

        string pixbuf = item.LargeCover;
        if (pixbuf != null) {
            image = new Gtk.Image (pixbuf);
        }

        label = new Label ();
        // Escape specials Markups characters
        string title;
        title = item.Title.Replace ("&", "&amp;");
        title = title.Replace ("<", "&lt;");
        title = title.Replace (">", "&gt;");
        label.Text = "<b>"+title+"</b>";
        label.UseMarkup = true;

        Label label1 = new Label (Mono.Posix.Catalog.GetString ("Borrower:"));
        borrowerComboBox = ComboBoxEntry.NewText ();
        PopulateEntryComboBox ();

        hBox1.PackStart (label1);
        hBox1.PackStart (borrowerComboBox);

        Gtk.Frame frame = new Frame ();
        frame.Shadow = ShadowType.Out;
        frame.Add (image);

        vBox.PackStart (frame);
        vBox.PackStart (label);
        vBox.PackStart (hBox1);
        vBox.Spacing = 5;

        Button cancelButton = (Button)this.AddButton (Gtk.Stock.Cancel, 0);
        Button okButton = (Button)this.AddButton (Gtk.Stock.Ok, 1);

        cancelButton.Clicked += OnCancelButtonClicked;
        okButton.Clicked     += OnOkButtonClicked;

        this.ShowAll();
    }
		public void Initialize (EditSession session)
		{
			values = DeployService.GetDeployDirectoryInfo ();
			ebox = new Gtk.EventBox ();
			ebox.Show ();
			PackStart (ebox, true, true, 0);

			combo = Gtk.ComboBoxEntry.NewText ();
			combo.Changed += combo_Changed;
			combo.Entry.IsEditable = false;
			combo.Entry.HasFrame = false;
			combo.Entry.HeightRequest = combo.SizeRequest ().Height;
			combo.Show ();
			ebox.Add (combo);

			foreach (DeployDirectoryInfo value in values) {
				combo.AppendText (value.Description);
			}
		}
Пример #8
0
        public void Initialize(EditSession session)
        {
            values = DeployService.GetDeployDirectoryInfo();
            ebox   = new Gtk.EventBox();
            ebox.Show();
            PackStart(ebox, true, true, 0);

            combo                     = Gtk.ComboBoxEntry.NewText();
            combo.Changed            += combo_Changed;
            combo.Entry.IsEditable    = false;
            combo.Entry.HasFrame      = false;
            combo.Entry.HeightRequest = combo.SizeRequest().Height;
            combo.Show();
            ebox.Add(combo);

            foreach (DeployDirectoryInfo value in values)
            {
                combo.AppendText(value.Description);
            }
        }
Пример #9
0
        public static void FillComboBoxEntry(Gtk.ComboBoxEntry combo, Dictionary <decimal, string> items, decimal currentValue, bool editable)
        {
            combo.Model = new ListStore(typeof(string));

            var resultItems = new Dictionary <decimal, string>();

            if (editable)
            {
                // adding missing to first pos
                if (!items.ContainsKey(currentValue))
                {
                    resultItems.Add(currentValue, currentValue.ToString());
                }

                foreach (var kvp in items)
                {
                    resultItems.Add(kvp.Key, kvp.Value);
                }
            }
            else
            {
                resultItems.Add(currentValue, currentValue.ToString());
            }

            var index = 0;

            foreach (var kvp in resultItems)
            {
                combo.AppendText(kvp.Value);

                if (kvp.Key == currentValue)
                {
                    combo.Active = index;
                }
                index++;
            }
        }
Пример #10
0
        public static Gtk.Window Create()
        {
            window = new Window("GtkComboBox");
            window.SetDefaultSize(200, 100);

            VBox box1 = new VBox(false, 0);

            window.Add(box1);

            VBox box2 = new VBox(false, 10);

            box2.BorderWidth = 10;
            box1.PackStart(box2, true, true, 0);

            ComboBoxEntry combo = new Gtk.ComboBoxEntry(new string[] { "Foo", "Bar" });

            combo.Changed       += new EventHandler(OnComboActivated);
            combo.Entry.Changed += new EventHandler(OnComboEntryChanged);
            box2.PackStart(combo, true, true, 0);

            HSeparator separator = new HSeparator();

            box1.PackStart(separator, false, false, 0);

            box2             = new VBox(false, 10);
            box2.BorderWidth = 10;
            box1.PackStart(box2, false, false, 0);

            Button button = new Button(Stock.Close);

            button.Clicked   += new EventHandler(OnCloseClicked);
            button.CanDefault = true;

            box2.PackStart(button, true, true, 0);
            button.GrabDefault();
            return(window);
        }
Пример #11
0
        // 
		public void Initialize (EditSession session)
		{
            prop = session.Property;
           
            ICollection valuesCollection = prop.Converter.GetStandardValues();
            values = new TraceLab.Core.Components.EnumValue[valuesCollection.Count];
            valuesCollection.CopyTo(values, 0);

			//values = System.Enum.GetValues (prop.PropertyType);
			Hashtable names = new Hashtable ();
			foreach (FieldInfo f in prop.PropertyType.GetFields ()) {
				DescriptionAttribute att = (DescriptionAttribute) Attribute.GetCustomAttribute (f, typeof(DescriptionAttribute));
				if (att != null)
					names [f.Name] = att.Description;
				else
					names [f.Name] = f.Name;
			}
				       
			
			ebox = new Gtk.EventBox ();
			ebox.Show ();
			PackStart (ebox, true, true, 0);

			combo = Gtk.ComboBoxEntry.NewText ();
			combo.Changed += combo_Changed;
			combo.Entry.IsEditable = false;
			combo.Entry.CanFocus = false;
			combo.Entry.HasFrame = false;
			combo.Entry.HeightRequest = combo.SizeRequest ().Height;
			combo.Show ();
			ebox.Add (combo);

            foreach (TraceLab.Core.Components.EnumValue value in values) {
				string str = prop.Converter.ConvertToString (value);
				if (names.Contains (str))
					str = (string) names [str];
				combo.AppendText (str);
			}
		}
Пример #12
0
		protected NoteRecentChanges (NoteManager manager)
: base (Catalog.GetString ("Search All Notes"))
		{
			this.manager = manager;
			this.IconName = "tomboy";
			this.DefaultWidth = 450;
			this.DefaultHeight = 400;
			this.current_matches = new Dictionary<string, int> ();
			this.Resizable = true;

			selected_tags = new Dictionary<Tag, Tag> ();

			AddAccelGroup (Tomboy.ActionManager.UI.AccelGroup);

			menu_bar = CreateMenuBar ();

			Gtk.Label label = new Gtk.Label (Catalog.GetString ("_Search:"));
			label.Xalign = 0.0f;

			find_combo = Gtk.ComboBoxEntry.NewText ();
			label.MnemonicWidget = find_combo;
			find_combo.Changed += OnEntryChanged;
			find_combo.Entry.ActivatesDefault = false;
			find_combo.Entry.Activated += OnEntryActivated;
			find_combo.Entry.FocusInEvent += OnEntryFocusIn;
			if (previous_searches != null) {
				foreach (string prev in previous_searches) {
					find_combo.AppendText (prev);
				}
			}

			clear_search_button = new Gtk.Button (new Gtk.Image (Gtk.Stock.Clear,
							      Gtk.IconSize.Menu));
			clear_search_button.Sensitive = false;
			clear_search_button.Clicked += ClearSearchClicked;
			clear_search_button.Show ();

			Gtk.Table table = new Gtk.Table (1, 3, false);
			table.Attach (label, 0, 1, 0, 1,
			              Gtk.AttachOptions.Fill,
			              Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill,
			              0, 0);
			table.Attach (find_combo, 1, 2, 0, 1,
			              Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill,
			              Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill,
			              0, 0);
			table.Attach (clear_search_button,
				      2, 3, 0, 1,
			              Gtk.AttachOptions.Fill,
			              Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill,
			              0, 0);
			table.ColumnSpacing = 4;
			table.ShowAll ();

			Gtk.HBox hbox = new Gtk.HBox (false, 0);
			hbox.PackStart (table, true, true, 0);
			hbox.ShowAll ();

			// Notebooks Pane
			Gtk.Widget notebooksPane = MakeNotebooksPane ();
			notebooksPane.Show ();

			MakeRecentTree ();
			tree.Show ();

			status_bar = new Gtk.Statusbar ();
			status_bar.HasResizeGrip = true;
			status_bar.Show ();

			// Update on changes to notes
			manager.NoteDeleted += OnNotesDeleted;
			manager.NoteAdded += OnNotesChanged;
			manager.NoteRenamed += OnNoteRenamed;
			manager.NoteSaved += OnNoteSaved;

			// List all the current notes
			UpdateResults ();

			matches_window = new Gtk.ScrolledWindow ();
			matches_window.ShadowType = Gtk.ShadowType.In;

			matches_window.HscrollbarPolicy = Gtk.PolicyType.Automatic;
			matches_window.VscrollbarPolicy = Gtk.PolicyType.Automatic;
			matches_window.Add (tree);
			matches_window.Show ();

			hpaned = new Gtk.HPaned ();
			hpaned.Position = 150;
			hpaned.Add1 (notebooksPane);
			hpaned.Add2 (matches_window);
			hpaned.Show ();

			RestorePosition ();

			Gtk.VBox vbox = new Gtk.VBox (false, 8);
			vbox.BorderWidth = 6;
			vbox.PackStart (hbox, false, false, 4);
			vbox.PackStart (hpaned, true, true, 0);
			vbox.PackStart (status_bar, false, false, 0);
			vbox.Show ();

			// Use another VBox to place the MenuBar
			// right at thetop of the window.
			content_vbox = new Gtk.VBox (false, 0);
#if !MAC
			content_vbox.PackStart (menu_bar, false, false, 0);
#endif
			content_vbox.PackStart (vbox, true, true, 0);
			content_vbox.Show ();

			this.Add (content_vbox);
			this.DeleteEvent += OnDelete;
			this.KeyPressEvent += OnKeyPressed; // For Escape

			// Watch when notes are added to notebooks so the search
			// results will be updated immediately instead of waiting
			// until the note's QueueSave () kicks in.
			Notebooks.NotebookManager.NoteAddedToNotebook += OnNoteAddedToNotebook;
			Notebooks.NotebookManager.NoteRemovedFromNotebook += OnNoteRemovedFromNotebook;
			
			// Set the focus chain for the top-most containers Bug #512175
			Gtk.Widget[] vbox_focus = new Gtk.Widget[2];
			vbox_focus[0] = hbox;
			vbox_focus[1] = hpaned;
			vbox.FocusChain = vbox_focus;

			// Set focus chain for sub widgits of first top-most container
			Gtk.Widget[] table_focus = new Gtk.Widget[2];
			table_focus[0] = find_combo;
			table_focus[1] = matches_window;
			hbox.FocusChain = table_focus;
			
			// set focus chain for sub widgits of seconf top-most container
			Gtk.Widget[] hpaned_focus = new Gtk.Widget[2];
			hpaned_focus[0] = matches_window;
			hpaned_focus[1] = notebooksPane;
			hpaned.FocusChain = hpaned_focus;
			
			// get back to the beginning of the focus chain
			Gtk.Widget[] scroll_right = new Gtk.Widget[1];
			scroll_right[0] = tree;
			matches_window.FocusChain = scroll_right;
			
			Tomboy.ExitingEvent += OnExitingEvent;
		}