using System; using Gtk; using UI = Gtk.Builder.ObjectAttribute; namespace Buypeeb { class MainWindow : Window { public MainWindow() : this(new Builder("ui.glade")) { } private MainWindow(Builder builder) : base(builder.GetObject("wndMain").Handle) { builder.Autoconnect(this); DeleteEvent += Window_Shutdown; } private void Window_Shutdown(object sender, DeleteEventArgs args) { Application.Quit(); } // convenience functions private (Boolean accepted, string response) EntryDialogue(string title = "Buypeeb", string message = "Hi there!") { Dialog ed = new Dialog(title, null, Gtk.DialogFlags.DestroyWithParent, "Cancel", ResponseType.Cancel, "OK", ResponseType.Ok); Label edLabel = new Label(message); Entry edEntry = new Entry(); ed.ContentArea.PackStart(edLabel, true, true, 2); edLabel.Show(); ed.ContentArea.PackStart(edEntry, true, true, 10); edEntry.Show(); // TODO: pressing enter should submit the form ResponseType accepted = (ResponseType)ed.Run(); string response = edEntry.Text; ed.Destroy(); return (accepted == ResponseType.Ok, response); } // button handlers private void ButtonAddClicked(object sender, EventArgs a) { Console.WriteLine("ButtonAddClicked"); var EntryResponse = EntryDialogue(); Console.WriteLine(EntryResponse.response); } private void ButtonUpdateAllClicked(object sender, EventArgs a) { Console.WriteLine("ButtonUpdateAllClicked"); } private void ButtonClearEndedClicked(object sender, EventArgs a) { Console.WriteLine("ButtonClearEndedClicked"); } private void ButtonClearAllClicked(object sender, EventArgs a) { Console.WriteLine("ButtonClearAllClicked"); } private void ButtonSaveClicked(object sender, EventArgs a) { Console.WriteLine("ButtonSaveClicked"); } private void ButtonQuitClicked(object sender, EventArgs a) { MessageDialog md = new MessageDialog(null, DialogFlags.DestroyWithParent, MessageType.Question, ButtonsType.OkCancel, "Are you sure you want to quit?"); ResponseType response = (ResponseType)md.Run(); md.Destroy(); if (response == ResponseType.Ok) { Application.Quit(); } } private void tveItemsSelectionChanged(object sender, EventArgs a) { Console.WriteLine("tveItemsSelectionChanged"); } private void ButtonViewBuyeeClicked(object sender, EventArgs a) { Console.WriteLine("ButtonViewBuyeeClicked"); } private void ButtonViewYahooClicked(object sender, EventArgs a) { Console.WriteLine("ButtonViewYahooClicked"); } private void ButtonSelectedRemoveClicked(object sender, EventArgs a) { Console.WriteLine("ButtonSelectedRemoveClicked"); } private void ButtonSelectedRenameClicked(object sender, EventArgs a) { Console.WriteLine("ButtonSelectedRenameClicked"); } } }