conduit r1631 - in trunk: . conduit conduit/gtkui data



Author: jstowers
Date: Sat Aug  2 13:48:50 2008
New Revision: 1631
URL: http://svn.gnome.org/viewvc/conduit?rev=1631&view=rev

Log:
	* NEWS: Update to include recent UI work.
	* conduit/Module.py:
	* conduit/SyncSet.py:
	* conduit/gtkui/Canvas.py:
	* conduit/gtkui/UI.py:
	* data/conduit.glade: Add preconfigured example conduits to Knowledge.
	Enable the ability to add these example Conduits to the Canvas from
	a menu item.


Modified:
   trunk/   (props changed)
   trunk/ChangeLog
   trunk/NEWS
   trunk/conduit/Module.py
   trunk/conduit/SyncSet.py
   trunk/conduit/gtkui/Canvas.py
   trunk/conduit/gtkui/UI.py
   trunk/data/conduit.glade

Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS	(original)
+++ trunk/NEWS	Sat Aug  2 13:48:50 2008
@@ -7,6 +7,10 @@
 * Conflict inprovements. Duplicate conflicts should no longer be shown
   in the UI.
 * The UI should will now reuse your theme colors
+* Finer borders and smaller rectangles to match closer with GNOME style
+* Usage hints are now displayed at the bottom of the window, indicating steps
+  that should be taken after one adds items to the Canvas
+* A number of example Conduits can be created from the File->Examples menu
 
 NEW in 0.3.12:
 ==============

Modified: trunk/conduit/Module.py
==============================================================================
--- trunk/conduit/Module.py	(original)
+++ trunk/conduit/Module.py	Sat Aug  2 13:48:50 2008
@@ -14,6 +14,7 @@
 
 import conduit.dataproviders
 import conduit.ModuleWrapper as ModuleWrapper
+import conduit.Knowledge as Knowledge
 import conduit.Vfs as Vfs
 
 class ModuleManager(gobject.GObject):
@@ -271,6 +272,26 @@
         for i in self.moduleWrappers.values():
             if i.module_type == type_filter:
                 i.instantiate_module()
+                
+    def list_preconfigured_conduits(self):
+        #strip the keys back to the classnames, because the preconfigured dps
+        #are described in terms of classes, not instances (keys)
+        names = {}
+        for key in self.moduleWrappers:
+            names[key.split(":")[0]] = key
+            
+        print names.keys()
+        
+        #for a preconfigured conduit to be available, both the 
+        #source and sink must be loaded
+        found = []
+        for (source,sink),(comment,twoway) in Knowledge.PRECONFIGIRED_CONDUITS.items():
+            print source,sink
+            if source in names and sink in names:
+                #return key,key,desc,two-way
+                found.append( (names[source],names[sink],comment,twoway) )
+
+        return found
 
     def quit(self):
         for dpf in self.dataproviderFactories:

Modified: trunk/conduit/SyncSet.py
==============================================================================
--- trunk/conduit/SyncSet.py	(original)
+++ trunk/conduit/SyncSet.py	Sat Aug  2 13:48:50 2008
@@ -52,18 +52,20 @@
             if dp.module:
                 dp.module.uninitialize()
                 
-    def _restore_dataprovider(self, cond, wrapperKey, dpName, dpxml, trySourceFirst):
+    def _restore_dataprovider(self, cond, wrapperKey, dpName="", dpxml="", trySourceFirst=True):
         """
         Adds the dataprovider back onto the canvas at the specifed
         location and configures it with the given settings
         """
         log.debug("Restoring %s to (source=%s)" % (wrapperKey,trySourceFirst))
         wrapper = self.moduleManager.get_module_wrapper_with_instance(wrapperKey)
-        wrapper.set_name(dpName)
+        if dpName:
+            wrapper.set_name(dpName)
         if wrapper is not None:
-            for i in dpxml.childNodes:
-                if i.nodeType == i.ELEMENT_NODE and i.localName == "configuration":
-                    wrapper.set_configuration_xml(xmltext=i.toxml())
+            if dpxml:
+                for i in dpxml.childNodes:
+                    if i.nodeType == i.ELEMENT_NODE and i.localName == "configuration":
+                        wrapper.set_configuration_xml(xmltext=i.toxml())
         cond.add_dataprovider(wrapper, trySourceFirst)
 
     def on_dataprovider_available_unavailable(self, loader, dpw):
