Support for changing which addressbook is used.
authorepage <eopage@byu.net>
Sat, 9 Aug 2008 17:09:35 +0000 (17:09 +0000)
committerepage <eopage@byu.net>
Sat, 9 Aug 2008 17:09:35 +0000 (17:09 +0000)
git-svn-id: file:///svnroot/gc-dialer/trunk@128 c39d3808-3fe2-4d86-a59f-b7f623ee9f21

Makefile
src/evo_backend.py
src/gc_backend.py
src/gc_dialer.glade
src/gc_dialer.py

index e3758ab..a90e9fd 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -26,7 +26,8 @@ DEB_PACKAGE=$(PACKAGE_PATH)/$(PROJECT_NAME)-$(PROJECT_VERSION)_$(PLATFORM).deb
 DEBUGGER=winpdb
 UNIT_TEST=nosetests -w $(TEST_PATH)
 STYLE_TEST=../../Python/tools/pep8.py --ignore=W191
-LINT=pylint --rcfile=./support/pylint.rc
+LINT_RC=./support/pylint.rc
+LINT=pylint --rcfile=$(LINT_RC)
 COVERAGE_TEST=figleaf
 PROFILER=pyprofiler
 CTAGS=ctags-exuberant
@@ -133,7 +134,7 @@ $(TAG_FILE): $(SOURCE)
        mkdir -p $(dir $(TAG_FILE))
        $(CTAGS) -o $(TAG_FILE) $(SOURCE)
 
-%1.stats: $(SOURCE)
+%1.stats: $(SOURCE) $(LINT_RC)
        @ #DESIRED DEPENDENCY: $(subst .,/,$(notdir $*)).py
        @ #DESIRED COMMAND: $(LINT) $<
        @ $(LINT) $(subst .,/,$(notdir $*)).py
index 96d921a..04388bf 100644 (file)
@@ -37,7 +37,7 @@ class EvolutionAddressBook(object):
 
                self._phoneTypes = None
                self._bookId = bookId if bookId is not None else self.get_addressbooks().next()[1]
-               self._book = evolution.ebook.open_addressbook(self._bookId[1])
+               self._book = evolution.ebook.open_addressbook(self._bookId)
        
        @classmethod
        def is_supported(cls):
@@ -51,13 +51,16 @@ class EvolutionAddressBook(object):
                        return
 
                for bookId in evolution.ebook.list_addressbooks():
-                       yield self, bookId, bookId[0]
+                       yield self, bookId[1], bookId[0]
        
        def open_addressbook(self, bookId):
                self._bookId = bookId
-               self._book = evolution.ebook.open_addressbook(self._bookId[1])
+               self._book = evolution.ebook.open_addressbook(self._bookId)
                return self
 
+       def factory_name(self):
+               return "Evo"
+
        def get_contacts(self):
                """
                @returns Iterable of (contact id, contact name)
index f7d90b6..591c0dd 100644 (file)
@@ -262,11 +262,14 @@ class GCDialer(object):
                """
                @returns Iterable of (Address Book Factory, Book Id, Book Name)
                """
-               yield self, None, "Grand Central"
+               yield self, "", "Grand Central"
        
        def open_addressbook(self, bookId):
                return self
 
+       def factory_name(self):
+               return "GC"
+
        def get_contacts(self):
                """
                @returns Iterable of (contact id, contact name)
index 3f943f2..3646164 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.5 on Thu Aug  7 21:12:53 2008 -->
+<!--Generated with glade3 3.4.5 on Sat Aug  9 10:42:47 2008 -->
 <glade-interface>
   <widget class="GtkWindow" id="Dialpad">
     <property name="width_request">400</property>
                         <signal name="activate" handler="on_clear_number"/>
                       </widget>
                     </child>
+                    <child>
+                      <widget class="GtkSeparatorMenuItem" id="separatormenuitem2">
+                        <property name="visible">True</property>
+                      </widget>
+                    </child>
+                    <child>
+                      <widget class="GtkImageMenuItem" id="settings_menu_item">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">gtk-preferences</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                        <signal name="activate" handler="on_settings"/>
+                      </widget>
+                    </child>
                   </widget>
                 </child>
               </widget>
                     <property name="n_columns">3</property>
                     <property name="homogeneous">True</property>
                     <child>
-                      <widget class="GtkButton" id="dial">
+                      <widget class="GtkButton" id="digit1">
                         <property name="visible">True</property>
-                        <property name="has_default">True</property>
                         <property name="focus_on_click">False</property>
                         <property name="response_id">0</property>
-                        <signal name="clicked" handler="on_dial_clicked"/>
-                        <accelerator key="Return" modifiers="" signal="clicked"/>
+                        <signal name="clicked" handler="on_digit_clicked"/>
+                        <accelerator key="1" modifiers="" signal="clicked"/>
                         <child>
