From: Ed Page Date: Sun, 14 Feb 2010 05:03:55 +0000 (-0600) Subject: Import of contacts is implemented, just no refreshing of contact X-Git-Url: http://git.maemo.org/git/?p=gc-dialer;a=commitdiff_plain;h=457453f2da8db8fb6a48215bcf77bf0b3722995d Import of contacts is implemented, just no refreshing of contact --- diff --git a/src/dc_glade.py b/src/dc_glade.py index 708d8e0..2e0adca 100755 --- a/src/dc_glade.py +++ b/src/dc_glade.py @@ -29,6 +29,7 @@ import threading import base64 import ConfigParser import itertools +import shutils import logging import gtk @@ -97,6 +98,7 @@ class Dialcentral(object): self._alarmHandler = None self._ledHandler = None self._originalCurrentLabels = [] + self._fsContactsPath = os.path.join(constants._data_path_, "contacts") for path in self._glade_files: if os.path.isfile(path): @@ -158,6 +160,10 @@ class Dialcentral(object): button.connect("clicked", self._on_clearcookies_clicked) menu.append(button) + button= gtk.Button("Import Contacts") + button.connect("clicked", self._on_contact_import) + menu.append(button) + button= gtk.Button("Refresh") button.connect("clicked", self._on_menu_refresh) menu.append(button) @@ -313,8 +319,7 @@ class Dialcentral(object): ), }) - fsContactsPath = os.path.join(constants._data_path_, "contacts") - fileBackend = file_backend.FilesystemAddressBookFactory(fsContactsPath) + fileBackend = file_backend.FilesystemAddressBookFactory(self._fsContactsPath) self._dialpads[self.GV_BACKEND].number_selected = self._select_action self._historyViews[self.GV_BACKEND].number_selected = self._select_action @@ -335,6 +340,7 @@ class Dialcentral(object): "on_refresh": self._on_menu_refresh, "on_clearcookies_clicked": self._on_clearcookies_clicked, "on_about_activate": self._on_about_activate, + "on_import": self._on_contact_import, } if hildonize.GTK_MENU_USED: self._widgetTree.signal_autoconnect(callbackMapping) @@ -879,6 +885,27 @@ class Dialcentral(object): except Exception, e: self._errorDisplay.push_exception() + def _on_contact_import(self, *args): + try: + csvFilter = gtk.FileFilter() + csvFilter.set_name("Contacts") + csvFilter.add_pattern("*.csv") + importFileChooser = gtk.FileChooserDialog( + title="Contacts", + parent=self._window, + ) + importFileChooser.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL) + importFileChooser.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK) + + importFileChooser.set_property("filter", csvFilter) + userResponse = importFileChooser.run() + importFileChooser.hide() + if userResponse == gtk.RESPONSE_OK: + filename = importFileChooser.get_filename() + shutils.copy2(filename, self._fsContactsPath) + except Exception, e: + self._errorDisplay.push_exception() + def _on_menu_refresh(self, *args): try: self._refresh_active_tab() diff --git a/src/dialcentral.glade b/src/dialcentral.glade index 4bee031..be6883a 100644 --- a/src/dialcentral.glade +++ b/src/dialcentral.glade @@ -21,6 +21,14 @@ + + True + Import + True + + + + True Paste