conduit r1564 - in trunk: . conduit/modules/FacebookModule
- From: jstowers svn gnome org
- To: svn-commits-list gnome org
- Subject: conduit r1564 - in trunk: . conduit/modules/FacebookModule
- Date: Thu, 17 Jul 2008 00:48:36 +0000 (UTC)
Author: jstowers
Date: Thu Jul 17 00:48:36 2008
New Revision: 1564
URL: http://svn.gnome.org/viewvc/conduit?rev=1564&view=rev
Log:
2008-07-16 John Stowers <john stowers gmail com>
* conduit/modules/FacebookModule/config.glade:
* conduit/modules/FacebookModule/FacebookModule.py:
* conduit/modules/FacebookModule/Makefile.am: You can now specify the
album that facebook photos are added to.
Added:
trunk/conduit/modules/FacebookModule/config.glade
Modified:
trunk/ (props changed)
trunk/ChangeLog
trunk/NEWS
trunk/conduit/modules/FacebookModule/FacebookModule.py
trunk/conduit/modules/FacebookModule/Makefile.am
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Thu Jul 17 00:48:36 2008
@@ -3,6 +3,7 @@
* Support google documents upload/sync
* Support youtube video upload
* Factories can now be configured
+* Facebook photos can now be added to albums
NEW in 0.3.11.2:
==============
Modified: trunk/conduit/modules/FacebookModule/FacebookModule.py
==============================================================================
--- trunk/conduit/modules/FacebookModule/FacebookModule.py (original)
+++ trunk/conduit/modules/FacebookModule/FacebookModule.py Thu Jul 17 00:48:36 2008
@@ -38,7 +38,7 @@
_description_ = _("Sync your Facebook photos")
_module_type_ = "sink"
_icon_ = "facebook"
- _configurable_ = False
+ _configurable_ = True
API_KEY="6ce1868c3292471c022c771c0d4d51ed"
SECRET="20e2c82829f1884e40efc616a44e5d1f"
@@ -47,22 +47,26 @@
Image.ImageSink.__init__(self)
self.fapi = pyfacebook.Facebook(FacebookSink.API_KEY, FacebookSink.SECRET)
self.browser = "gtkmozembed"
+ self.albumname = ""
+ self.albums = {}
def _upload_photo (self, uploadInfo):
"""
Upload to album; and return image id here
"""
try:
- rsp = self.fapi.photos.upload(uploadInfo.url)
+ rsp = self.fapi.photos.upload(
+ uploadInfo.url,
+ aid=self.albums.get(self.albumname, None))
return Rid(uid=rsp["pid"])
except pyfacebook.FacebookError, f:
raise Exceptions.SyncronizeError("Facebook Upload Error %s" % f)
def _get_albums(self):
- albums = []
+ albums = {}
try:
for a in self.fapi.photos.getAlbums(self.fapi.uid):
- albums.append((a['name'], a['aid']))
+ albums[a['name']] = a['aid']
except pyfacebook.FacebookError, f:
log.warn("Error getting album list: %s" % f)
return albums
@@ -107,13 +111,96 @@
rsp = self.fapi.auth.getSession()
return rsp.has_key("secret") and rsp.has_key("session_key")
+ def configure(self, window):
+ import gtk
+ import gobject
+ def on_login_finish(*args):
+ if self.fapi.uid:
+ build_album_store()
+ Utils.dialog_reset_cursor(dlg)
+
+ def on_response(sender, responseID):
+ if responseID == gtk.RESPONSE_OK:
+ self.albumname = albumnamecombo.child.get_text()
+
+ def load_button_clicked(button):
+ Utils.dialog_set_busy_cursor(dlg)
+ conduit.GLOBALS.syncManager.run_blocking_dataprovider_function_calls(
+ self,
+ on_login_finish,
+ self._login)
+
+ def build_album_store():
+ album_store.clear()
+ album_count = 0
+ album_iter = None
+ for album_name in self._get_albums().keys():
+ iter = album_store.append((album_name,))
+ if album_name != "" and album_name == self.albumname:
+ album_iter = iter
+ album_count += 1
+
+ if album_iter:
+ albumnamecombo.set_active_iter(album_iter)
+ elif self.albumname:
+ albumnamecombo.child.set_text(self.albumname)
+ elif album_count:
+ albumnamecombo.set_active(0)
+
+ tree = Utils.dataprovider_glade_get_widget(
+ __file__,
+ "config.glade",
+ "FacebookConfigDialog")
+
+ #get a whole bunch of widgets
+ albumnamecombo = tree.get_widget("albumnamecombo")
+ load_button = tree.get_widget("load_button")
+ dlg = tree.get_widget("FacebookConfigDialog")
+
+ # setup combobox
+ album_store = gtk.ListStore(gobject.TYPE_STRING)
+ albumnamecombo.set_model(album_store)
+ cell = gtk.CellRendererText()
+ albumnamecombo.pack_start(cell, True)
+ albumnamecombo.set_text_column(0)
+
+ # load button
+ load_button.connect('clicked', load_button_clicked)
+ albumnamecombo.child.set_text(self.albumname)
+
+ # run the dialog
+ Utils.run_dialog_non_blocking(dlg, on_response, window)
+
def refresh(self):
Image.ImageSink.refresh(self)
if self.fapi.uid == None:
self._login()
+ #get the list of albums
+ if self.fapi.uid:
+ self.albums = self._get_albums()
+ if self.albumname and self.albumname not in self.albums:
+ log.info("Creating album: %s" % self.albumname)
+ try:
+ rsp = self.fapi.photos.createAlbum(
+ #session_key=self.fapi.session_key,
+ name=self.albumname)
+ self.albums[self.albumname] = rsp["aid"]
+ except pyfacebook.FacebookError, f:
+ self.albumname = ""
+ log.warn("Error creating album: %s" % self.albumname)
+
def get_UID(self):
if self.fapi.uid == None:
return ""
return self.fapi.uid
+
+ def is_configured (self, isSource, isTwoWay):
+ #Specifing an album is optional
+ return True
+
+ def get_configuration(self):
+ return {
+ "albumname" : self.albumname
+ }
Modified: trunk/conduit/modules/FacebookModule/Makefile.am
==============================================================================
--- trunk/conduit/modules/FacebookModule/Makefile.am (original)
+++ trunk/conduit/modules/FacebookModule/Makefile.am Thu Jul 17 00:48:36 2008
@@ -3,8 +3,8 @@
conduit_handlersdir = $(libdir)/conduit/modules/FacebookModule
conduit_handlers_PYTHON = FacebookModule.py
-#conduit_handlers_DATA = config.glade
-#EXTRA_DIST = config.glade
+conduit_handlers_DATA = config.glade
+EXTRA_DIST = config.glade
clean-local:
rm -rf *.pyc *.pyo
Added: trunk/conduit/modules/FacebookModule/config.glade
==============================================================================
--- (empty file)
+++ trunk/conduit/modules/FacebookModule/config.glade Thu Jul 17 00:48:36 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="FacebookConfigDialog">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Facebook</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="albumnamecombo">
+ <property name="visible">True</property>
+ <child internal-child="entry">
+ <widget class="GtkEntry" id="comboboxentry-entry1">
+ </widget>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkButton" id="load_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Load</property>
+ <property name="use_underline">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>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]