diff options
author | Marco Pesenti Gritti <mpgritti@gmail.com> | 2008-10-21 23:19:29 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <mpgritti@gmail.com> | 2008-10-21 23:19:29 (GMT) |
commit | a39d2b92d95e14f6d3470a00f37818a26dda0881 (patch) | |
tree | 64e0d4eb893f63ee6e067ad6c6078f9c0aa1cbd7 | |
parent | c9a13a716f6c2666f8a2460512819c55f14b1067 (diff) | |
parent | 5596f6c64d5b4328c6b2acd02ec1623113797929 (diff) |
Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar
-rw-r--r-- | bin/sugar-emulator | 6 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | data/sugar.schemas.in | 23 | ||||
-rw-r--r-- | src/jarabe/Makefile.am | 3 | ||||
-rw-r--r-- | src/jarabe/desktop/favoriteslayout.py | 2 | ||||
-rw-r--r-- | src/jarabe/desktop/favoritesview.py | 60 | ||||
-rw-r--r-- | src/jarabe/util/Makefile.am | 6 | ||||
-rw-r--r-- | src/jarabe/util/__init__.py | 19 | ||||
-rw-r--r-- | src/jarabe/util/telepathy/Makefile.am | 4 | ||||
-rw-r--r-- | src/jarabe/util/telepathy/__init__.py | 19 | ||||
-rw-r--r-- | src/jarabe/util/telepathy/connection_watcher.py | 108 |
11 files changed, 215 insertions, 37 deletions
diff --git a/bin/sugar-emulator b/bin/sugar-emulator index 33bd71f..4daba14 100644 --- a/bin/sugar-emulator +++ b/bin/sugar-emulator @@ -91,8 +91,10 @@ def main(): """Script-level operations""" parser = OptionParser() - parser.add_option('-d', '--dpi', dest='dpi', help='Emulator dpi') - parser.add_option('-s', '--scaling', dest='scaling', help='Sugar scaling') + parser.add_option('-d', '--dpi', dest='dpi', type="int", + help='Emulator dpi') + parser.add_option('-s', '--scaling', dest='scaling', + help='Sugar scaling in %') parser.add_option('-i', '--dimensions', dest='dimensions', help='Emulator dimensions (ex. 1200x900)') (options, args) = parser.parse_args() diff --git a/configure.ac b/configure.ac index c54b12d..87c21fe 100644 --- a/configure.ac +++ b/configure.ac @@ -70,5 +70,7 @@ src/jarabe/journal/Makefile src/jarabe/view/Makefile src/jarabe/model/Makefile src/jarabe/service/Makefile +src/jarabe/util/Makefile +src/jarabe/util/telepathy/Makefile po/Makefile.in ]) diff --git a/data/sugar.schemas.in b/data/sugar.schemas.in index 5cdff4d..e704013 100644 --- a/data/sugar.schemas.in +++ b/data/sugar.schemas.in @@ -120,17 +120,6 @@ <long>Url of the jabber server to use.</long> </locale> </schema> - <schema> - <key>/schemas/desktop/sugar/collaboration/jabber_registered</key> - <applyto>/desktop/sugar/collaboration/jabber_registered</applyto> - <owner>sugar</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Jabber Registered</short> - <long>Flag to keep track of the registration status with the jabber server.</long> - </locale> - </schema> <schema> <key>/schemas/desktop/sugar/power/automatic</key> @@ -155,5 +144,17 @@ </locale> </schema> + <schema> + <key>/schemas/desktop/sugar/collaboration/publish_gadget</key> + <applyto>/desktop/sugar/collaboration/publish_gadget</applyto> + <owner>sugar</owner> + <type>bool</type> + <default>true</default> + <locale name="C"> + <short>Publish to Gadget</short> + <long>If TRUE, Sugar will make us searchable for the other users of the Jabber server.</long> + </locale> + </schema> + </schemalist> </gconfschemafile> diff --git a/src/jarabe/Makefile.am b/src/jarabe/Makefile.am index 04890b4..cf25785 100644 --- a/src/jarabe/Makefile.am +++ b/src/jarabe/Makefile.am @@ -6,7 +6,8 @@ SUBDIRS = \ model \ view \ intro \ - service + service \ + util sugardir = $(pythondir)/jarabe sugar_PYTHON = \ diff --git a/src/jarabe/desktop/favoriteslayout.py b/src/jarabe/desktop/favoriteslayout.py index 9438e56..b286126 100644 --- a/src/jarabe/desktop/favoriteslayout.py +++ b/src/jarabe/desktop/favoriteslayout.py @@ -56,7 +56,6 @@ class FavoritesLayout(gobject.GObject, hippo.CanvasLayout): return 0 def append(self, icon, locked=False): - self.box.insert_sorted(icon, 0, self.compare_activities) if hasattr(icon, 'fixed_position'): relative_x, relative_y = icon.fixed_position if relative_x >= 0 and relative_y >= 0: @@ -69,7 +68,6 @@ class FavoritesLayout(gobject.GObject, hippo.CanvasLayout): def remove(self, icon): if icon in self.fixed_positions: del self.fixed_positions[icon] - self.box.remove(icon) def move_icon(self, icon, x, y, locked=False): if icon not in self.box.get_children(): diff --git a/src/jarabe/desktop/favoritesview.py b/src/jarabe/desktop/favoritesview.py index 3db90ac..926f143 100644 --- a/src/jarabe/desktop/favoritesview.py +++ b/src/jarabe/desktop/favoritesview.py @@ -87,8 +87,12 @@ class FavoritesView(hippo.Canvas): self._box.props.background_color = style.COLOR_WHITE.get_int() self.set_root(self._box) - self._my_icon = None - self._current_activity = None + self._my_icon = _MyIcon(style.XLARGE_ICON_SIZE) + self._box.append(self._my_icon) + + self._current_activity = CurrentActivityIcon() + self._box.append(self._current_activity) + self._layout = None self._alert = None @@ -106,6 +110,12 @@ class FavoritesView(hippo.Canvas): def __connect_to_bundle_registry_cb(self): registry = bundleregistry.get_registry() + + for info in registry: + if registry.is_bundle_favorite(info.get_bundle_id(), + info.get_activity_version()): + self._add_activity(info) + registry.connect('bundle-added', self.__activity_added_cb) registry.connect('bundle-removed', self.__activity_removed_cb) registry.connect('bundle-changed', self.__activity_changed_cb) @@ -114,6 +124,7 @@ class FavoritesView(hippo.Canvas): icon = ActivityIcon(activity_info) icon.connect('erase-activated', self.__erase_activated_cb) icon.props.size = style.STANDARD_ICON_SIZE + self._box.insert_sorted(icon, 0, self._layout.compare_activities) self._layout.append(icon) def __erase_activated_cb(self, activity_icon, bundle_id): @@ -137,6 +148,7 @@ class FavoritesView(hippo.Canvas): activity_info.get_activity_version()) if icon is not None: self._layout.remove(icon) + self._box.remove(icon) def __activity_changed_cb(self, activity_registry, activity_info): if activity_info.get_bundle_id() == 'org.laptop.JournalActivity': @@ -265,30 +277,36 @@ class FavoritesView(hippo.Canvas): def _set_layout(self, layout): if layout not in LAYOUT_MAP: raise ValueError('Unknown favorites layout: %r' % layout) - if type(self._layout) != LAYOUT_MAP[layout]: - self._box.clear() - self._layout = LAYOUT_MAP[layout]() - self._box.set_layout(self._layout) - self._my_icon = _MyIcon(style.XLARGE_ICON_SIZE) - self._layout.append(self._my_icon, locked=True) + if type(self._layout) == LAYOUT_MAP[layout]: + return - self._current_activity = CurrentActivityIcon() - self._layout.append(self._current_activity, locked=True) + self._layout = LAYOUT_MAP[layout]() + self._box.set_layout(self._layout) + + #TODO: compatibility hack while sort() gets added to the hippo + # python bindings + if hasattr(self._box, 'sort'): + self._box.sort(self._layout.compare_activities) + else: + icons = self._box.get_children() + self._box.clear() + for icon in icons: + self._box.insert_sorted(icon, 0, self._layout.compare_activities) - registry = bundleregistry.get_registry() - for info in registry: - if registry.is_bundle_favorite(info.get_bundle_id(), - info.get_activity_version()): - self._add_activity(info) + for icon in self._box.get_children(): + if icon not in [self._my_icon, self._current_activity]: + self._layout.append(icon) + self._layout.append(self._my_icon, locked=True) + self._layout.append(self._current_activity, locked=True) - if self._layout.allow_dnd(): - self.drag_source_set(0, [], 0) - self.drag_dest_set(0, [], 0) - else: - self.drag_source_unset() - self.drag_dest_unset() + if self._layout.allow_dnd(): + self.drag_source_set(0, [], 0) + self.drag_dest_set(0, [], 0) + else: + self.drag_source_unset() + self.drag_dest_unset() layout = property(None, _set_layout) diff --git a/src/jarabe/util/Makefile.am b/src/jarabe/util/Makefile.am new file mode 100644 index 0000000..4046fe8 --- /dev/null +++ b/src/jarabe/util/Makefile.am @@ -0,0 +1,6 @@ +SUBDIRS = \ + telepathy + +sugardir = $(pythondir)/jarabe/util +sugar_PYTHON = \ + __init__.py diff --git a/src/jarabe/util/__init__.py b/src/jarabe/util/__init__.py new file mode 100644 index 0000000..1610dd0 --- /dev/null +++ b/src/jarabe/util/__init__.py @@ -0,0 +1,19 @@ +"""OLPC Sugar Jarabe utility modules +""" + +# Copyright (C) 2008, One Laptop Per Child +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + diff --git a/src/jarabe/util/telepathy/Makefile.am b/src/jarabe/util/telepathy/Makefile.am new file mode 100644 index 0000000..d40349d --- /dev/null +++ b/src/jarabe/util/telepathy/Makefile.am @@ -0,0 +1,4 @@ +sugardir = $(pythondir)/jarabe/util/telepathy +sugar_PYTHON = \ + __init__.py \ + connection_watcher.py diff --git a/src/jarabe/util/telepathy/__init__.py b/src/jarabe/util/telepathy/__init__.py new file mode 100644 index 0000000..387d09c --- /dev/null +++ b/src/jarabe/util/telepathy/__init__.py @@ -0,0 +1,19 @@ +"""OLPC Sugar Jarabe utility telepathy modules +""" + +# Copyright (C) 2008, One Laptop Per Child +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + diff --git a/src/jarabe/util/telepathy/connection_watcher.py b/src/jarabe/util/telepathy/connection_watcher.py new file mode 100644 index 0000000..27f506f --- /dev/null +++ b/src/jarabe/util/telepathy/connection_watcher.py @@ -0,0 +1,108 @@ +# This should eventually land in telepathy-python, so has the same license: +# Copyright (C) 2008 Collabora Ltd. <http://www.collabora.co.uk/> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# FIXME: should we really put this in sugar-toolkit/src/sugar/presence ? + +import dbus +import dbus.mainloop.glib +import gobject + +from telepathy.client import Connection +from telepathy.interfaces import CONN_INTERFACE +from telepathy.constants import CONNECTION_STATUS_CONNECTED, CONNECTION_STATUS_DISCONNECTED + +class ConnectionWatcher(gobject.GObject): + __gsignals__ = { + 'connection-added': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, + ([gobject.TYPE_PYOBJECT])), + 'connection-removed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, + ([gobject.TYPE_PYOBJECT])), + } + + def __init__(self, bus=None): + gobject.GObject.__init__(self) + + if bus is None: + self.bus = dbus.Bus() + else: + self.bus = bus + + # D-Bus path -> Connection + self._connections = {} + + self.bus.add_signal_receiver(self._status_changed_cb, + dbus_interface=CONN_INTERFACE, signal_name='StatusChanged', + path_keyword='path') + + for conn in Connection.get_connections(bus): + conn.call_when_ready(self._conn_ready_cb) + + def _status_changed_cb(self, *args, **kwargs): + path = kwargs['path'] + if not path.startswith('/org/freedesktop/Telepathy/Connection/'): + return + + status, reason = args + service_name = path.replace('/', '.')[1:] + + if status == CONNECTION_STATUS_CONNECTED: + self._add_connection(service_name, path) + elif status == CONNECTION_STATUS_DISCONNECTED: + self._remove_connection(service_name, path) + + def _conn_ready_cb(self, conn): + if conn.object_path in self._connections: + return + + self._connections[conn.object_path] = conn + self.emit('connection-added', conn) + + def _add_connection(self, service_name, path): + if path in self._connections: + return + + try: + Connection(service_name, path, ready_handler=self._conn_ready_cb) + except dbus.exceptions.DBusException: + # The service is probably already gone + pass + + def _remove_connection(self, service_name, path): + conn = self._connections.pop(path, None) + if conn is None: + return + + self.emit('connection-removed', conn) + + def get_connections(self): + return self._connections.values() + +if __name__ == '__main__': + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) + + def connection_added_cb(watcher, conn): + print "new connection", conn.service_name + + def connection_removed_cb(watcher, conn): + print "removed connection", conn.service_name + + watcher = ConnectionWatcher() + watcher.connect('connection-added', connection_added_cb) + watcher.connect('connection-removed', connection_removed_cb) + + loop = gobject.MainLoop() + loop.run() |