-                          <widget class="GtkHBox" id="hbox1">
+                          <widget class="GtkLabel" id="label12">
                             <property name="visible">True</property>
-                            <child>
-                              <widget class="GtkImage" id="image1">
-                                <property name="visible">True</property>
-                                <property name="xalign">1</property>
-                                <property name="stock">gtk-yes</property>
-                              </widget>
-                            </child>
-                            <child>
-                              <widget class="GtkLabel" id="label8">
-                                <property name="visible">True</property>
-                                <property name="xalign">0</property>
-                                <property name="xpad">5</property>
-                                <property name="label" translatable="yes">&lt;span size="17000" weight="bold"&gt;Dial&lt;/span&gt;</property>
-                                <property name="use_markup">True</property>
-                              </widget>
-                              <packing>
-                                <property name="position">1</property>
-                              </packing>
-                            </child>
+                            <property name="label" translatable="yes">&lt;span size="33000" weight="bold"&gt;1&lt;/span&gt;
+&lt;span size="9000"&gt;  &lt;/span&gt;</property>
+                            <property name="use_markup">True</property>
                           </widget>
                         </child>
                       </widget>
-                      <packing>
-                        <property name="left_attach">2</property>
-                        <property name="right_attach">3</property>
-                        <property name="top_attach">3</property>
-                        <property name="bottom_attach">4</property>
-                      </packing>
                     </child>
                     <child>
-                      <widget class="GtkButton" id="digit0">
+                      <widget class="GtkButton" id="digit2">
                         <property name="visible">True</property>
                         <property name="focus_on_click">False</property>
                         <property name="response_id">0</property>
                         <signal name="clicked" handler="on_digit_clicked"/>
-                        <accelerator key="0" modifiers="" signal="clicked"/>
+                        <accelerator key="2" modifiers="" signal="clicked"/>
+                        <accelerator key="a" modifiers="" signal="clicked"/>
+                        <accelerator key="b" modifiers="" signal="clicked"/>
+                        <accelerator key="c" modifiers="" signal="clicked"/>
                         <child>
-                          <widget class="GtkLabel" id="label19">
+                          <widget class="GtkLabel" id="label10">
                             <property name="visible">True</property>
-                            <property name="label" translatable="yes">&lt;span size="33000" weight="bold"&gt;0&lt;/span&gt;
-&lt;span size="9000"&gt;&lt;/span&gt;</property>
+                            <property name="label" translatable="yes">&lt;span size="30000" weight="bold"&gt;2&lt;/span&gt;
+&lt;span size="12000"&gt;ABC&lt;/span&gt;</property>
                             <property name="use_markup">True</property>
                             <property name="justify">GTK_JUSTIFY_CENTER</property>
                           </widget>
                       <packing>
                         <property name="left_attach">1</property>
                         <property name="right_attach">2</property>
-                        <property name="top_attach">3</property>
-                        <property name="bottom_attach">4</property>
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkButton" id="back">
-                        <property name="visible">True</property>
-                        <property name="focus_on_click">False</property>
-                        <property name="response_id">0</property>
-                        <signal name="clicked" handler="on_back_clicked"/>
-                        <accelerator key="BackSpace" modifiers="" signal="clicked"/>
-                        <child>
-                          <widget class="GtkHBox" id="hbox2">
-                            <property name="visible">True</property>
-                            <child>
-                              <widget class="GtkImage" id="image2">
-                                <property name="visible">True</property>
-                                <property name="xalign">1</property>
-                                <property name="stock">gtk-no</property>
-                              </widget>
-                            </child>
-                            <child>
-                              <widget class="GtkLabel" id="label9">
-                                <property name="visible">True</property>
-                                <property name="xalign">0</property>
-                                <property name="xpad">5</property>
-                                <property name="label" translatable="yes">&lt;span size="17000" weight="Bold"&gt;Back&lt;/span&gt;</property>
-                                <property name="use_markup">True</property>
-                              </widget>
-                              <packing>
-                                <property name="position">1</property>
-                              </packing>
-                            </child>
-                          </widget>
-                        </child>
-                      </widget>
-                      <packing>
-                        <property name="top_attach">3</property>
-                        <property name="bottom_attach">4</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <widget class="GtkButton" id="digit9">
+                      <widget class="GtkButton" id="digit3">
                         <property name="visible">True</property>
                         <property name="focus_on_click">False</property>
                         <property name="response_id">0</property>
                         <signal name="clicked" handler="on_digit_clicked"/>
