Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar
This commit is contained in:
commit
cd0a2b3ecd
@ -101,6 +101,7 @@ class HomeModel(gobject.GObject):
|
|||||||
self._remove_activity(window.get_xid())
|
self._remove_activity(window.get_xid())
|
||||||
if not self._activities:
|
if not self._activities:
|
||||||
self.emit('active-activity-changed', None)
|
self.emit('active-activity-changed', None)
|
||||||
|
self._notify_activity_activation(self._current_activity, None)
|
||||||
|
|
||||||
def _get_activity_by_xid(self, xid):
|
def _get_activity_by_xid(self, xid):
|
||||||
for act in self._activities.values():
|
for act in self._activities.values():
|
||||||
@ -108,10 +109,25 @@ class HomeModel(gobject.GObject):
|
|||||||
return act
|
return act
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def _notify_activity_activation(self, old_activity, new_activity):
|
||||||
|
if old_activity == new_activity:
|
||||||
|
return
|
||||||
|
|
||||||
|
if old_activity:
|
||||||
|
service = old_activity.get_service()
|
||||||
|
if service:
|
||||||
|
service.set_active(False)
|
||||||
|
|
||||||
|
if new_activity:
|
||||||
|
service = new_activity.get_service()
|
||||||
|
if service:
|
||||||
|
service.set_active(True)
|
||||||
|
|
||||||
def _active_window_changed_cb(self, screen):
|
def _active_window_changed_cb(self, screen):
|
||||||
window = screen.get_active_window()
|
window = screen.get_active_window()
|
||||||
if window == None:
|
if window == None:
|
||||||
self.emit('active-activity-changed', None)
|
self.emit('active-activity-changed', None)
|
||||||
|
self._notify_activity_activation(self._current_activity, None)
|
||||||
return
|
return
|
||||||
if window.get_window_type() != wnck.WINDOW_NORMAL:
|
if window.get_window_type() != wnck.WINDOW_NORMAL:
|
||||||
return
|
return
|
||||||
@ -120,11 +136,14 @@ class HomeModel(gobject.GObject):
|
|||||||
act = self._get_activity_by_xid(window.get_xid())
|
act = self._get_activity_by_xid(window.get_xid())
|
||||||
if act:
|
if act:
|
||||||
if act.get_launched() == True:
|
if act.get_launched() == True:
|
||||||
|
self._notify_activity_activation(self._current_activity, act)
|
||||||
self._current_activity = act
|
self._current_activity = act
|
||||||
else:
|
else:
|
||||||
|
self._notify_activity_activation(self._current_activity, None)
|
||||||
self._current_activity = None
|
self._current_activity = None
|
||||||
logging.error('Activity for window %d was not yet launched.' % xid)
|
logging.error('Activity for window %d was not yet launched.' % xid)
|
||||||
else:
|
else:
|
||||||
|
self._notify_activity_activation(self._current_activity, None)
|
||||||
self._current_activity = None
|
self._current_activity = None
|
||||||
logging.error('Model for window %d does not exist.' % xid)
|
logging.error('Model for window %d does not exist.' % xid)
|
||||||
|
|
||||||
|
@ -146,6 +146,10 @@ class Activity(Window, gtk.Container):
|
|||||||
'joined': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([]))
|
'joined': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([]))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__gproperties__ = {
|
||||||
|
'active': (bool, None, None, False, gobject.PARAM_READWRITE)
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, handle, create_jobject=True):
|
def __init__(self, handle, create_jobject=True):
|
||||||
"""Initialise the Activity
|
"""Initialise the Activity
|
||||||
|
|
||||||
@ -175,6 +179,7 @@ class Activity(Window, gtk.Container):
|
|||||||
|
|
||||||
self.connect('destroy', self._destroy_cb)
|
self.connect('destroy', self._destroy_cb)
|
||||||
|
|
||||||
|
self._active = False
|
||||||
self._activity_id = handle.activity_id
|
self._activity_id = handle.activity_id
|
||||||
self._pservice = presenceservice.get_instance()
|
self._pservice = presenceservice.get_instance()
|
||||||
self._shared_activity = None
|
self._shared_activity = None
|
||||||
@ -213,7 +218,16 @@ class Activity(Window, gtk.Container):
|
|||||||
else:
|
else:
|
||||||
self.jobject = None
|
self.jobject = None
|
||||||
|
|
||||||
self.connect('focus-out-event', self._focus_out_event_cb)
|
def do_set_property(self, pspec, value):
|
||||||
|
if pspec.name == 'active':
|
||||||
|
if self._active != value:
|
||||||
|
self._active = value
|
||||||
|
if not self._active and self.jobject:
|
||||||
|
self.save()
|
||||||
|
|
||||||
|
def do_get_property(self, pspec):
|
||||||
|
if pspec.name == 'active':
|
||||||
|
return self._active
|
||||||
|
|
||||||
def _internal_jobject_create_cb(self):
|
def _internal_jobject_create_cb(self):
|
||||||
pass
|
pass
|
||||||
@ -221,10 +235,6 @@ class Activity(Window, gtk.Container):
|
|||||||
def _internal_jobject_error_cb(self, err):
|
def _internal_jobject_error_cb(self, err):
|
||||||
logging.debug("Error creating activity datastore object: %s" % err)
|
logging.debug("Error creating activity datastore object: %s" % err)
|
||||||
|
|
||||||
def _focus_out_event_cb(self, widget, event):
|
|
||||||
if self.jobject:
|
|
||||||
self.save()
|
|
||||||
|
|
||||||
def read_file(self):
|
def read_file(self):
|
||||||
"""
|
"""
|
||||||
Subclasses implement this method if they support resuming objects from
|
Subclasses implement this method if they support resuming objects from
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
# Boston, MA 02111-1307, USA.
|
# Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
import dbus
|
import dbus
|
||||||
import dbus.service
|
import dbus.service
|
||||||
|
|
||||||
@ -81,3 +83,7 @@ class ActivityService(dbus.service.Object):
|
|||||||
def execute(self, command, args):
|
def execute(self, command, args):
|
||||||
return self._activity.execute(command, args)
|
return self._activity.execute(command, args)
|
||||||
|
|
||||||
|
@dbus.service.method(_ACTIVITY_INTERFACE)
|
||||||
|
def set_active(self, active):
|
||||||
|
logging.debug('ActivityService.set_active: %s.' % active)
|
||||||
|
self._activity.props.active = active
|
||||||
|
@ -34,32 +34,13 @@ except Exception, e:
|
|||||||
_data_store = None
|
_data_store = None
|
||||||
logging.error(e)
|
logging.error(e)
|
||||||
|
|
||||||
def get_contents(filename):
|
|
||||||
if not filename:
|
|
||||||
return ''
|
|
||||||
f = open(filename, "r")
|
|
||||||
try:
|
|
||||||
contents = f.read()
|
|
||||||
finally:
|
|
||||||
f.close()
|
|
||||||
return contents
|
|
||||||
|
|
||||||
def create(properties, filename):
|
def create(properties, filename):
|
||||||
logging.debug('dbus_helpers.create: %s, %s' % (properties, filename))
|
|
||||||
try:
|
|
||||||
logging.debug(get_contents(filename))
|
|
||||||
except UnicodeDecodeError:
|
|
||||||
pass
|
|
||||||
object_id = _data_store.create(dbus.Dictionary(properties), filename)
|
object_id = _data_store.create(dbus.Dictionary(properties), filename)
|
||||||
logging.debug('dbus_helpers.create: ' + object_id)
|
logging.debug('dbus_helpers.create: ' + object_id)
|
||||||
return object_id
|
return object_id
|
||||||
|
|
||||||
def update(uid, properties, filename, reply_handler=None, error_handler=None):
|
def update(uid, properties, filename, reply_handler=None, error_handler=None):
|
||||||
logging.debug('dbus_helpers.update: %s, %s, %s' % (uid, properties, filename))
|
logging.debug('dbus_helpers.update')
|
||||||
try:
|
|
||||||
logging.debug(get_contents(filename))
|
|
||||||
except UnicodeDecodeError:
|
|
||||||
pass
|
|
||||||
if reply_handler and error_handler:
|
if reply_handler and error_handler:
|
||||||
_data_store.update(uid, dbus.Dictionary(properties), filename,
|
_data_store.update(uid, dbus.Dictionary(properties), filename,
|
||||||
reply_handler=reply_handler,
|
reply_handler=reply_handler,
|
||||||
@ -68,20 +49,16 @@ def update(uid, properties, filename, reply_handler=None, error_handler=None):
|
|||||||
_data_store.update(uid, dbus.Dictionary(properties), filename)
|
_data_store.update(uid, dbus.Dictionary(properties), filename)
|
||||||
|
|
||||||
def get_properties(uid):
|
def get_properties(uid):
|
||||||
props = _data_store.get_properties(uid)
|
logging.debug('dbus_helpers.get_properties: %s' % uid)
|
||||||
logging.debug('dbus_helpers.get_properties: %s, %s' % (uid, props))
|
return _data_store.get_properties(uid)
|
||||||
return props
|
|
||||||
|
|
||||||
def get_filename(uid):
|
def get_filename(uid):
|
||||||
filename = _data_store.get_filename(uid)
|
filename = _data_store.get_filename(uid)
|
||||||
logging.debug('dbus_helpers.get_filename: %s, %s' % (uid, filename))
|
logging.debug('dbus_helpers.get_filename: %s, %s' % (uid, filename))
|
||||||
try:
|
|
||||||
logging.debug(get_contents(filename))
|
|
||||||
except UnicodeDecodeError:
|
|
||||||
pass
|
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
def find(query, reply_handler, error_handler):
|
def find(query, reply_handler, error_handler):
|
||||||
|
logging.debug('dbus_helpers.find')
|
||||||
if reply_handler and error_handler:
|
if reply_handler and error_handler:
|
||||||
return _data_store.find(query, reply_handler=reply_handler,
|
return _data_store.find(query, reply_handler=reply_handler,
|
||||||
error_handler=error_handler)
|
error_handler=error_handler)
|
||||||
|
@ -40,7 +40,6 @@ class ComboBox(gtk.ComboBox):
|
|||||||
self.set_model(self._model)
|
self.set_model(self._model)
|
||||||
|
|
||||||
self.set_row_separator_func(self._is_separator)
|
self.set_row_separator_func(self._is_separator)
|
||||||
self.connect('realize', self._realize_cb)
|
|
||||||
|
|
||||||
def do_get_property(self, pspec):
|
def do_get_property(self, pspec):
|
||||||
if pspec.name == 'value':
|
if pspec.name == 'value':
|
||||||
@ -49,10 +48,6 @@ class ComboBox(gtk.ComboBox):
|
|||||||
else:
|
else:
|
||||||
return gtk.ComboBox.do_get_property(self, pspec)
|
return gtk.ComboBox.do_get_property(self, pspec)
|
||||||
|
|
||||||
def _realize_cb(self, widget, data=None):
|
|
||||||
if self.get_active() == -1:
|
|
||||||
self.set_active(0)
|
|
||||||
|
|
||||||
def append_item(self, action_id, text, icon_name=None):
|
def append_item(self, action_id, text, icon_name=None):
|
||||||
if not self._icon_renderer and icon_name:
|
if not self._icon_renderer and icon_name:
|
||||||
self._icon_renderer = gtk.CellRendererPixbuf()
|
self._icon_renderer = gtk.CellRendererPixbuf()
|
||||||
|
Loading…
Reference in New Issue
Block a user