I have an item list and I want to put a text input:
using Gtk;
public class TreeViewSample : Window {
public TreeViewSample () {
this.title = "Programa de odontologia";
set_default_size (500,500);
var view = new TreeView ();
setup_treeview (view);
add (view);
this.destroy.connect (Gtk.main_quit);
// The Entry:
Gtk.Entry entry = new Gtk.Entry ();
this.add (entry);
// Add a default-text:
entry.set_text ("hello, world!");
// Add a delete-button:
entry.set_icon_from_icon_name (Gtk.EntryIconPosition.SECONDARY, "edit-clear");
entry.icon_press.connect ((pos, event) => {
if (pos == Gtk.EntryIconPosition.SECONDARY) {
entry.set_text ("");
}
});
// Print text to stdout on enter:
entry.activate.connect (() => {
unowned string str = entry.get_text ();
stdout.printf ("%s\n", str);
});
}
private void setup_treeview (TreeView view) {
/*
* Use ListStore to hold accountname, accounttype, balance and
* color attribute. For more info on how TreeView works take a
* look at the GTK+ API.
*/
var listmodel = new ListStore (5, typeof (string), typeof (string),
typeof (string), typeof (string), typeof (string));
view.set_model (listmodel);
view.insert_column_with_attributes (-1, "Nombre del paciente", new CellRendererText (), "text", 0);
view.insert_column_with_attributes (-1, "Apellido", new CellRendererText (), "text", 1);
view.insert_column_with_attributes (-1, "Tratamiento", new CellRendererText (), "text", 2);
var cell = new CellRendererText ();
cell.set ("foreground_set", true);
view.insert_column_with_attributes (-1, "Lo que debe", cell, "text", 3, "foreground", 4);
TreeIter iter;
listmodel.append (out iter);
listmodel.set (iter, 0, "Agustin", 1, "Gomez", 3, "0", 2, "conducto", 4, "blue");
listmodel.append (out iter);
listmodel.set (iter, 0, "Laura", 1, "Gomez", 3, "$100", 2, "conducto", 4, "red");
listmodel.append (out iter);
listmodel.set (iter, 0, "Luis", 1, "Gomez", 3, "$400", 2, "conducto", 4, "green");
}
public static int main (string[] args) {
Gtk.init (ref args);
var sample = new TreeViewSample ();
sample.show_all ();
Gtk.main ();
return 0;
}
}