All pastes #1850178 Raw Edit

diego

public text v1 · immutable
#1850178 ·published 2010-03-23 11:19 UTC
rendered paste body
/* vim: set sw=2 ts=2 sts=2 et: */using Gtk;struct SearchEngine {  public string name;  public string url;  public string icon;}public class EphyLocationPlus : Gtk.Entry{  SearchEngine[] engines = {      SearchEngine () { name = "Google", url = "www.google.com",                        icon = "face-wink" },      SearchEngine () { name = "Youtube", url = "www.youtube.com",                        icon = "face-smile" },    };  private void icon_press_cb (Gtk.EntryIconPosition pos, Gdk.Event event)  {    var menu = new Gtk.Menu ();    foreach (var engine in this.engines)    {      var item = new Gtk.ImageMenuItem.with_label (engine.name);      item.activate.connect (() =>      {        this.set_text (engine.url);        this.set_icon_from_icon_name (Gtk.EntryIconPosition.PRIMARY,                                      engine.icon);      });      menu.append (item);      item.show_all ();    }    menu.popup (null, null, null,                event.button.button, Gtk.get_current_event_time ());  }  public EphyLocationPlus ()  {    this.set_icon_from_icon_name (Gtk.EntryIconPosition.PRIMARY, "face-angel");    this.icon_press.connect (icon_press_cb);  }}int main (string[] args){  Gtk.init (ref args);  var window = new Gtk.Window (Gtk.WindowType.TOPLEVEL);  window.title = "ELP";  window.set_default_size (300, 50);  window.position = Gtk.WindowPosition.CENTER;  window.destroy.connect (Gtk.main_quit);  window.add (new EphyLocationPlus ());  window.show_all ();  Gtk.main ();  return 0;}