-                        <accelerator key="z" modifiers="" signal="clicked"/>
-                        <accelerator key="y" modifiers="" signal="clicked"/>
-                        <accelerator key="x" modifiers="" signal="clicked"/>
-                        <accelerator key="w" modifiers="" signal="clicked"/>
-                        <accelerator key="9" modifiers="" signal="clicked"/>
+                        <accelerator key="3" modifiers="" signal="clicked"/>
+                        <accelerator key="d" modifiers="" signal="clicked"/>
+                        <accelerator key="e" modifiers="" signal="clicked"/>
+                        <accelerator key="f" modifiers="" signal="clicked"/>
                         <child>
-                          <widget class="GtkLabel" id="label18">
+                          <widget class="GtkLabel" id="label11">
                             <property name="visible">True</property>
-                            <property name="label" translatable="yes">&lt;span size="30000" weight="bold"&gt;9&lt;/span&gt;
-&lt;span size="12000"&gt;WXYZ&lt;/span&gt;</property>
+                            <property name="label" translatable="yes">&lt;span size="30000" weight="bold" stretch="ultraexpanded"&gt;3&lt;/span&gt;
+&lt;span size="12000"&gt;DEF&lt;/span&gt;</property>
                             <property name="use_markup">True</property>
                             <property name="justify">GTK_JUSTIFY_CENTER</property>
                           </widget>
                       <packing>
                         <property name="left_attach">2</property>
                         <property name="right_attach">3</property>
-                        <property name="top_attach">2</property>
-                        <property name="bottom_attach">3</property>
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkButton" id="digit8">
+                      <widget class="GtkButton" id="digit4">
                         <property name="visible">True</property>
                         <property name="focus_on_click">False</property>
                         <property name="response_id">0</property>
                         <signal name="clicked" handler="on_digit_clicked"/>
-                        <accelerator key="v" modifiers="" signal="clicked"/>
-                        <accelerator key="u" modifiers="" signal="clicked"/>
-                        <accelerator key="t" modifiers="" signal="clicked"/>
-                        <accelerator key="8" modifiers="" signal="clicked"/>
+                        <accelerator key="4" modifiers="" signal="clicked"/>
+                        <accelerator key="g" modifiers="" signal="clicked"/>
+                        <accelerator key="h" modifiers="" signal="clicked"/>
+                        <accelerator key="i" modifiers="" signal="clicked"/>
                         <child>
-                          <widget class="GtkLabel" id="label17">
+                          <widget class="GtkLabel" id="label13">
                             <property name="visible">True</property>
-                            <property name="label" translatable="yes">&lt;span size="30000" weight="bold"&gt;8&lt;/span&gt;
-&lt;span size="12000"&gt;TUV&lt;/span&gt;</property>
+                            <property name="label" translatable="yes">&lt;span size="30000" weight="bold"&gt;4&lt;/span&gt;
+&lt;span size="12000"&gt;GHI&lt;/span&gt;</property>
                             <property name="use_markup">True</property>
                             <property name="justify">GTK_JUSTIFY_CENTER</property>
                           </widget>
                         </child>
                       </widget>
                       <packing>
-                        <property name="left_attach">1</property>
-                        <property name="right_attach">2</property>
-                        <property name="top_attach">2</property>
-                        <property name="bottom_attach">3</property>
+                        <property name="top_attach">1</property>
+                        <property name="bottom_attach">2</property>
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkButton" id="digit7">
+                      <widget class="GtkButton" id="digit5">
                         <property name="visible">True</property>
                         <property name="focus_on_click">False</property>
                         <property name="response_id">0</property>
                         <signal name="clicked" handler="on_digit_clicked"/>
-                        <accelerator key="s" modifiers="" signal="clicked"/>
-                        <accelerator key="r" modifiers="" signal="clicked"/>
-                        <accelerator key="q" modifiers="" signal="clicked"/>
-                        <accelerator key="p" modifiers="" signal="clicked"/>
-                        <accelerator key="7" modifiers="" signal="clicked"/>
+                        <accelerator key="5" modifiers="" signal="clicked"/>
+                        <accelerator key="j" modifiers="" signal="clicked"/>
+                        <accelerator key="k" modifiers="" signal="clicked"/>
+                        <accelerator key="l" modifiers="" signal="clicked"/>
                         <child>
-                          <widget class="GtkLabel" id="label16">
+                          <widget class="GtkLabel" id="label14">
                             <property name="visible">True</property>
-                            <property name="label" translatable="yes">&lt;span size="30000" weight="bold"&gt;7&lt;/span&gt;
-&lt;span size="12000"&gt;PQRS&lt;/span&gt;</property>
+                            <property name="label" translatable="yes">&lt;span size="30000" weight="bold"&gt;5&lt;/span&gt;
+&lt;span size="12000"&gt;JKL&lt;/span&gt;</property>
                             <property name="use_markup">True</property>
                             <property name="justify">GTK_JUSTIFY_CENTER</property>
                           </widget>
                         </child>
                       </widget>
                       <packing>
