OSDN Git Service

Unset gconf entry if no window exists
authorAiwota Programmer <aiwotaprog@tetteke.tk>
Wed, 23 Aug 2006 14:59:37 +0000 (23:59 +0900)
committerAiwota Programmer <aiwotaprog@tetteke.tk>
Wed, 23 Aug 2006 14:59:37 +0000 (23:59 +0900)
src/Hage1/session.py

index 84483bd..9f97563 100644 (file)
@@ -33,7 +33,7 @@ _windows = {}
 
 def get_window(key):
     if key in _windows:
 
 def get_window(key):
     if key in _windows:
-        return _windows[key]
+        return _windows[key]["winwrap"]
     else:
         return None
 
     else:
         return None
 
@@ -43,8 +43,8 @@ def window_created(key, winwrap):
 
     if key in _windows:
         return False
 
     if key in _windows:
         return False
-    winwrap.window.connect("destroy", on_window_destroy, key)
-    _windows[key] = winwrap
+    handler_id = winwrap.window.connect("destroy", on_window_destroy, key)
+    _windows[key] = {"winwrap": winwrap, "handler_id": handler_id}
     print "regist to _windows", key
     return True
 
     print "regist to _windows", key
     return True
 
@@ -52,6 +52,8 @@ def on_window_destroy(widget, key):
     if key not in _windows:
         return
 
     if key not in _windows:
         return
 
+    do_on_window_destroy(key, get_window(key))
+
     del _windows[key]
     print "unregist from _windows", key
 
     del _windows[key]
     print "unregist from _windows", key
 
@@ -60,7 +62,7 @@ def on_window_destroy(widget, key):
         on_all_window_destroy()
 
 def on_all_window_destroy():
         on_all_window_destroy()
 
 def on_all_window_destroy():
-    gtk.main_quit()
+    main_quit()
 
 def thread_idx_updated(thread_uri, idx_dic):
     if not thread_uri or not idx_dic:
 
 def thread_idx_updated(thread_uri, idx_dic):
     if not thread_uri or not idx_dic:
@@ -74,24 +76,30 @@ def on_thread_idx_updated(thread_uri, idx_dic):
     if winwrap:
         winwrap.on_thread_idx_updated(thread_uri, idx_dic)
 
     if winwrap:
         winwrap.on_thread_idx_updated(thread_uri, idx_dic)
 
+def do_on_window_destroy(uri, winwrap):
+    print "window destroyed:", uri
+    
 def main_quit():
     print "session main quit"
 
 def main_quit():
     print "session main quit"
 
-    tmp_win_dict = dict(_windows)
     uris = _windows.keys()
     uris = _windows.keys()
-    if uris:
+    try:
         gconf_client = gconf.client_get_default()
         gconf_client = gconf.client_get_default()
-        try:
+        if uris:
             gconf_client.set_list(
                 _gconf_key_windows, gconf.VALUE_STRING, uris)
             print "save windows", uris
             gconf_client.set_list(
                 _gconf_key_windows, gconf.VALUE_STRING, uris)
             print "save windows", uris
-        except:
-            pass
+        else:
+            gconf_client.unset(_gconf_key_windows)
+            print "save no window"
+    except:
+        pass
 
 
-    for uri, winwrap in tmp_win_dict.iteritems():
-        winwrap.window.destroy()
+    for uri, value in _windows.iteritems():
+        value["winwrap"].window.disconnect(value["handler_id"])
+        value["winwrap"].window.destroy()
+        do_on_window_destroy(uri, value["winwrap"])
 
 
-    # do not reach here
     gtk.main_quit()
 
 def restore():
     gtk.main_quit()
 
 def restore():