conduit r1407 - in trunk: . conduit/modules conduit/modules/iPodModule



Author: jstowers
Date: Fri Apr  4 11:10:11 2008
New Revision: 1407
URL: http://svn.gnome.org/viewvc/conduit?rev=1407&view=rev

Log:
2008-04-04  John Stowers  <john stowers gmail com>

	* conduit/modules/Makefile.am:
	* conduit/modules/iPodModule.py:
	* conduit/modules/iPodModule/config.glade:
	* conduit/modules/iPodModule/iPodModule.py:
	* configure.ac: Move iPodModule to its own folder, and add the ability to
	list and delete photo albums from the device.



Added:
   trunk/conduit/modules/iPodModule/
   trunk/conduit/modules/iPodModule/config.glade
   trunk/conduit/modules/iPodModule/iPodModule.py
      - copied, changed from r1405, /trunk/conduit/modules/iPodModule.py
Removed:
   trunk/conduit/modules/iPodModule.py
Modified:
   trunk/ChangeLog
   trunk/NEWS
   trunk/conduit/modules/Makefile.am
   trunk/configure.ac

Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS	(original)
+++ trunk/NEWS	Fri Apr  4 11:10:11 2008
@@ -1,5 +1,13 @@
 NEW in 0.3.10:
 ==============
+* Improve error logging and debug messages at startup
+* Improve network sync performance
+* Improve dataprovider config dialogs
+  * You can now see the available photosets (Flickr)
+  * You can now see the available photo albums (Picasa)
+  * You can now see the available folders (Box.net)
+  * You can create f-spot tags from the fspot dialog
+  * You can see, and delete the available albums on your iPod
 
 NEW in 0.3.9:
 ==============

Modified: trunk/conduit/modules/Makefile.am
==============================================================================
--- trunk/conduit/modules/Makefile.am	(original)
+++ trunk/conduit/modules/Makefile.am	Fri Apr  4 11:10:11 2008
@@ -8,6 +8,7 @@
 	FlickrModule \
 	FspotModule \
 	GmailModule \
+	iPodModule \
 	SmugMugModule \
 	EvolutionModule \
 	GoogleModule \
@@ -20,7 +21,6 @@
 conduit_handlersdir = $(libdir)/conduit/modules
 conduit_handlers_PYTHON = \
 	__init__.py \
-	iPodModule.py \
 	TomboyModule.py \
 	ConverterModule.py \
 	PhotoConverterModule.py \

Added: trunk/conduit/modules/iPodModule/config.glade
==============================================================================
--- (empty file)
+++ trunk/conduit/modules/iPodModule/config.glade	Fri Apr  4 11:10:11 2008
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--*- mode: xml -*-->
+<glade-interface>
+  <widget class="GtkDialog" id="PhotoConfigDialog">
+    <property name="visible">True</property>
+    <property name="title" translatable="yes">iPod Photos</property>
+    <property name="resizable">False</property>
+    <property name="default_width">250</property>
+    <property name="default_height">350</property>
+    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+    <child internal-child="vbox">
+      <widget class="GtkVBox" id="vbox30">
+        <property name="visible">True</property>
+        <child>
+          <widget class="GtkLabel" id="albumlabel">
+            <property name="visible">True</property>
+            <property name="xalign">0</property>
+            <property name="xpad">2</property>
+            <property name="ypad">2</property>
+            <property name="label" translatable="yes">Album:</property>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child>
+          <widget class="GtkHBox" id="hbox1">
+            <property name="visible">True</property>
+            <child>
+              <widget class="GtkComboBoxEntry" id="album_combobox">
+                <property name="visible">True</property>
+                <child internal-child="entry">
+                  <widget class="GtkEntry" id="comboboxentry-entry1">
+                  </widget>
+                </child>
+              </widget>
+            </child>
+            <child>
+              <widget class="GtkButton" id="delete_button">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="label" translatable="yes">gtk-delete</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">0</property>
+              </widget>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">3</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <widget class="GtkHButtonBox" id="hbuttonbox12">
+            <property name="visible">True</property>
+            <property name="layout_style">GTK_BUTTONBOX_END</property>
+            <child>
+              <widget class="GtkButton" id="button32">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="label">gtk-cancel</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">-6</property>
+              </widget>
+            </child>
+            <child>
+              <widget class="GtkButton" id="button33">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="label">gtk-ok</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">-5</property>
+              </widget>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">GTK_PACK_END</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+  </widget>
+</glade-interface>

Copied: trunk/conduit/modules/iPodModule/iPodModule.py (from r1405, /trunk/conduit/modules/iPodModule.py)
==============================================================================
--- /trunk/conduit/modules/iPodModule.py	(original)
+++ trunk/conduit/modules/iPodModule/iPodModule.py	Fri Apr  4 11:10:11 2008
@@ -65,7 +65,10 @@
                     kwargs['mount'])
 
     def get_dataproviders(self, udi, **kwargs):
-         return [IPodNoteTwoWay, IPodContactsTwoWay, IPodCalendarTwoWay, IPodPhotoSink]
+        if LIBGPOD_PHOTOS:
+            return [IPodNoteTwoWay, IPodContactsTwoWay, IPodCalendarTwoWay, IPodPhotoSink]
+        else:
+            return [IPodNoteTwoWay, IPodContactsTwoWay, IPodCalendarTwoWay]
 
 
 class IPodBase(DataProvider.TwoWay):
@@ -319,6 +322,8 @@
     _out_type_ = "file/photo"
     _icon_ = "image-x-generic"
 