-                        <property name="top_attach">2</property>
-                        <property name="bottom_attach">3</property>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                        <property name="top_attach">1</property>
+                        <property name="bottom_attach">2</property>
                       </packing>
                     </child>
                     <child>
                         <property name="focus_on_click">False</property>
                         <property name="response_id">0</property>
                         <signal name="clicked" handler="on_digit_clicked"/>
-                        <accelerator key="o" modifiers="" signal="clicked"/>
-                        <accelerator key="n" modifiers="" signal="clicked"/>
-                        <accelerator key="m" modifiers="" signal="clicked"/>
                         <accelerator key="6" modifiers="" signal="clicked"/>
+                        <accelerator key="m" modifiers="" signal="clicked"/>
+                        <accelerator key="n" modifiers="" signal="clicked"/>
+                        <accelerator key="o" modifiers="" signal="clicked"/>
                         <child>
                           <widget class="GtkLabel" id="label15">
                             <property name="visible">True</property>
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkButton" id="digit5">
+                      <widget class="GtkButton" id="digit7">
                         <property name="visible">True</property>
                         <property name="focus_on_click">False</property>
                         <property name="response_id">0</property>
                         <signal name="clicked" handler="on_digit_clicked"/>
-                        <accelerator key="l" modifiers="" signal="clicked"/>
-                        <accelerator key="k" modifiers="" signal="clicked"/>
-                        <accelerator key="j" modifiers="" signal="clicked"/>
-                        <accelerator key="5" modifiers="" signal="clicked"/>
+                        <accelerator key="7" modifiers="" signal="clicked"/>
+                        <accelerator key="p" modifiers="" signal="clicked"/>
+                        <accelerator key="q" modifiers="" signal="clicked"/>
+                        <accelerator key="r" modifiers="" signal="clicked"/>
+                        <accelerator key="s" modifiers="" signal="clicked"/>
                         <child>
-                          <widget class="GtkLabel" id="label14">
+                          <widget class="GtkLabel" id="label16">
                             <property name="visible">True</property>
-                            <property name="label" translatable="yes">&lt;span size="30000" weight="bold"&gt;5&lt;/span&gt;
-&lt;span size="12000"&gt;JKL&lt;/span&gt;</property>
+                            <property name="label" translatable="yes">&lt;span size="30000" weight="bold"&gt;7&lt;/span&gt;
+&lt;span size="12000"&gt;PQRS&lt;/span&gt;</property>
                             <property name="use_markup">True</property>
                             <property name="justify">GTK_JUSTIFY_CENTER</property>
                           </widget>
                         </child>
                       </widget>
                       <packing>
-                        <property name="left_attach">1</property>
-                        <property name="right_attach">2</property>
-                        <property name="top_attach">1</property>
-                        <property name="bottom_attach">2</property>
+                        <property name="top_attach">2</property>
+                        <property name="bottom_attach">3</property>
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkButton" id="digit4">
+                      <widget class="GtkButton" id="digit8">
                         <property name="visible">True</property>
                         <property name="focus_on_click">False</property>
                         <property name="response_id">0</property>
                         <signal name="clicked" handler="on_digit_clicked"/>
-                        <accelerator key="i" modifiers="" signal="clicked"/>
-                        <accelerator key="h" modifiers="" signal="clicked"/>
-                        <accelerator key="g" modifiers="" signal="clicked"/>
-                        <accelerator key="4" modifiers="" signal="clicked"/>
+                        <accelerator key="8" modifiers="" signal="clicked"/>
+                        <accelerator key="t" modifiers="" signal="clicked"/>
+                        <accelerator key="u" modifiers="" signal="clicked"/>
+                        <accelerator key="v" modifiers="" signal="clicked"/>
                         <child>
-                          <widget class="GtkLabel" id="label13">
+                          <widget class="GtkLabel" id="label17">
                             <property name="visible">True</property>
-                            <property name="label" translatable="yes">&lt;span size="30000" weight="bold"&gt;4&lt;/span&gt;
-&lt;span size="12000"&gt;GHI&lt;/span&gt;</property>
+                            <property name="label" translatable="yes">&lt;span size="30000" weight="bold"&gt;8&lt;/span&gt;
+&lt;span size="12000"&gt;TUV&lt;/span&gt;</property>
                             <property name="use_markup">True</property>
                             <property name="justify">GTK_JUSTIFY_CENTER</property>
                           </widget>
                         </child>
                       </widget>
                       <packing>
