diff --git a/gtk/ComboBox.custom b/gtk/ComboBox.custom index c41b473de..cf5040453 100644 --- a/gtk/ComboBox.custom +++ b/gtk/ComboBox.custom @@ -30,6 +30,26 @@ store.AppendValues (entry); } + protected ComboBox (bool with_entry) : base (IntPtr.Zero) + { + if (GetType () != typeof (ComboBox)) { + CreateNativeObject (new string [0], new GLib.Value[0]); + return; + } + + if (with_entry) { + Raw = gtk_combo_box_new_with_entry (); + } else { + Raw = gtk_combo_box_new (); + } + } + + public Gtk.Entry Entry { + get { + return (Gtk.Entry)Child; + } + } + public void SetAttributes (CellRenderer cell, params object[] attrs) { if (attrs.Length % 2 != 0) diff --git a/gtk/ComboBoxEntry.custom b/gtk/ComboBoxText.custom similarity index 61% rename from gtk/ComboBoxEntry.custom rename to gtk/ComboBoxText.custom index 7593ceb82..c891084a3 100644 --- a/gtk/ComboBoxEntry.custom +++ b/gtk/ComboBoxText.custom @@ -1,8 +1,8 @@ -// Gtk.ComboBoxEntry.custom - Gtk ComboBoxEntry customizations +// ComboBoxText.custom - Gtk ComboBoxText customizations // -// Authors: Mike Kestner +// Authors: Bertrand Lorentz // -// Copyright (c) 2005 Novell, Inc. +// Copyright (c) 2011 Bertrand Lorentz // // This program is free software; you can redistribute it and/or // modify it under the terms of version 2 of the Lesser GNU General @@ -18,10 +18,18 @@ // Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. - public ComboBoxEntry (string[] entries) : this (new ListStore (typeof (string)), 0) + protected ComboBoxText (bool with_entry) : base (IntPtr.Zero) { - foreach (string entry in entries) - AppendText (entry); + if (GetType () != typeof (ComboBoxText)) { + CreateNativeObject (new string [0], new GLib.Value[0]); + return; + } + + if (with_entry) { + Raw = gtk_combo_box_text_new_with_entry (); + } else { + Raw = gtk_combo_box_text_new (); + } } public Gtk.Entry Entry { @@ -29,3 +37,4 @@ return (Gtk.Entry)Child; } } + diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 47aa6edd4..c3cb221cd 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -54,7 +54,7 @@ customs = \ ColorSelection.custom \ ColorSelectionDialog.custom \ ComboBox.custom \ - ComboBoxEntry.custom \ + ComboBoxText.custom \ Container.custom \ Dialog.custom \ Drag.custom \ diff --git a/sample/test/TestComboBox.cs b/sample/test/TestComboBox.cs index a48a54ca3..5ec5c60e3 100644 --- a/sample/test/TestComboBox.cs +++ b/sample/test/TestComboBox.cs @@ -29,7 +29,7 @@ namespace WidgetViewer { combo.AppendText ("Foo"); combo.AppendText ("Bar"); combo.Changed += new EventHandler (OnComboActivated); - ((Entry)combo.Child).Changed += new EventHandler (OnComboEntryChanged); + combo.Entry.Changed += new EventHandler (OnComboEntryChanged); box2.PackStart (combo, true, true, 0); HSeparator separator = new HSeparator ();