+    SAFE_PHOTO_ALBUM = "Photo Library"
+
     def __init__(self, *args):
         IPodBase.__init__(self, *args)
         self.db = gpod.PhotoDatabase(self.mountPoint)
@@ -328,11 +333,22 @@
     def _set_sysinfo(self, modelnumstr, model):
         gpod.itdb_device_set_sysinfo(self.db._itdb.device, modelnumstr, model)
         
-    def _get_photo_album(self):
+    def _get_photo_album(self, albumName):
         for album in self.db.PhotoAlbums:
-            if album.name == self.albumName:
+            if album.name == albumName:
+                log.debug("Found album: %s" % albumName)
                 return album
-        return None
+
+        log.debug("Creating album: %s" % albumName)
+        return self._create_photo_album(albumName)
+
+    def _create_photo_album(self, albumName):
+        if albumName in [a.name for a in self.db.PhotoAlbums]:
+            log.warn("Album already exists: %s" % albumName)
+            album = self._get_photo_album(albumName)
+        else:
+            album = self.db.new_PhotoAlbum(title=albumName)
+        return album
         
     def _get_photo_by_id(self, id):
         for album in self.db.PhotoAlbums:
@@ -341,32 +357,38 @@
                     return photo
         return None
         
-    def _empty_album(self):
-        for photo in self.album[:]:
-            self.album.remove(photo)
+    def _delete_album(self, albumName):
+        if albumName == self.SAFE_PHOTO_ALBUM:
+            log.warn("Cannot delete album: %s" % self.SAFE_PHOTO_ALBUM)
+        else:
+            album = self._get_photo_album(albumName)
+            for photo in album[:]:
+                album.remove(photo)
+            self.db.remove(album)
             
     def _empty_all_photos(self):
         for photo in self.db.PhotoAlbums[0][:]:
             self.db.remove(photo)
 
+    def _get_photo_albums(self):
+        i = []
+        for album in self.db.PhotoAlbums:
+            i.append(album.name)
+        return i
+
     def refresh(self):
         DataProvider.TwoWay.refresh(self)
-        if self.albumName != "":
-            self.album = self._get_photo_album()
-            if self.album == None:
-                log.debug("Creating album %s" % self.albumName)
-                self.album = self.db.new_PhotoAlbum(title=self.albumName)
+        self.album = self._get_photo_album(self.albumName)
 
     def get_all(self):
         uids = []
-        for photo in self._get_photo_album():
+        for photo in self.album:
             uids.append(str(photo['id']))
         return uids
 
     def put(self, f, overwrite, LUID=None):
         photo = self.db.new_Photo(filename=f.get_local_uri())
-        if self.album != None:
-            self.album.add(photo)
+        self.album.add(photo)
         gpod.itdb_photodb_write(self.db._itdb, None)
         return conduit.datatypes.Rid(str(photo['id']), None, hash(None))
 
@@ -375,7 +397,66 @@
         if photo != None:
             self.db.remove(photo)
             gpod.itdb_photodb_write(self.db._itdb, None)
+
+    def configure(self, window):    
+        import gobject
+        import gtk
+        def build_album_model(albumCombo):
+            self.album_store.clear()
+            album_count = 0
+            album_iter = None
+            for name in self._get_photo_albums():
+                iter = self.album_store.append((name,))
+                if name == self.albumName:
+                    album_iter = iter
+                album_count += 1
+
+            if album_iter:
+                albumCombo.set_active_iter(album_iter)
+            elif self.albumName:
+                albumCombo.child.set_text(self.albumName)
+            elif album_count:
+                albumCombo.set_active(0)
+
+        def delete_click(sender, albumCombo):
+            albumName = albumCombo.get_active_text()
+            if albumName:
+                self._delete_album(albumName)
+                build_album_model(albumCombo)
+ 
+        #get a whole bunch of widgets
+        tree = Utils.dataprovider_glade_get_widget(
+                        __file__, 
+                        "config.glade", 
+                        "PhotoConfigDialog")
+        albumCombo = tree.get_widget("album_combobox")
+        delete_button = tree.get_widget("delete_button")
+
+        #setup album store
+        self.album_store = gtk.ListStore(gobject.TYPE_STRING)
+        albumCombo.set_model(self.album_store)
+        cell = gtk.CellRendererText()
+        albumCombo.pack_start(cell, True)
+        albumCombo.set_text_column(0)
         
+        #setup widgets
+        build_album_model(albumCombo)
+        delete_button.connect('clicked', delete_click, albumCombo)
+
+        # run dialog 
+        dlg = tree.get_widget("PhotoConfigDialog")
+        response = Utils.run_dialog(dlg, window)
+
+        if response == True:
+            #get the values from the widgets
+            self.albumName = albumCombo.get_active_text()
+        dlg.destroy()    
+
+        del self.album_store
+
+    def is_configured (self, isSource, isTwoWay):
+        return len(self.albumName) > 0
+
     def uninitialize(self):
         self.db.close()
                 

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Fri Apr  4 11:10:11 2008
@@ -129,6 +129,7 @@
 conduit/modules/FspotModule/Makefile
 conduit/modules/GmailModule/Makefile
 conduit/modules/GmailModule/libgmail/Makefile
+conduit/modules/iPodModule/Makefile
 conduit/modules/SmugMugModule/Makefile
 conduit/modules/SmugMugModule/SmugMugAPI/Makefile
 conduit/modules/GoogleModule/Makefile



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]