-                        <property name="top_attach">1</property>
-                        <property name="bottom_attach">2</property>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                        <property name="top_attach">2</property>
+                        <property name="bottom_attach">3</property>
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkButton" id="digit3">
+                      <widget class="GtkButton" id="digit9">
                         <property name="visible">True</property>
                         <property name="focus_on_click">False</property>
                         <property name="response_id">0</property>
                         <signal name="clicked" handler="on_digit_clicked"/>
-                        <accelerator key="f" modifiers="" signal="clicked"/>
-                        <accelerator key="e" modifiers="" signal="clicked"/>
-                        <accelerator key="d" modifiers="" signal="clicked"/>
-                        <accelerator key="3" modifiers="" signal="clicked"/>
+                        <accelerator key="9" modifiers="" signal="clicked"/>
+                        <accelerator key="w" modifiers="" signal="clicked"/>
+                        <accelerator key="x" modifiers="" signal="clicked"/>
+                        <accelerator key="y" modifiers="" signal="clicked"/>
+                        <accelerator key="z" modifiers="" signal="clicked"/>
                         <child>
-                          <widget class="GtkLabel" id="label11">
+                          <widget class="GtkLabel" id="label18">
                             <property name="visible">True</property>
-                            <property name="label" translatable="yes">&lt;span size="30000" weight="bold" stretch="ultraexpanded"&gt;3&lt;/span&gt;
-&lt;span size="12000"&gt;DEF&lt;/span&gt;</property>
+                            <property name="label" translatable="yes">&lt;span size="30000" weight="bold"&gt;9&lt;/span&gt;
+&lt;span size="12000"&gt;WXYZ&lt;/span&gt;</property>
                             <property name="use_markup">True</property>
                             <property name="justify">GTK_JUSTIFY_CENTER</property>
                           </widget>
                       <packing>
                         <property name="left_attach">2</property>
                         <property name="right_attach">3</property>
+                        <property name="top_attach">2</property>
+                        <property name="bottom_attach">3</property>
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkButton" id="digit2">
+                      <widget class="GtkButton" id="back">
+                        <property name="visible">True</property>
+                        <property name="focus_on_click">False</property>
+                        <property name="response_id">0</property>
+                        <signal name="clicked" handler="on_back_clicked"/>
+                        <accelerator key="BackSpace" modifiers="" signal="clicked"/>
+                        <child>
+                          <widget class="GtkHBox" id="hbox2">
+                            <property name="visible">True</property>
+                            <child>
+                              <widget class="GtkImage" id="image2">
+                                <property name="visible">True</property>
+                                <property name="xalign">1</property>
+                                <property name="stock">gtk-no</property>
+                              </widget>
+                            </child>
+                            <child>
+                              <widget class="GtkLabel" id="label9">
+                                <property name="visible">True</property>
+                                <property name="xalign">0</property>
+                                <property name="xpad">5</property>
+                                <property name="label" translatable="yes">&lt;span size="17000" weight="Bold"&gt;Back&lt;/span&gt;</property>
+                                <property name="use_markup">True</property>
+                              </widget>
+                              <packing>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </widget>
+                        </child>
+                      </widget>
+                      <packing>
+                        <property name="top_attach">3</property>
+                        <property name="bottom_attach">4</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkButton" id="digit0">
                         <property name="visible">True</property>
                         <property name="focus_on_click">False</property>
                         <property name="response_id">0</property>
                         <signal name="clicked" handler="on_digit_clicked"/>
-                        <accelerator key="c" modifiers="" signal="clicked"/>
-                        <accelerator key="b" modifiers="" signal="clicked"/>
-                        <accelerator key="a" modifiers="" signal="clicked"/>
-                        <accelerator key="2" modifiers="" signal="clicked"/>
+                        <accelerator key="0" modifiers="" signal="clicked"/>
                         <child>
-                          <widget class="GtkLabel" id="label10">
+                          <widget class="GtkLabel" id="label19">
                             <property name="visible">True</property>
-                            <property name="label" translatable="yes">&lt;span size="30000" weight="bold"&gt;2&lt;/span&gt;
-&lt;span size="12000"&gt;ABC&lt;/span&gt;</property>
+                            <property name="label" translatable="yes">&lt;span size="33000" weight="bold"&gt;0&lt;/span&gt;
+&lt;span size="9000"&gt;&lt;/span&gt;</property>
                             <property name="use_markup">True</property>
                             <property name="justify">GTK_JUSTIFY_CENTER</property>
                           </widget>
                       <packing>
                         <property name="left_attach">1</property>
                         <property name="right_attach">2</property>
+                        <property name="top_attach">3</property>
+                        <property name="bottom_attach">4</property>
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkButton" id="digit1">
+                      <widget class="GtkButton" id="dial">
                         <property name="visible">True</property>
+                        <property name="has_default">True</property>
                         <property name="focus_on_click">False</property>
                         <property name="response_id">0</property>
