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())
|
||||
if not self._activities:
|
||||
self.emit('active-activity-changed', None)
|
||||
self._notify_activity_activation(self._current_activity, None)
|
||||
|
||||
def _get_activity_by_xid(self, xid):
|
||||
for act in self._activities.values():
|
||||
@ -108,10 +109,25 @@ class HomeModel(gobject.GObject):
|
||||
return act
|
||||
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):
|
||||
window = screen.get_active_window()
|
||||
if window == None:
|
||||
self.emit('active-activity-changed', None)
|
||||
self._notify_activity_activation(self._current_activity, None)
|
||||
return
|
||||
if window.get_window_type() != wnck.WINDOW_NORMAL:
|
||||
return
|
||||
@ -120,11 +136,14 @@ class HomeModel(gobject.GObject):
|
||||
act = self._get_activity_by_xid(window.get_xid())
|
||||
if act:
|
||||
if act.get_launched() == True:
|
||||
self._notify_activity_activation(self._current_activity, act)
|
||||
self._current_activity = act
|
||||
else:
|
||||
self._notify_activity_activation(self._current_activity, None)
|
||||
self._current_activity = None
|
||||
logging.error('Activity for window %d was not yet launched.' % xid)
|
||||
else:
|
||||
self._notify_activity_activation(self._current_activity, None)
|
||||
self._current_activity = None
|
||||
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, ([]))
|
||||
}
|
||||
|
||||
__gproperties__ = {
|
||||
'active': (bool, None, None, False, gobject.PARAM_READWRITE)
|
||||
}
|
||||
|
||||
def __init__(self, handle, create_jobject=True):
|
||||
"""Initialise the Activity
|
||||
|
||||
@ -175,6 +179,7 @@ class Activity(Window, gtk.Container):
|
||||
|
||||
self.connect('destroy', self._destroy_cb)
|
||||
|
||||
self._active = False
|
||||
self._activity_id = handle.activity_id
|
||||
self._pservice = presenceservice.get_instance()
|
||||
self._shared_activity = None
|
||||
@ -213,7 +218,16 @@ class Activity(Window, gtk.Container):
|
||||
else:
|
||||
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):
|
||||
pass
|
||||
@ -221,10 +235,6 @@ class Activity(Window, gtk.Container):
|
||||
def _internal_jobject_error_cb(self, 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):
|
||||
"""
|
||||
Subclasses implement this method if they support resuming objects from
|
||||
|
@ -15,6 +15,8 @@
|
||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
|
||||
import logging
|
||||
|
||||
import dbus
|
||||
import dbus.service
|
||||
|
||||
@ -81,3 +83,7 @@ class ActivityService(dbus.service.Object):
|
||||
def execute(self, 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
|
||||
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):
|
||||
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)
|
||||
logging.debug('dbus_helpers.create: ' + object_id)
|
||||
return object_id
|
||||
|
||||
def update(uid, properties, filename, reply_handler=None, error_handler=None):
|
||||
logging.debug('dbus_helpers.update: %s, %s, %s' % (uid, properties, filename))
|
||||
try:
|
||||
logging.debug(get_contents(filename))
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
logging.debug('dbus_helpers.update')
|
||||
if reply_handler and error_handler:
|
||||
_data_store.update(uid, dbus.Dictionary(properties), filename,
|
||||
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)
|
||||
|
||||
def get_properties(uid):
|
||||
props = _data_store.get_properties(uid)
|
||||
logging.debug('dbus_helpers.get_properties: %s, %s' % (uid, props))
|
||||
return props
|
||||
logging.debug('dbus_helpers.get_properties: %s' % uid)
|
||||
return _data_store.get_properties(uid)
|
||||
|
||||
def get_filename(uid):
|
||||
filename = _data_store.get_filename(uid)
|
||||
logging.debug('dbus_helpers.get_filename: %s, %s' % (uid, filename))
|
||||
try:
|
||||
logging.debug(get_contents(filename))
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
return filename
|
||||
|
||||
def find(query, reply_handler, error_handler):
|
||||
logging.debug('dbus_helpers.find')
|
||||
if reply_handler and error_handler:
|
||||
return _data_store.find(query, reply_handler=reply_handler,
|
||||
error_handler=error_handler)
|
||||
|
@ -40,7 +40,6 @@ class ComboBox(gtk.ComboBox):
|
||||
self.set_model(self._model)
|
||||
|
||||
self.set_row_separator_func(self._is_separator)
|
||||
self.connect('realize', self._realize_cb)
|
||||
|
||||
def do_get_property(self, pspec):
|
||||
if pspec.name == 'value':
|
||||
@ -49,10 +48,6 @@ class ComboBox(gtk.ComboBox):
|
||||
else:
|
||||
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):
|
||||
if not self._icon_renderer and icon_name:
|
||||
self._icon_renderer = gtk.CellRendererPixbuf()
|
||||
|
Loading…
Reference in New Issue
Block a user