mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2025-01-11 07:05:29 +00:00
gtk: Facilitate use of ComboBox and ComboBoxText with an Entry
Add ComboBox[Text] (bool with_entry) protected constructors to allow subclasses with an Entry. Add an Entry property for easy access to the Entry child widget. Also remove the unused gtk/ComboBoxEntry.custom.
This commit is contained in:
parent
c28312f826
commit
bef589e836
|
@ -30,6 +30,26 @@
|
||||||
store.AppendValues (entry);
|
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)
|
public void SetAttributes (CellRenderer cell, params object[] attrs)
|
||||||
{
|
{
|
||||||
if (attrs.Length % 2 != 0)
|
if (attrs.Length % 2 != 0)
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
// Gtk.ComboBoxEntry.custom - Gtk ComboBoxEntry customizations
|
// ComboBoxText.custom - Gtk ComboBoxText customizations
|
||||||
//
|
//
|
||||||
// Authors: Mike Kestner <mkestner@novell.com>
|
// Authors: Bertrand Lorentz <bertrand.lorentz@gmail.com>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2005 Novell, Inc.
|
// Copyright (c) 2011 Bertrand Lorentz
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the Lesser GNU General
|
// 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,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// 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)
|
if (GetType () != typeof (ComboBoxText)) {
|
||||||
AppendText (entry);
|
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 {
|
public Gtk.Entry Entry {
|
||||||
|
@ -29,3 +37,4 @@
|
||||||
return (Gtk.Entry)Child;
|
return (Gtk.Entry)Child;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ customs = \
|
||||||
ColorSelection.custom \
|
ColorSelection.custom \
|
||||||
ColorSelectionDialog.custom \
|
ColorSelectionDialog.custom \
|
||||||
ComboBox.custom \
|
ComboBox.custom \
|
||||||
ComboBoxEntry.custom \
|
ComboBoxText.custom \
|
||||||
Container.custom \
|
Container.custom \
|
||||||
Dialog.custom \
|
Dialog.custom \
|
||||||
Drag.custom \
|
Drag.custom \
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace WidgetViewer {
|
||||||
combo.AppendText ("Foo");
|
combo.AppendText ("Foo");
|
||||||
combo.AppendText ("Bar");
|
combo.AppendText ("Bar");
|
||||||
combo.Changed += new EventHandler (OnComboActivated);
|
combo.Changed += new EventHandler (OnComboActivated);
|
||||||
((Entry)combo.Child).Changed += new EventHandler (OnComboEntryChanged);
|
combo.Entry.Changed += new EventHandler (OnComboEntryChanged);
|
||||||
box2.PackStart (combo, true, true, 0);
|
box2.PackStart (combo, true, true, 0);
|
||||||
|
|
||||||
HSeparator separator = new HSeparator ();
|
HSeparator separator = new HSeparator ();
|
||||||
|
|
Loading…
Reference in a new issue