conduit r1886 - in trunk: . conduit tools/eog-plugin
- From: jstowers svn gnome org
- To: svn-commits-list gnome org
- Subject: conduit r1886 - in trunk: . conduit tools/eog-plugin
- Date: Fri, 20 Feb 2009 09:57:14 +0000 (UTC)
Author: jstowers
Date: Fri Feb 20 09:57:14 2009
New Revision: 1886
URL: http://svn.gnome.org/viewvc/conduit?rev=1886&view=rev
Log:
2009-02-20 John Stowers <john stowers gmail com>
* conduit/libconduit.py: Also remove the exporter
from the syncset when cleared.
* tools/eog-plugin/conduit.py: Be more robust when
Conduit is started and stopped.
Modified:
trunk/ChangeLog
trunk/conduit/libconduit.py
trunk/tools/eog-plugin/conduit.py
Modified: trunk/conduit/libconduit.py
==============================================================================
--- trunk/conduit/libconduit.py (original)
+++ trunk/conduit/libconduit.py Fri Feb 20 09:57:14 2009
@@ -136,7 +136,6 @@
self.clear()
#update the status
self.store.set_value(rowref, self.STATUS_IDX, "finished")
- self.syncset.DeleteConduit(self.conduit, dbus_interface=SYNCSET_DBUS_IFACE)
else:
#show the error message in the conduit gui
self.store.set_value(rowref, self.STATUS_IDX, "error")
@@ -172,6 +171,8 @@
#need to do in two steps so we dont modify the store while iterating
for d in delete:
self.store.remove(d)
+ #delete conduit's remote instance
+ self.syncset.DeleteConduit(self.conduit, dbus_interface=SYNCSET_DBUS_IFACE)
def sync(self):
if self.configured == True:
@@ -224,6 +225,8 @@
str, #ConduitWrapper.STATUS_IDX
gtk.gdk.Pixbuf #ConduitWrapper.PB_IDX
)
+ else:
+ self.store = None
self.dbus_iface = dbus.Interface(
dbus.SessionBus().get_object('org.freedesktop.DBus', '/org/freedesktop/DBus'),
@@ -329,8 +332,11 @@
def clear(self):
if self.connected():
- for c in self.conduits:
- self.conduits[c].clear()
+ for name,c in self.conduits.items():
+ c.clear()
+ if self.store and c.rowref:
+ self.store.remove(c.rowref)
+ del(self.conduits[name])
def connected(self):
return self.app != None
Modified: trunk/tools/eog-plugin/conduit.py
==============================================================================
--- trunk/tools/eog-plugin/conduit.py (original)
+++ trunk/tools/eog-plugin/conduit.py Fri Feb 20 09:57:14 2009
@@ -10,7 +10,6 @@
DEBUG = True
ICON_SIZE = 24
-MENU_PATH="/MainMenu/ToolsMenu/ToolsOps_2"
SUPPORTED_SINKS = {
"FlickrTwoWay" : "Upload to Flickr",
"PicasaTwoWay" : "Upload to Picasa",
@@ -21,7 +20,7 @@
"IPodPhotoSink" : "Add to iPod"
}
if DEBUG:
- SUPPORTED_SINKS["TestImageSink"] = "Test"
+ SUPPORTED_SINKS["TestImageSink"] = "Test Image Sink"
class EogConduitWrapper(libconduit.ConduitWrapper):
@@ -49,6 +48,10 @@
)
self.conduit.connect("conduit-started", self._on_conduit_started)
self.running = self.conduit.connect_to_conduit(startConduit=True)
+
+ #dictionary holding items that are set sensitive or not when
+ #conduit is started/stopped
+ self.windows = {}
def _debug(self, msg):
if self.debug:
@@ -57,7 +60,10 @@
def _on_conduit_started(self, sender, started):
self._debug("Conduit started: %s" % started)
self.running = started
- self.box.set_sensitive(self.running)
+ #set (in)sensitive on widgets in all windows
+ for box, ui_action_group in self.windows.values():
+ box.set_sensitive(self.running)
+ ui_action_group.set_sensitive(self.running)
def _on_upload_clicked(self, sender, window):
eogImage = window.get_image()
@@ -70,10 +76,10 @@
self.conduit.upload(name, uri, pb)
- def _on_sync_clicked(self, *args):
+ def _on_sync_clicked(self, sender, window):
self.conduit.sync()
- def _on_clear_clicked(self, *args):
+ def _on_clear_clicked(self, sender, window):
self.conduit.clear()
def _on_row_activated(self, treeview, path, view_column):
@@ -87,21 +93,20 @@
app = eog.eog_application_get_instance()
app.open_uri_list((clickedUri,))
- def _prepare_sidebar(self, window):
- #the sidebar is a treeview where
- #photos to upload are grouped by the
- #upload service, with a clear button and
- #an upload button below
-
- self.box = gtk.VBox()
- self.box.set_sensitive(self.running)
+ def _prepare_ui(self, window):
+ #
+ #the sidebar is a treeview where photos to upload are grouped by the
+ #upload service, with a clear button and an upload button below
+ #
+ box = gtk.VBox()
+ box.set_sensitive(self.running)
view = gtk.TreeView(self.conduit.store)
view.connect("row-activated", self._on_row_activated)
view.set_headers_visible(False)
- self.box.pack_start(view,expand=True,fill=True)
+ box.pack_start(view,expand=True,fill=True)
bbox = gtk.HButtonBox()
- self.box.pack_start(bbox,expand=False)
+ box.pack_start(bbox,expand=False,fill=True)
#two colums, an icon and a description/name
col0 = gtk.TreeViewColumn("Pic", gtk.CellRendererPixbuf(), pixbuf=libconduit.ConduitWrapper.PB_IDX)
@@ -117,17 +122,21 @@
okbtn.set_image(
gtk.image_new_from_stock(gtk.STOCK_REFRESH,gtk.ICON_SIZE_BUTTON)
)
- okbtn.connect("clicked",self._on_sync_clicked)
+ okbtn.connect("clicked",self._on_sync_clicked, window)
clearbtn = gtk.Button(stock=gtk.STOCK_CLEAR)
- clearbtn.connect("clicked",self._on_clear_clicked)
+ clearbtn.connect("clicked",self._on_clear_clicked, window)
bbox.pack_start(okbtn,expand=True)
bbox.pack_start(clearbtn,expand=True)
sidebar = window.get_sidebar()
- sidebar.add_page("Photo Uploads", self.box)
+ sidebar.add_page("Photo Uploads", box)
sidebar.show_all()
- def _prepare_tools_menu(self, window):
+
+ #
+ #add items to the tools menu, when clicked the current
+ #image is queued with the service to upload
+ #
ui_action_group = gtk.ActionGroup("ConduitPluginActions")
manager = window.get_ui_manager()
@@ -150,11 +159,15 @@
mid = manager.new_merge_id()
manager.add_ui(
merge_id=mid,
- path=MENU_PATH,
+ path="/MainMenu/ToolsMenu/ToolsOps_2", #Tools menu
name=sinkName,
action=sinkName,
type=gtk.UI_MANAGER_MENUITEM,
top=False)
+
+ #store a reference to the box and action_group as we
+ #set them (in)sensitive when conduit is started/stopped
+ self.windows[window] = (box, ui_action_group)
def _name_data_func(self, column, cell_renderer, tree_model, rowref):
name = tree_model.get_value(rowref, libconduit.ConduitWrapper.NAME_IDX)
@@ -166,12 +179,14 @@
def activate(self, window):
self._debug("Activate")
- #the sidebar and menu integration must be done once per eog window instance
- self._prepare_sidebar(window)
- self._prepare_tools_menu(window)
+ self._prepare_ui(window)
def deactivate(self, window):
self._debug("Deactivate")
+ box,ui_action_group = self.windows[window]
+ window.get_sidebar().remove_page(box)
+ window.get_ui_manager().remove_action_group(ui_action_group)
+ self.conduit.clear()
def update_ui(self, window):
self._debug("Update UI")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]