conduit r1632 - in trunk: . conduit conduit/gtkui



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

Log:
	* conduit/Module.py: Remove print spew.
	* conduit/Synchronization.py:
	* conduit/gtkui/UI.py:
	* conduit/Web.py: Fix a nasty gtkmozembed threading crash bug caused by
	importing gtkmozembed from a thread that is not the gtk thread.


Modified:
   trunk/   (props changed)
   trunk/ChangeLog
   trunk/conduit/Module.py
   trunk/conduit/Synchronization.py
   trunk/conduit/Web.py
   trunk/conduit/gtkui/UI.py

Modified: trunk/conduit/Module.py
==============================================================================
--- trunk/conduit/Module.py	(original)
+++ trunk/conduit/Module.py	Sat Aug  2 13:49:05 2008
@@ -280,13 +280,10 @@
         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) )

Modified: trunk/conduit/Synchronization.py
==============================================================================
--- trunk/conduit/Synchronization.py	(original)
+++ trunk/conduit/Synchronization.py	Sat Aug  2 13:49:05 2008
@@ -4,7 +4,7 @@
 Copyright: John Stowers, 2006
 License: GPLv2
 """
-
+import thread
 import traceback
 import threading
 import logging
@@ -208,7 +208,8 @@
 
     def __init__(self):
         threading.Thread.__init__(self)
-
+        log.debug("Created thread %s (thread: %s)" % (self,thread.get_ident()))
+        
         #Python threads are not cancellable. Hopefully this will be fixed
         #in Python 3000
         self.cancelled = False
@@ -620,6 +621,7 @@
         exception if the synchronisation state machine does not complete, in
         some way, without success.
         """
