Trap X errors in wm.py (#1123)
This commit is contained in:
parent
3ce0a0253b
commit
d304f72872
@ -20,11 +20,37 @@ UNSTABLE. Used only internally by Activity and jarabe.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import gtk
|
import gtk
|
||||||
|
import logging
|
||||||
|
|
||||||
|
def _property_get_trapped(window, prop, prop_type):
|
||||||
|
gtk.gdk.error_trap_push()
|
||||||
|
|
||||||
|
prop_info = window.property_get('_SUGAR_ACTIVITY_ID', 'STRING')
|
||||||
|
|
||||||
|
# We just log a message
|
||||||
|
error = gtk.gdk.error_trap_pop()
|
||||||
|
if gtk.gdk.error_trap_pop():
|
||||||
|
logging.debug('Received X Error (%i) while getting '
|
||||||
|
'a property on a window' % error)
|
||||||
|
|
||||||
|
return prop_info
|
||||||
|
|
||||||
|
def _property_change_trapped(window, prop, prop_type, format, mode, data):
|
||||||
|
gtk.gdk.error_trap_push()
|
||||||
|
|
||||||
|
window.property_change(prop, prop_type, format, mode, data)
|
||||||
|
|
||||||
|
error = gtk.gdk.error_trap_pop()
|
||||||
|
if error:
|
||||||
|
logging.debug('Received X Error (%i) while setting '
|
||||||
|
'a property on a window' % error)
|
||||||
|
raise RuntimeError('Received X Error (%i) while setting '
|
||||||
|
'a property on a window' % error)
|
||||||
|
|
||||||
|
|
||||||
def get_activity_id(wnck_window):
|
def get_activity_id(wnck_window):
|
||||||
window = gtk.gdk.window_foreign_new(wnck_window.get_xid())
|
window = gtk.gdk.window_foreign_new(wnck_window.get_xid())
|
||||||
prop_info = window.property_get('_SUGAR_ACTIVITY_ID', 'STRING')
|
prop_info = _property_get_trapped(window, '_SUGAR_ACTIVITY_ID', 'STRING')
|
||||||
if prop_info is None:
|
if prop_info is None:
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
@ -33,7 +59,7 @@ def get_activity_id(wnck_window):
|
|||||||
|
|
||||||
def get_bundle_id(wnck_window):
|
def get_bundle_id(wnck_window):
|
||||||
window = gtk.gdk.window_foreign_new(wnck_window.get_xid())
|
window = gtk.gdk.window_foreign_new(wnck_window.get_xid())
|
||||||
prop_info = window.property_get('_SUGAR_BUNDLE_ID', 'STRING')
|
prop_info = _property_get_trapped(window, '_SUGAR_BUNDLE_ID', 'STRING')
|
||||||
if prop_info is None:
|
if prop_info is None:
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
@ -41,10 +67,11 @@ def get_bundle_id(wnck_window):
|
|||||||
|
|
||||||
|
|
||||||
def set_activity_id(window, activity_id):
|
def set_activity_id(window, activity_id):
|
||||||
window.property_change('_SUGAR_ACTIVITY_ID', 'STRING', 8,
|
_property_change_trapped(window, '_SUGAR_ACTIVITY_ID', 'STRING', 8,
|
||||||
gtk.gdk.PROP_MODE_REPLACE, activity_id)
|
gtk.gdk.PROP_MODE_REPLACE, activity_id)
|
||||||
|
|
||||||
|
|
||||||
def set_bundle_id(window, bundle_id):
|
def set_bundle_id(window, bundle_id):
|
||||||
window.property_change('_SUGAR_BUNDLE_ID', 'STRING', 8,
|
_property_change_trapped(window, '_SUGAR_BUNDLE_ID', 'STRING', 8,
|
||||||
gtk.gdk.PROP_MODE_REPLACE, bundle_id)
|
gtk.gdk.PROP_MODE_REPLACE, bundle_id)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user