Merge branch 'master' of gitorious@git.sugarlabs.org:sugar-toolkit/mainline

This commit is contained in:
Tomeu Vizoso 2009-09-01 11:28:07 +02:00
commit e3415afbc5
2 changed files with 36 additions and 6 deletions

View File

@ -400,3 +400,6 @@ class ActivityBundle(Bundle):
os.remove(path)
self._uninstall(install_path)
def is_user_activity(self):
return self.get_path().startswith(env.get_user_activities_path())

View File

@ -20,11 +20,37 @@ UNSTABLE. Used only internally by Activity and jarabe.
"""
import gtk
import logging
def _property_get_trapped(window, prop, prop_type):
gtk.gdk.error_trap_push()
prop_info = window.property_get(prop, prop_type)
# We just log a message
error = gtk.gdk.error_trap_pop()
if error:
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):
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:
return None
else:
@ -33,7 +59,7 @@ def get_activity_id(wnck_window):
def get_bundle_id(wnck_window):
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:
return None
else:
@ -41,10 +67,11 @@ def get_bundle_id(wnck_window):
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)
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)