+        log.debug("Started thread %s (thread: %s)" % (self,thread.get_ident()))
         try:
             log.debug("Sync %s beginning. Slow: %s, Twoway: %s" % (
                                     self,
@@ -809,6 +811,7 @@
         steps, setting its status at the appropriate time and performing
         nicely in the case of errors. 
         """
+        log.debug("Started thread %s (thread: %s)" % (self,thread.get_ident()))
         try:
             log.debug("Refresh %s beginning" % self)
             self.cond.emit("sync-started")
@@ -854,6 +857,7 @@
         self.setName("%s functions" % len(self.functions))
 
     def run(self):
+        log.debug("Started thread %s (thread: %s)" % (self,thread.get_ident()))
         try:
             #FIXME: Set the status text on the dataprovider
             for f in self.functions:

Modified: trunk/conduit/Web.py
==============================================================================
--- trunk/conduit/Web.py	(original)
+++ trunk/conduit/Web.py	Sat Aug  2 13:49:05 2008
@@ -27,7 +27,7 @@
         self.pages = {}
         self.finished = {}
 
-        log.debug("Created Conduit login window")
+        log.debug("Created login window (thread: %s)" % thread.get_ident())
 
     def _on_window_closed(self, *args):
         for url in self.pages.keys():
@@ -38,10 +38,10 @@
         self._delete_page(url)
             
     def _on_open_uri(self, *args):
-        log.debug("LINK CLICKED (thread: %s)" % thread.get_ident())
+        log.debug("Link clicked (thread: %s)" % thread.get_ident())
 
     def _delete_page(self, url):
-        log.debug("DELETE PAGE (thread: %s)" % thread.get_ident())
+        log.debug("Delete page (thread: %s)" % thread.get_ident())
         #get the original objects
         browser = self.pages[url]
         browserWidget = browser.widget()
@@ -50,20 +50,26 @@
         #remove the page and any refs
         idx = self.notebook.page_num(browserWidget)
         self.notebook.remove_page(idx)
+        browserWidget.destroy()
         del(self.pages[url])
 
         if self.notebook.get_n_pages() == 0:
-            self.window.hide_all()
+            self.window.hide()
 
         #notify 
         self.finished[url] = True
 
-    def _create_page(self, name, url, browserImplKlass):
-        log.debug("CREATE PAGE: %s (thread: %s)" % (url,thread.get_ident()))
+    def _create_page(self, name, url, browserName):
+        log.debug("Create page: %s (thread: %s)" % (url,thread.get_ident()))
         if url in self.pages:
             return False
 
         import gtk
+        if browserName == "gtkmozembed":
+            import conduit.platform.WebBrowserMozilla as WebBrowserImpl
+        elif browserName == "webkit":
+            import conduit.platform.WebBrowserWebkit as WebBrowserImpl
+
         #lazy init to save a bit of time
         if self.window == None:
             self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
@@ -78,9 +84,9 @@
         self.window.show_all()
 
         #create object and connect signals
-        browser = browserImplKlass()
+        browser = WebBrowserImpl.WebBrowserImpl()
         browser.connect("open_uri",self._on_open_uri)
-        
+
         #create the tab label
         tab_button = gtk.Button()
         tab_button.connect('clicked', self._on_tab_close_clicked, url)
@@ -99,15 +105,16 @@
 
         #add to notebook
         browserWidget = browser.widget()
+        browserWidget.show_now()
         self.notebook.append_page(child=browserWidget, tab_label=tab_box)
+        self.notebook.show_all()
         self.pages[url] = browser
 
-        browserWidget.show_now()
         browser.load_url(url)
         return False
 
     def _raise_page(self, url):
-        log.debug("RAISE PAGE (thread: %s)" % thread.get_ident())
+        log.debug("Raise page (thread: %s)" % thread.get_ident())
         self.window.show_all()
 
         #get the original objects
@@ -123,12 +130,12 @@
         return False
 
     def wait_for_login(self, name, url, **kwargs):
-        log.debug("LOGIN (thread: %s)" % thread.get_ident())
+        log.debug("Wait for login (thread: %s)" % thread.get_ident())
     
         if url in self.pages:
             gobject.idle_add(self._raise_page, url)
         else:
-            gobject.idle_add(self._create_page, name, url, kwargs["browserImplKlass"])
+            gobject.idle_add(self._create_page, name, url, kwargs["browserName"])
             self.finished[url] = False
 
         while not self.finished[url] and not conduit.GLOBALS.cancelled:
@@ -136,7 +143,7 @@
             #and gtk.main needs to iterate
             time.sleep(0.1)
 
-        log.debug("FINISHED LOGIN (thread: %s)" % thread.get_ident())
+        log.debug("Finished login (thread: %s)" % thread.get_ident())
 
         #call the test function
         testFunc = kwargs.get("login_function",None)
@@ -152,22 +159,18 @@
     """
     def __init__(self, name, url, **kwargs):
         browser = kwargs.get("browser",conduit.GLOBALS.settings.get("web_login_browser"))
-        log.info("Logging in using browser: %s" % browser)
+        log.info("Logging in using browser: %s (thread: %s)" % (browser,thread.get_ident()))
 
         #instantiate the browser
         if browser == "system":
             login = WebBrowserSystem.WebBrowserImpl()
         else:
             try:
-                if browser == "gtkmozembed":
-                    from conduit.platform.WebBrowserMozilla import WebBrowserImpl
-                elif browser == "webkit":
-                    from conduit.platform.WebBrowserWebkit import WebBrowserImpl
-                else:
+                if browser not in ("gtkmozembed","webkit"):
                     log.warn("Unknown browser type")
                     return
 
-                kwargs["browserImplKlass"] = WebBrowserImpl
+                kwargs["browserName"] = browser
                 login = LoginWindow()
 
             except ImportError:

Modified: trunk/conduit/gtkui/UI.py
==============================================================================
--- trunk/conduit/gtkui/UI.py	(original)
+++ trunk/conduit/gtkui/UI.py	Sat Aug  2 13:49:05 2008
@@ -6,6 +6,7 @@
 Copyright: John Stowers, 2006
 License: GPLv2
 """
+import thread
 import gobject
 import gtk, gtk.glade
 import gnome.ui
@@ -169,12 +170,6 @@
         else:
             self.preconfiguredConduitsMenu = None
 
-        #final GUI setup
-        self.cancelSyncButton = self.widgets.get_widget('cancel')
-        self.hpane.set_position(conduit.GLOBALS.settings.get("gui_hpane_postion"))
-        self.dataproviderTreeView.set_expand_rows()
-        self.window_state = 0
-        
         #if running a development version, add some developer specific links
         #to the help menu
         if conduit.IS_DEVELOPMENT_VERSION:
@@ -195,6 +190,13 @@
                                 gtk.ICON_SIZE_MENU))
                 item.connect("activate",self.on_developer_menu_item_clicked,name,url)
                 developersMenu.append(item)
+
+        #final GUI setup
+        self.cancelSyncButton = self.widgets.get_widget('cancel')
+        self.hpane.set_position(conduit.GLOBALS.settings.get("gui_hpane_postion"))
+        self.dataproviderTreeView.set_expand_rows()
+        self.window_state = 0                
+        log.info("Main window constructed  (thread: %s)" % thread.get_ident())
                 
     def on_developer_menu_item_clicked(self, menuitem, name, url):
         threading.Thread(



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