-                        <signal name="clicked" handler="on_digit_clicked"/>
-                        <accelerator key="1" modifiers="" signal="clicked"/>
+                        <signal name="clicked" handler="on_dial_clicked"/>
+                        <accelerator key="Return" modifiers="" signal="clicked"/>
                         <child>
-                          <widget class="GtkLabel" id="label12">
+                          <widget class="GtkHBox" id="hbox1">
                             <property name="visible">True</property>
-                            <property name="label" translatable="yes">&lt;span size="33000" weight="bold"&gt;1&lt;/span&gt;
-&lt;span size="9000"&gt;  &lt;/span&gt;</property>
-                            <property name="use_markup">True</property>
+                            <child>
+                              <widget class="GtkImage" id="image1">
+                                <property name="visible">True</property>
+                                <property name="xalign">1</property>
+                                <property name="stock">gtk-yes</property>
+                              </widget>
+                            </child>
+                            <child>
+                              <widget class="GtkLabel" id="label8">
+                                <property name="visible">True</property>
+                                <property name="xalign">0</property>
+                                <property name="xpad">5</property>
+                                <property name="label" translatable="yes">&lt;span size="17000" weight="bold"&gt;Dial&lt;/span&gt;</property>
+                                <property name="use_markup">True</property>
+                              </widget>
+                              <packing>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
                           </widget>
                         </child>
                       </widget>
+                      <packing>
+                        <property name="left_attach">2</property>
+                        <property name="right_attach">3</property>
+                        <property name="top_attach">3</property>
+                        <property name="bottom_attach">4</property>
+                      </packing>
                     </child>
                   </widget>
                   <packing>
                   <placeholder/>
                 </child>
                 <child>
-                  <widget class="GtkLabel" id="label1">
+                  <widget class="GtkComboBoxEntry" id="callbackcombo">
                     <property name="visible">True</property>
-                    <property name="xalign">1</property>
-                    <property name="xpad">5</property>
-                    <property name="label" translatable="yes">GrandCentral
-Number:</property>
-                    <property name="justify">GTK_JUSTIFY_RIGHT</property>
+                    <child internal-child="entry">
+                      <widget class="GtkEntry" id="comboboxentry-entry2">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <signal name="changed" handler="on_callbackentry_changed"/>
+                      </widget>
+                    </child>
                   </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
                 </child>
                 <child>
-                  <widget class="GtkLabel" id="gcnumberlabel">
+                  <widget class="GtkLabel" id="label3">
                     <property name="visible">True</property>
-                    <property name="label" translatable="yes">&lt;span size="15000" weight="bold"&gt;(518) 555-1212&lt;/span&gt;</property>
-                    <property name="use_markup">True</property>
+                    <property name="xalign">1</property>
+                    <property name="xpad">5</property>
+                    <property name="label" translatable="yes">Callback Number:</property>
                   </widget>
                   <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="y_options"></property>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
                   </packing>
                 </child>
                 <child>
@@ -590,36 +614,26 @@ must reauthenticate</property>
                   </packing>
                 </child>
                 <child>
-                  <widget class="GtkLabel" id="label3">
+                  <widget class="GtkLabel" id="gcnumberlabel">
                     <property name="visible">True</property>
-                    <property name="xalign">1</property>
-                    <property name="xpad">5</property>
-                    <property name="label" translatable="yes">Callback Number:</property>
+                    <property name="label" translatable="yes">&lt;span size="15000" weight="bold"&gt;(518) 555-1212&lt;/span&gt;</property>
+                    <property name="use_markup">True</property>
                   </widget>
                   <packing>
-                    <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="y_options"></property>
                   </packing>
                 </child>
                 <child>
-                  <widget class="GtkComboBoxEntry" id="callbackcombo">
+                  <widget class="GtkLabel" id="label1">
                     <property name="visible">True</property>
-                    <child internal-child="entry">
-                      <widget class="GtkEntry" id="comboboxentry-entry2">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <signal name="changed" handler="on_callbackentry_changed"/>
-                      </widget>
-                    </child>
+                    <property name="xalign">1</property>
+                    <property name="xpad">5</property>
+                    <property name="label" translatable="yes">GrandCentral
+Number:</property>
+                    <property name="justify">GTK_JUSTIFY_RIGHT</property>
                   </widget>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
-                  </packing>
                 </child>
               </widget>
               <packing>
@@ -722,17 +736,14 @@ Copyright 2008</property>
             <property name="n_rows">2</property>
             <property name="n_columns">2</property>
             <child>
-              <widget class="GtkLabel" id="label5">
-                <property name="visible">True</property>
-                <property name="label" translatable="yes">Username</property>
-              </widget>
-            </child>
-            <child>
-              <widget class="GtkLabel" id="label6">
+              <widget class="GtkEntry" id="passwordentry">
                 <property name="visible">True</property>
