From be8cd3de7e6dea5c50dcba91cb32803a1e1b31b5 Mon Sep 17 00:00:00 2001 From: Simon Schampijer Date: Wed, 21 Jan 2009 17:01:38 +0000 Subject: Merge branch 'master' of gitorious@git.sugarlabs.org:sugar/mainline --- (limited to 'src') diff --git a/src/jarabe/desktop/favoriteslayout.py b/src/jarabe/desktop/favoriteslayout.py index a82f6bf..010b344 100644 --- a/src/jarabe/desktop/favoriteslayout.py +++ b/src/jarabe/desktop/favoriteslayout.py @@ -56,14 +56,20 @@ class FavoritesLayout(gobject.GObject, hippo.CanvasLayout): return 0 def append(self, icon, locked=False): - if hasattr(icon, 'fixed_position'): - relative_x, relative_y = icon.fixed_position - if relative_x >= 0 and relative_y >= 0: - min_width_, width = self.box.get_width_request() - min_height_, height = self.box.get_height_request(width) - self.fixed_positions[icon] = \ - (int(relative_x * _BASE_SCALE / float(width)), - int(relative_y * _BASE_SCALE / float(height))) + if not hasattr(type(icon), 'fixed_position'): + logging.debug('Icon without fixed_position: %r' % icon) + return + + relative_x, relative_y = icon.fixed_position + if relative_x < 0 or relative_y < 0: + logging.debug('Icon out of bounds: %r' % icon) + return + + min_width_, width = self.box.get_width_request() + min_height_, height = self.box.get_height_request(width) + self.fixed_positions[icon] = \ + (int(relative_x * _BASE_SCALE / float(width)), + int(relative_y * _BASE_SCALE / float(height))) def remove(self, icon): if icon in self.fixed_positions: @@ -73,15 +79,18 @@ class FavoritesLayout(gobject.GObject, hippo.CanvasLayout): if icon not in self.box.get_children(): raise ValueError('Child not in box.') - if hasattr(icon, 'get_bundle_id') and hasattr(icon, 'get_version'): - min_width_, width = self.box.get_width_request() - min_height_, height = self.box.get_height_request(width) - registry = bundleregistry.get_registry() - registry.set_bundle_position( - icon.get_bundle_id(), icon.get_version(), - x * width / float(_BASE_SCALE), - y * height / float(_BASE_SCALE)) - self.fixed_positions[icon] = (x, y) + if not(hasattr(icon, 'get_bundle_id') and hasattr(icon, 'get_version')): + logging.debug('Not an activity icon %r' % icon) + return + + min_width_, width = self.box.get_width_request() + min_height_, height = self.box.get_height_request(width) + registry = bundleregistry.get_registry() + registry.set_bundle_position( + icon.get_bundle_id(), icon.get_version(), + x * width / float(_BASE_SCALE), + y * height / float(_BASE_SCALE)) + self.fixed_positions[icon] = (x, y) def do_allocate(self, x, y, width, height, req_width, req_height, origin_changed): diff --git a/src/jarabe/desktop/favoritesview.py b/src/jarabe/desktop/favoritesview.py index 561b26b..03dd407 100644 --- a/src/jarabe/desktop/favoritesview.py +++ b/src/jarabe/desktop/favoritesview.py @@ -546,7 +546,8 @@ class ActivityIcon(CanvasIcon): installation_time = property(_get_installation_time, None) def _get_fixed_position(self): - return self._activity_info.position + registry = bundleregistry.get_registry() + return registry.get_bundle_position(self.bundle_id, self.version) fixed_position = property(_get_fixed_position, None) class FavoritePalette(ActivityPalette): diff --git a/src/jarabe/journal/palettes.py b/src/jarabe/journal/palettes.py index 99db82f..a56d373 100644 --- a/src/jarabe/journal/palettes.py +++ b/src/jarabe/journal/palettes.py @@ -151,18 +151,25 @@ class FriendsMenu(gtk.Menu): def __init__(self): gobject.GObject.__init__(self) - friends_model = friends.get_model() - for friend in friends_model: - if friend.is_present(): - menu_item = MenuItem(text_label=friend.get_nick(), - icon_name='computer-xo', - xo_color=friend.get_color()) - menu_item.connect('activate', self.__item_activate_cb, friend) + if filetransfer.file_transfer_available(): + friends_model = friends.get_model() + for friend in friends_model: + if friend.is_present(): + menu_item = MenuItem(text_label=friend.get_nick(), + icon_name='computer-xo', + xo_color=friend.get_color()) + menu_item.connect('activate', self.__item_activate_cb, + friend) + self.append(menu_item) + menu_item.show() + + if not self.get_children(): + menu_item = MenuItem(_('No friends present')) + menu_item.set_sensitive(False) self.append(menu_item) - menu_item.show() - - if not self.get_children(): - menu_item = MenuItem(_('No friends present')) + menu_item.show() + else: + menu_item = MenuItem(_('No valid connection found')) menu_item.set_sensitive(False) self.append(menu_item) menu_item.show() diff --git a/src/jarabe/model/filetransfer.py b/src/jarabe/model/filetransfer.py index 781b4e1..c66a19c 100644 --- a/src/jarabe/model/filetransfer.py +++ b/src/jarabe/model/filetransfer.py @@ -315,11 +315,14 @@ def _monitor_connection(connection): def _connection_addded_cb(conn_watcher, connection): _monitor_connection(connection) +_conn_watcher = None + def init(): - conn_watcher = connection_watcher.ConnectionWatcher() - conn_watcher.connect('connection-added', _connection_addded_cb) + global _conn_watcher + _conn_watcher = connection_watcher.ConnectionWatcher() + _conn_watcher.connect('connection-added', _connection_addded_cb) - for connection in conn_watcher.get_connections(): + for connection in _conn_watcher.get_connections(): _monitor_connection(connection) def start_transfer(buddy, file_name, title, description, mime_type): @@ -327,5 +330,23 @@ def start_transfer(buddy, file_name, title, description, mime_type): description, mime_type) new_file_transfer.send(None, file_transfer=outgoing_file_transfer) +def file_transfer_available(): + for connection in _conn_watcher.get_connections(): + + properties_iface = connection[dbus.PROPERTIES_IFACE] + properties = properties_iface.GetAll(CONNECTION_INTERFACE_REQUESTS) + classes = properties['RequestableChannelClasses'] + for prop, allowed_prop in classes: + + channel_type = prop.get(CHANNEL + '.ChannelType', '') + target_handle_type = prop.get(CHANNEL + '.TargetHandleType', '') + + if len(prop) == 2 and \ + channel_type == CHANNEL_TYPE_FILE_TRANSFER and \ + target_handle_type == CONNECTION_HANDLE_TYPE_CONTACT: + return True + + return False + new_file_transfer = dispatch.Signal() -- cgit v0.9.1