@@ -88,6 +90,14 @@
         from the main loop on an idle handler
         """
         gobject.idle_add(gobject.GObject.emit,self,*args)
+        
+    def create_preconfigured_conduit(self, sourceKey, sinkKey, twoway):
+        cond = Conduit.Conduit(self.syncManager)
+        self.add_conduit(cond)
+        if twoway == True:
+            cond.enable_two_way_sync()
+        self._restore_dataprovider(cond, sourceKey, trySourceFirst=True)
+        self._restore_dataprovider(cond, sinkKey, trySourceFirst=False)
 
     def add_conduit(self, cond):
         self.conduits.append(cond)

Modified: trunk/conduit/gtkui/Canvas.py
==============================================================================
--- trunk/conduit/gtkui/Canvas.py	(original)
+++ trunk/conduit/gtkui/Canvas.py	Sat Aug  2 13:48:50 2008
@@ -18,9 +18,9 @@
 
 import conduit.utils as Utils
 import conduit.Conduit as Conduit
+import conduit.Knowledge as Knowledge
 import conduit.gtkui.Tree
 import conduit.gtkui.Util as GtkUtil
-import conduit.gtkui.Hints as Hints
 
 log.info("Module Information: %s" % Utils.get_module_information(goocanvas, "pygoocanvas_version"))
 
@@ -199,7 +199,7 @@
         self._maybe_show_welcome()
         
     def _do_hint(self, msgarea, respid):
-        if respid == Hints.BLANK_CANVAS:
+        if respid == Knowledge.HINT_BLANK_CANVAS:
             new = conduit.GLOBALS.moduleManager.get_module_wrapper_with_instance("FolderTwoWay")
             self.add_dataprovider_to_canvas(
                                 "FolderTwoWay",
@@ -208,14 +208,14 @@
                                 )
 
     def _make_hint(self, hint, timeout=4):
-        if Hints.HINT_TEXT[hint][2]:
+        if Knowledge.HINT_TEXT[hint][2]:
             buttons = [("Show me",hint)]
         else:
             buttons = []
         h = self.msg.new_from_text_and_icon(
                             gtk.STOCK_INFO,
-                            Hints.HINT_TEXT[hint][0],
-                            Hints.HINT_TEXT[hint][1],
+                            Knowledge.HINT_TEXT[hint][0],
+                            Knowledge.HINT_TEXT[hint][1],
                             buttons=buttons,
                             timeout=timeout)
         h.connect("response", self._do_hint)
@@ -229,11 +229,11 @@
             return
             
         if newItem == conduitCanvasItem:
-            self._make_hint(Hints.ADD_DATAPROVIDER)
+            self._make_hint(Knowledge.HINT_ADD_DATAPROVIDER)
         elif newItem == dataproviderCanvasItem:
             #check if we have a source and a sink
             if conduitCanvasItem.model.can_sync():
-                self._make_hint(Hints.RIGHT_CLICK_CONFIGURE)
+                self._make_hint(Knowledge.HINT_RIGHT_CLICK_CONFIGURE)
             
     def _update_for_theme(self, *args):
         if not self.get_gtk_style() or self._changing_style:
@@ -312,7 +312,7 @@
             if self.welcome == None:
                 self._create_welcome()
             if self.msg and conduit.GLOBALS.settings.get("gui_show_hints"):
-                self._make_hint(Hints.BLANK_CANVAS, timeout=0)
+                self._make_hint(Knowledge.HINT_BLANK_CANVAS, timeout=0)
 
         elif self.welcome:
             self._delete_welcome()

Modified: trunk/conduit/gtkui/UI.py
==============================================================================
--- trunk/conduit/gtkui/UI.py	(original)
+++ trunk/conduit/gtkui/UI.py	Sat Aug  2 13:48:50 2008
@@ -39,7 +39,35 @@
 for module in gtk.glade, gettext:
     module.bindtextdomain('conduit', conduit.LOCALE_DIR)
     module.textdomain('conduit')
-    
+
+class _PreconfiguredConduitMenu(gtk.Menu):
+    def __init__(self):
+        gtk.Menu.__init__(self)
+#        self._items = {}
+#        conduit.GLOBALS.moduleManager.connect("dataprovider-available", self._dp_added)
+#        conduit.GLOBALS.moduleManager.connect("dataprovider-unavailable", self._dp_removed)
+
+        for sok,sik,desc,w in conduit.GLOBALS.moduleManager.list_preconfigured_conduits():
+            item = gtk.MenuItem(desc)
+            item.connect("activate", self._create, sok, sik, w)
+            item.show()
+            self.append(item)
+
+    def set_sync_set(self, syncSet):    
+        self.syncSet = syncSet  
+        
+    def _create(self, menu, sok, sik, w):
+        self.syncSet.create_preconfigured_conduit(sok,sik,w)
+        
+    def _dp_added(self, manager, dpw):
+        item = gtk.MenuItem(dpw.get_key())
+        self._items[dpw] = item
+        self.append(item)
+        item.show()
+        
+    def _dp_removed(self, manager, dpw):
+        self.remove(self._items[dpw])
+
 class MainWindow:
     """
     The main conduit window.