-                <property name="label" translatable="yes">Password</property>
+                <property name="can_focus">True</property>
+                <property name="visibility">False</property>
               </widget>
               <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
                 <property name="top_attach">1</property>
                 <property name="bottom_attach">2</property>
               </packing>
@@ -748,18 +759,21 @@ Copyright 2008</property>
               </packing>
             </child>
             <child>
-              <widget class="GtkEntry" id="passwordentry">
+              <widget class="GtkLabel" id="label6">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="visibility">False</property>
+                <property name="label" translatable="yes">Password</property>
               </widget>
               <packing>
-                <property name="left_attach">1</property>
-                <property name="right_attach">2</property>
                 <property name="top_attach">1</property>
                 <property name="bottom_attach">2</property>
               </packing>
             </child>
+            <child>
+              <widget class="GtkLabel" id="label5">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">Username</property>
+              </widget>
+            </child>
           </widget>
           <packing>
             <property name="position">1</property>
@@ -881,22 +895,12 @@ Copyright 2008</property>
               <widget class="GtkTable" id="table2">
                 <property name="visible">True</property>
                 <property name="n_rows">1</property>
-                <property name="n_columns">2</property>
+                <property name="n_columns">1</property>
                 <child>
-                  <widget class="GtkComboBox" id="addressbooks_combo">
+                  <widget class="GtkTreeView" id="books_view">
                     <property name="visible">True</property>
-                  </widget>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkLabel" id="label2">
-                    <property name="visible">True</property>
-                    <property name="label" translatable="yes">Address Book</property>
+                    <property name="can_focus">True</property>
+                    <property name="headers_clickable">True</property>
                   </widget>
                 </child>
               </widget>
index 77a4962..564e4b9 100755 (executable)
@@ -145,6 +145,7 @@ def make_idler(func):
                        a[0].next()
                        return True
                except StopIteration:
+                       del a[:]
                        return False
        
        decorated_func.__name__ = func.__name__
@@ -160,25 +161,28 @@ class DummyAddressBook(object):
                """
                @returns Iterable of (Address Book Factory, Book Id, Book Name)
                """
-               yield self, None, "None"
+               yield self, "", "None"
        
        def open_addressbook(self, bookId):
                return self
 
+       def factory_name(self):
+               return ""
+
        def get_contacts(self):
                """
                @returns Iterable of (contact id, contact name)
                """
-               return
+               return []
 
        def get_contact_details(self, contactId):
                """
                @returns Iterable of (Phone Type, Phone Number)
                """
-               return
+               return []
 
 
-class SettingsWindow(object):
+class SettingsDialog(object):
 
        def __init__(self, widgetTree, gcDialer):
                self._gcDialer = gcDialer
@@ -191,14 +195,36 @@ class SettingsWindow(object):
                self._cancelButton = self._widgetTree.get_widget("cancel_settings")
                self._cancelButton.connect("clicked", self.custom_button_response(gtk.RESPONSE_CANCEL))
 
-               self._booksCombo = self._widgetTree.get_widget("addressbooks_combo")
+               self._booksList = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING)
+               for (factoryId, bookId), (factoryName, bookName) in self._gcDialer.get_addressbooks():
+                       row = (str(factoryId), bookId, factoryName, bookName)
+                       self._booksList.append(row)
+
+               self._booksView = self._widgetTree.get_widget("books_view")
+               self._booksView.set_model(self._booksList)
+
+               # Add the column to the treeview
+               column = gtk.TreeViewColumn("Addressbook")
+
+               textrenderer = gtk.CellRendererText()
+               column.pack_start(textrenderer, expand=False)
+               column.add_attribute(textrenderer, 'text', 2)
+
+               textrenderer = gtk.CellRendererText()
+               column.pack_start(textrenderer, expand=True)
+               column.add_attribute(textrenderer, 'text', 3)
 
-               self._booksList = gtk.ListStore(gobject.TYPE_STRING)
-               self._booksCombo.set_model(self._booksList)
-               self._booksCombo.set_text_column(0)
-               #for number, description in self._gcBackend.get_callback_numbers().iteritems():
-               #       self.callbacklist.append([make_pretty(number)])
-               #self._booksCombo.get_child().set_text()
+               column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
+               column.set_sort_column_id(2)
+               column.set_visible(True)
+               self._booksView.append_column(column)
+
+               self._booksViewSelection = self._booksView.get_selection()
+               self._booksViewSelection.set_mode(gtk.SELECTION_SINGLE)
+               self.reset()
+       
+       def reset(self):
+               pass
        
        def custom_button_response(self, response):
 
@@ -207,18 +233,18 @@ class SettingsWindow(object):
 
                return button_handler
 
