public GfaxSendPhoneBook(Glade.XML xml, string myparent) { //Phonebook[] pb; delete me //gxml = xml; //parent = myparent; delete me myPhoneBooks = Phonetools.get_phonebooks(); if (myPhoneBooks == null) { G_Message m = new G_Message(Catalog.GetString("You don't have any phone books yet.")); m = null; return; } gsxml = new Glade.XML(null, "send-druid.glade", "PhbookDialog", null); gsxml.Autoconnect(this); // Get the widget so we can manipulate it //phbd = (Gtk.Dialog) gsxml.GetWidget("PhbookDialog"); //book = (Gtk.TreeView) gsxml.GetWidget("book_treeview"); //list = (Gtk.TreeView) gsxml.GetWidget("list_treeview"); phbd = PhbookDialog; book = book_treeview; list = list_treeview; book.Selection.Changed += new EventHandler(on_book_treeview_selection); phbd.Resizable = true; book_store = new ListStore(typeof(string)); book.HeadersVisible = false; book.Selection.Mode = SelectionMode.Multiple; bs = new G_ListView(book, book_store); // Got have a column title or things won't show up bs.AddColumnTitle(Catalog.GetString("Phone books"), 0, COLUMN_0); list_store = new ListStore( typeof(string), typeof(string), typeof(string)); ls = new G_ListView(list, list_store); ls.AddColumnTitle(Catalog.GetString("Organization"), 0, COLUMN_0); ls.AddColumnTitle(Catalog.GetString("Phone Number"), 1, COLUMN_1); ls.AddColumnTitle(Catalog.GetString("Contact"), 2, COLUMN_2); list.HeadersVisible = true; list.Selection.Mode = SelectionMode.Multiple; // populate the list foreach (Phonebook p in myPhoneBooks) { bs.AddTextToRow(p.Name); } phbd.Run(); }
bool pbIsReadOnly = false; //wether current phone book is no editable. public GfaxPhonebook() { myPhoneBooks = Phonetools.get_phonebooks(); Application.Init(); gxml = new Glade.XML(null, "send-druid.glade", "PhbookWindow", null); gxml.Autoconnect(this); ItemStore = new ListStore(typeof(string), typeof(string), typeof(string)); ItemView = new G_ListView(ItemTreeview, ItemStore); ItemView.AddColumnTitle(Catalog.GetString("Organization"), 0, COLUMN_0); ItemView.AddColumnTitle(Catalog.GetString("Phone Number"), 1, COLUMN_1); ItemView.AddColumnTitle(Catalog.GetString("Contact"), 2, COLUMN_2); ItemTreeview.HeadersVisible = true; //ItemTreeview.Selection.Mode = SelectionMode.Multiple; ItemTreeview.Selection.Changed += new EventHandler(on_ItemTreeview_selection); // Populate the drop down combo box with phonebooks and populate // the list with the first phonebook. // TODO sort these alphabetically if (myPhoneBooks.Length > 0) { string[] list = new string[myPhoneBooks.Length]; if (myPhoneBooks != null) { // populate the list int i = 0; PhonebookComboBox.RemoveText(0); foreach (Phonebook p in myPhoneBooks) { list[i++] = p.Name; PhonebookComboBox.AppendText(p.Name); } PhonebookComboBox.Active = 0; } //Console.WriteLine(list[PhonebookComboBox.Active]); DeletePhonebookButton.Sensitive = true; } else { DeletePhonebookButton.Sensitive = false; } SaveCloseButton.Sensitive = false; UpdateButton.Sensitive = false; ClearButton.Sensitive = false; AddButton.Sensitive = false; Application.Run(); }
//--------- end of menu ----------------- private void on_NewPhonebookButton_clicked(object o, EventArgs args) { // Unselect any phone book otherwise we get gtk errors. ItemTreeview.Selection.UnselectAll(); // run the wizard NewPhoneBook nphb = new NewPhoneBook(); nphb.Run(); if (nphb.PhoneBookNames.Count > 0) // don't do this if cancelled { IEnumerator enu = nphb.PhoneBookNames.GetEnumerator(); while (enu.MoveNext()) { Phonebook ph = new Phonebook(); if (nphb.PhoneBookType == "gfax") { ph.Path = gfax.ConfigDirectory + "/" + (string)enu.Current; } else { ph.Path = ""; } ph.Name = (string)enu.Current; // get the new book name ph.Type = nphb.PhoneBookType; Phonetools.add_book(ph); PhonebookComboBox.AppendText(ph.Name); } // Reload the phone books myPhoneBooks = Phonetools.get_phonebooks(); if (myPhoneBooks.Length > 0) { //PhonebookComboBox.AppendText(ph.Name); PhonebookComboBox.Active = 0; DeletePhonebookButton.Sensitive = true; } } nphb = null; }
private void on_DeletePhonebookButton_clicked(object o, EventArgs args) { if (myPhoneBooks.Length > 0) { string[] list = new string[myPhoneBooks.Length]; if (myPhoneBooks != null) { // populate the list int i = 0; foreach (Phonebook pb in myPhoneBooks) { list[i++] = pb.Name; } } string book = list[PhonebookComboBox.Active]; MessageDialog md = new MessageDialog( null, DialogFlags.DestroyWithParent, MessageType.Question, ButtonsType.YesNo, Catalog.GetString("Are you sure you want to delete the phone book?") ); ResponseType result = (ResponseType)md.Run(); if (result == ResponseType.Yes) { md.Destroy(); if (book == null) { return; } Phonetools.delete_book(book); PhonebookComboBox.RemoveText(PhonebookComboBox.Active); ItemStore.Clear(); myPhoneBooks = Phonetools.get_phonebooks(); if (myPhoneBooks.Length > 0) { // now reload PhonebookComboBox.Active = 0; on_PhonebookComboBox_changed(null, null); } else { DeletePhonebookButton.Sensitive = false; PhonebookComboBox.InsertText(0, " "); } PhonebookComboBox.Active = 0; } else { md.Destroy(); } } }