@@ -129,6 +157,17 @@
 
         #Set up the expander used for resolving sync conflicts
         self.conflictResolver = ConflictResolver.ConflictResolver(self.widgets)
+        
+        #add the preconfigured Conduit menu
+        if conduit.GLOBALS.settings.get("gui_show_hints"):
+            self.preconfiguredConduitsMenu = _PreconfiguredConduitMenu()
+            item = gtk.ImageMenuItem("Examples")
+            item.set_image(
+                    gtk.image_new_from_stock(gtk.STOCK_OPEN,gtk.ICON_SIZE_MENU))
+            item.set_submenu(self.preconfiguredConduitsMenu)
+            self.widgets.get_widget("file_menu").insert(item, 3)
+        else:
+            self.preconfiguredConduitsMenu = None
 
         #final GUI setup
         self.cancelSyncButton = self.widgets.get_widget('cancel')
@@ -157,7 +196,6 @@
                 item.connect("activate",self.on_developer_menu_item_clicked,name,url)
                 developersMenu.append(item)
                 
-                
     def on_developer_menu_item_clicked(self, menuitem, name, url):
         threading.Thread(
                     target=Web.LoginMagic,
@@ -174,6 +212,8 @@
         self.syncSet = syncSet
         self.syncSet.connect("conduit-added", self.on_conduit_added)
         self.canvas.set_sync_set(syncSet)
+        if self.preconfiguredConduitsMenu:
+            self.preconfiguredConduitsMenu.set_sync_set(syncSet)
 
     def present(self):
         """
@@ -381,7 +421,7 @@
         dialog.set_transient_for(self.mainWindow)
         dialog.run()
         dialog.destroy()
-
+        
     def on_help(self, widget):
         """
         Display help
@@ -486,7 +526,7 @@
                             self.mainWindow.get_size())
         conduit.GLOBALS.settings.set(
                             "gui_expanded_rows",
-                            self.dataproviderTreeView.get_expanded_rows())        
+                            self.dataproviderTreeView.get_expanded_rows())
 
 class SplashScreen:
     """

Modified: trunk/data/conduit.glade
==============================================================================
--- trunk/data/conduit.glade	(original)
+++ trunk/data/conduit.glade	Sat Aug  2 13:48:50 2008
@@ -17,12 +17,12 @@
           <widget class="GtkMenuBar" id="menubar1">
             <property name="visible">True</property>
             <child>
-              <widget class="GtkMenuItem" id="file_menu">
+              <widget class="GtkMenuItem" id="file_menu_item">
                 <property name="visible">True</property>
                 <property name="label" translatable="yes">_File</property>
                 <property name="use_underline">True</property>
                 <child>
-                  <widget class="GtkMenu" id="file1_menu">
+                  <widget class="GtkMenu" id="file_menu">
                     <child>
                       <widget class="GtkImageMenuItem" id="save1">
                         <property name="visible">True</property>
@@ -85,7 +85,7 @@
               </widget>
             </child>
             <child>
-              <widget class="GtkMenuItem" id="edit_menu">
+              <widget class="GtkMenuItem" id="edit_menu_item">
                 <property name="visible">True</property>
                 <property name="label" translatable="yes">_Edit</property>
                 <property name="use_underline">True</property>
@@ -125,7 +125,7 @@
               </widget>
             </child>
             <child>
-              <widget class="GtkMenuItem" id="help_menu">
+              <widget class="GtkMenuItem" id="help_menu_item">
                 <property name="visible">True</property>
                 <property name="label" translatable="yes">_Help</property>
                 <property name="use_underline">True</property>



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