-       def run(self, contactDetails):
-               self._booksList.clear()
-
-               for phoneType, phoneNumber in contactDetails:
-                       self._booksList.append((phoneNumber, "%s - %s" % (make_pretty(phoneNumber), phoneType)))
-
+       def run(self):
                userResponse = self._dialog.run()
 
                if userResponse == gtk.RESPONSE_OK:
-                       pass
+                       model, itr = self._booksViewSelection.get_selected()
+                       if itr:
+                               factoryId = int(self._booksList.get_value(itr, 0))
+                               bookId = self._booksList.get_value(itr, 1)
+                               self._gcDialer.open_addressbook(factoryId, bookId)
+                               self._booksViewSelection.unselect_all()
                else:
-                       pass
+                       self.reset()
 
                self._dialog.hide()
 
@@ -410,6 +436,7 @@ class Dialpad(object):
                        "on_dialpad_quit": self._on_close,
                        "on_paste": self._on_paste,
                        "on_clear_number": self._on_clear_number,
+                       "on_settings": self._on_settings,
 
                        "on_clearcookies_clicked": self._on_clearcookies_clicked,
                        "on_notebook_switch_page": self._on_notebook_switch_page,
@@ -435,9 +462,10 @@ class Dialpad(object):
                        self._gcBackend,
                ]
                self._addressBook = None
-               self.open_addressbook(*self.get_addressbooks().next()[0:2])
+               self.open_addressbook(*self.get_addressbooks().next()[0][0:2])
 
                self._phoneTypeSelector = PhoneTypeSelector(self._widgetTree, self._gcBackend)
+               self._settingsDialog = SettingsDialog(self._widgetTree, self)
 
                if not self._gcBackend.is_authed():
                        self.attempt_login(2)
@@ -447,7 +475,9 @@ class Dialpad(object):
                gobject.idle_add(self._idly_init_contacts_view)
 
        def _idly_init_recent_view(self):
-               """ Deferred initalization of the recent view treeview """
+               """
+               Deferred initalization of the recent view treeview
+               """
 
                recentview = self._widgetTree.get_widget("recentview")
                recentview.set_model(self._recentmodel)
@@ -551,7 +581,7 @@ class Dialpad(object):
                        contactType = (self._gcContactIcon,)
                else:
                        contactType = (self._gcContactText,)
-               for contactId, contactName in self._gcBackend.get_contacts():
+               for contactId, contactName in self._addressBook.get_contacts():
                        self._contactsmodel.append(contactType + (contactName, "", contactId) + ("",))
                        yield
 
@@ -596,15 +626,16 @@ class Dialpad(object):
 
        def get_addressbooks(self):
                """
-               @returns Iterable of (Address Book Factory, Book Id, Book Name)
+               @returns Iterable of ((Factory Id, Book Id), (Factory Name, Book Name))
                """
-               for factory in self._addressBookFactories:
+               for i, factory in enumerate(self._addressBookFactories):
                        for bookFactory, bookId, bookName in factory.get_addressbooks():
-                               yield bookFactory, bookId, bookName
+                               yield (i, bookId), (factory.factory_name(), bookName)
        
-       def open_addressbook(self, bookFactory, bookId):
-               self._addressBook = bookFactory.open_addressbook(bookId)
+       def open_addressbook(self, bookFactoryId, bookId):
+               self._addressBook = self._addressBookFactories[bookFactoryId].open_addressbook(bookId)
                self._contactstime = 0
+               gobject.idle_add(self._idly_populate_contactsview)
 
        def set_number(self, number):
                """
@@ -612,7 +643,7 @@ class Dialpad(object):
                """
                self._phonenumber = make_ugly(number)
                self._prettynumber = make_pretty(self._phonenumber)
-               self._numberdisplay.set_label("<span size='30000' weight='bold'>%s</span>" % ( self._prettynumber ) )
+               self._numberdisplay.set_label("<span size='30000' weight='bold'>%s</span>" % (self._prettynumber))
 
        def set_account_number(self):
                """
@@ -660,6 +691,9 @@ class Dialpad(object):
                        self._isFullScreen = True
                else:
                        self._isFullScreen = False
+       
+       def _on_settings(self, *args, **kwds):
+               self._settingsDialog.run()
 
        def _on_key_press(self, widget, event, *args):
                """
@@ -717,7 +751,7 @@ class Dialpad(object):
                        return
 
                contactId = self._contactsmodel.get_value(itr, 3)
-               contactDetails = self._gcBackend.get_contact_details(contactId)
+               contactDetails = self._addressBook.get_contact_details(contactId)
                contactDetails = [phoneNumber for phoneNumber in contactDetails]
 
                if len(contactDetails) == 0: