コード例 #1
0
        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();
        }
コード例 #2
0
ファイル: gfaxphonebook.cs プロジェクト: horga83/gfax
        private void on_PhonebookComboBox_changed(object o, EventArgs args)
        {
            ArrayList contacts = null;
            Phonebook p;

            // get the first book in the list and load the liststore
            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;
                    }
                }

                p = Phonetools.get_book_from_name(list[PhonebookComboBox.Active]);
                if (p == null)
                {
                    return;
                }

                // Clear the list_store
                ItemStore.Clear();

                contacts = Phonetools.get_contacts(p);

                if (contacts != null)
                {
                    IEnumerator enu = contacts.GetEnumerator();
                    while (enu.MoveNext())
                    {
                        GfaxContact c = new GfaxContact();
                        c = (GfaxContact)enu.Current;
                        ItemView.AddTextToRow(c.Organization, c.PhoneNumber, c.ContactPerson);
                    }
                    if (p.Type == "evolution")
                    {
                        pbIsReadOnly = true;
                        EditPhbCompanyEntry.Sensitive = false;
                        EditPhbNumberEntry.Sensitive  = false;
                        EditPhbNameEntry.Sensitive    = false;
                    }
                    else
                    {
                        pbIsReadOnly = false;
                        EditPhbCompanyEntry.Sensitive = true;
                        EditPhbNumberEntry.Sensitive  = true;
                        EditPhbNameEntry.Sensitive    = true;
                        eventsEnabled = true;
                    }
                }
            }
        }
コード例 #3
0
        private void on_ok_button_clicked(object o, EventArgs args)
        {
            ArrayList lsdest   = new ArrayList();
            ArrayList bsdest   = new ArrayList();
            ArrayList contacts = new ArrayList();

            lsdest = ls.GetSelections(ALL_COLUMNS);

            // if there are indiviual entries don't do entire phonebooks
            if (lsdest.Count > 0)
            {
                IEnumerator enu = lsdest.GetEnumerator();
                while (enu.MoveNext())
                {
                    GfaxContact c = new GfaxContact();
                    c.Organization = (string)enu.Current;
                    enu.MoveNext();
                    c.PhoneNumber = (string)enu.Current;
                    enu.MoveNext();
                    c.ContactPerson = (string)enu.Current;
                    gfax.Destinations.Add(c);
                }
            }
            else
            {
                bsdest = bs.GetSelections(COLUMN_0);
                if (bsdest.Count > 0)
                {
                    IEnumerator enu = bsdest.GetEnumerator();
                    while (enu.MoveNext())
                    {
                        foreach (Phonebook p in myPhoneBooks)
                        {
                            if (p.Name == (string)enu.Current)
                            {
                                contacts = Phonetools.get_contacts(p);
                            }
                        }

                        // add contacts to global desinations
                        if (contacts.Count > 0)
                        {
                            IEnumerator enuc = contacts.GetEnumerator();
                            while (enuc.MoveNext())
                            {
                                gfax.Destinations.Add((GfaxContact)enuc.Current);
                            }
                        }
                    }
                }
            }

            phbd.Destroy();
        }
コード例 #4
0
ファイル: gfaxphonebook.cs プロジェクト: horga83/gfax
        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();
        }
コード例 #5
0
ファイル: gfaxphonebook.cs プロジェクト: horga83/gfax
        private void on_SaveCloseButton_clicked(object o, EventArgs args)
        {
            ArrayList rows;
            ArrayList contacts = new ArrayList();
            string    book;

            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;
                    }
                }
                book = list[PhonebookComboBox.Active];

                // just get all items and save
                SaveCloseButton.Sensitive = false;
                //eventsEnabled = false;
                EditPhbCompanyEntry.Text = "";
                EditPhbNumberEntry.Text  = "";
                EditPhbNameEntry.Text    = "";

                rows = ItemView.GetAllRows();

                IEnumerator enu = rows.GetEnumerator();
                while (enu.MoveNext())
                {
                    GfaxContact c = new GfaxContact();
                    c.Organization  = ((string[])enu.Current)[0];
                    c.PhoneNumber   = ((string[])enu.Current)[1];
                    c.ContactPerson = ((string[])enu.Current)[2];
                    contacts.Add(c);
                }

                Phonetools.save_phonebook_items(book, contacts);
                //EditPhbList.Selection.UnselectAll();
            }

            PhbookWindow.Destroy();
            Application.Quit();
        }
コード例 #6
0
ファイル: gfaxphonebook.cs プロジェクト: horga83/gfax
        //--------- 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;
        }
コード例 #7
0
        // loads the phone book into list_store
        private void load_phone_book(Phonebook p)
        {
            ArrayList contacts = null;

            // Clear the list_store
            list_store.Clear();

            contacts = Phonetools.get_contacts(p);
            if (contacts == null)
            {
                return;
            }

            IEnumerator enu = contacts.GetEnumerator();

            while (enu.MoveNext())
            {
                GfaxContact c = new GfaxContact();
                c = (GfaxContact)enu.Current;
                ls.AddTextToRow(c.Organization, c.PhoneNumber, c.ContactPerson);
            }
        }
コード例 #8
0
ファイル: gfaxphonebook.cs プロジェクト: horga83/gfax
        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();
                }
            }
        }