Ticket #4398: feedback_in_zoom_views.patch
File feedback_in_zoom_views.patch, 22.0 KB (added by manuq, 11 years ago) |
---|
-
src/jarabe/desktop/favoriteslayout.py
diff --git a/src/jarabe/desktop/favoriteslayout.py b/src/jarabe/desktop/favoriteslayout.py index 635a534..6e2a195 100644
a b class ViewLayout(Layout): 52 52 self._width = 0 53 53 self._height = 0 54 54 55 def setup(self, allocation, owner_icon, activity_icon=None): 55 def setup(self, allocation, owner_icon, activity_icon=None, 56 message_box=None): 56 57 if self._grid is not None: 57 58 if self._width == allocation.width and \ 58 59 self._height == allocation.height: … … class ViewLayout(Layout): 62 63 self._grid = Grid(int(allocation.width / _CELL_SIZE), 63 64 int(allocation.height / _CELL_SIZE)) 64 65 self._grid.connect('child-changed', self.__grid_child_changed_cb) 65 self._allocate_owner_icon(allocation, owner_icon, activity_icon) 66 self.allocate_fixed_icons(allocation, owner_icon, activity_icon, 67 message_box) 68 69 def remove(self, child): 70 if self._grid is None: 71 # the Grid is created during allocation time, so it might not 72 # exist yet when this method is called, SL #3814 73 return 74 75 if self._grid.is_in_grid(child): 76 self._grid.remove(child) 77 78 def allocate_fixed_icons(self, allocation, owner_icon, activity_icon, 79 message_box): 80 # Add owner icon to the grid, precisely centered on the 81 # screen. If activity_icon is not None, add it directly below 82 # the owner icon. Also if message_box is not None, add it 83 # below the previously added icon. 66 84 67 def _allocate_owner_icon(self, allocation, owner_icon, activity_icon):68 # add owner icon to the grid, precisely centered on the screen69 # if not None, add an activity icon directly below the owner icon70 85 owner_request = owner_icon.size_request() 71 86 owner_width, owner_height = owner_request.width, owner_request.height 72 87 height = allocation.height + allocation.y … … class ViewLayout(Layout): 84 99 # coordinate for the top of the owner icon. 85 100 y -= owner_height / 2 86 101 102 current_y = allocation.y + y 103 87 104 # calculate x coordinate and create allocation 88 105 owner_icon_allocation = Gdk.Rectangle() 89 106 owner_icon_allocation.x = (width - owner_width) / 2 90 owner_icon_allocation.y = allocation.y +y107 owner_icon_allocation.y = current_y 91 108 owner_icon_allocation.width = owner_width 92 109 owner_icon_allocation.height = owner_height 93 110 owner_icon.size_allocate(owner_icon_allocation) … … class ViewLayout(Layout): 100 117 self._grid.add(owner_icon, owner_grid_width, owner_grid_height, 101 118 grid_x, grid_y, locked=True) 102 119 103 if activity_icon is None: 104 return 105 106 # Position the current activity below the XO icon 107 # FIXME must ensure we cross into next grid cell here.. 108 activity_request = activity_icon.size_request() 109 activity_icon_allocation = Gdk.Rectangle() 110 activity_icon_allocation.x = (width - activity_request.width) / 2 111 activity_icon_allocation.y = owner_icon_allocation.y + owner_height 112 activity_icon_allocation.width = activity_request.width 113 activity_icon_allocation.height = activity_request.height 114 activity_icon.size_allocate(activity_icon_allocation) 115 116 # Determine grid coordinates and add to grid 117 activity_grid_width, activity_grid_height = \ 118 self._get_child_grid_size(activity_icon) 119 x = int(activity_icon_allocation.x / float(_CELL_SIZE)) 120 y = int(activity_icon_allocation.y / float(_CELL_SIZE)) 121 self._grid.add(activity_icon, activity_grid_width, 122 activity_grid_height, x, y, locked=True) 120 current_y += owner_height 121 122 if activity_icon is not None: 123 # Position the current activity below the XO icon 124 # FIXME must ensure we cross into next grid cell here.. 125 activity_request = activity_icon.size_request() 126 activity_icon_allocation = Gdk.Rectangle() 127 activity_icon_allocation.x = (width - activity_request.width) / 2 128 activity_icon_allocation.y = current_y 129 activity_icon_allocation.width = activity_request.width 130 activity_icon_allocation.height = activity_request.height 131 activity_icon.size_allocate(activity_icon_allocation) 132 133 # Determine grid coordinates and add to grid 134 activity_grid_width, activity_grid_height = \ 135 self._get_child_grid_size(activity_icon) 136 x = int(activity_icon_allocation.x / float(_CELL_SIZE)) 137 y = int(activity_icon_allocation.y / float(_CELL_SIZE)) 138 self._grid.add(activity_icon, activity_grid_width, 139 activity_grid_height, x, y, locked=True) 140 141 current_y += activity_icon_allocation.height 142 143 if message_box is not None: 144 # Position the current activity below the XO icon 145 # FIXME must ensure we cross into next grid cell here.. 146 size_request = message_box.size_request() 147 allocation = Gdk.Rectangle() 148 allocation.x = (width - size_request.width) / 2 149 allocation.y = current_y 150 allocation.width = size_request.width 151 allocation.height = size_request.height 152 message_box.size_allocate(allocation) 153 154 # Determine grid coordinates and add to grid 155 grid_width, grid_height = \ 156 self._get_child_grid_size(message_box) 157 x = int(allocation.x / float(_CELL_SIZE)) 158 y = int(allocation.y / float(_CELL_SIZE)) 159 self._grid.add(message_box, grid_width, 160 grid_height, x, y, locked=True) 161 162 current_y += allocation.height 123 163 124 164 def allocate_children(self, allocation, children): 125 165 pass … … class SpreadLayout(ViewLayout): 160 200 def __init__(self): 161 201 ViewLayout.__init__(self) 162 202 163 def remove(self, child):164 if self._grid is None:165 # the Grid is created during allocation time, so it might not166 # exist yet when this method is called, SL #3814167 return168 169 if self._grid.is_in_grid(child):170 self._grid.remove(child)171 172 203 def allocate_children(self, allocation, children): 173 204 for child in children: 174 205 if not self._grid.is_in_grid(child): -
src/jarabe/desktop/favoritesview.py
diff --git a/src/jarabe/desktop/favoritesview.py b/src/jarabe/desktop/favoritesview.py index a9358f6..909a367 100644
a b from gi.repository import GdkPixbuf 29 29 from sugar3.graphics import style 30 30 from sugar3.graphics.icon import Icon 31 31 from sugar3.graphics.icon import CanvasIcon 32 from sugar3.graphics.messagebox import MessageBox 32 33 from sugar3.graphics.palettemenu import PaletteMenuBox 33 34 from sugar3.graphics.palettemenu import PaletteMenuItem 34 35 from sugar3.graphics.palettemenu import PaletteMenuItemSeparator … … _favorites_settings = None 74 75 class FavoritesBox(Gtk.VBox): 75 76 __gtype_name__ = 'SugarFavoritesBox' 76 77 78 __gsignals__ = { 79 'clear-clicked': (GObject.SignalFlags.RUN_FIRST, None, ([])), 80 } 81 77 82 def __init__(self): 78 83 Gtk.VBox.__init__(self) 79 84 … … class FavoritesView(ViewContainer): 192 197 layout = property(None, _set_layout) 193 198 194 199 def do_add(self, child): 195 if child != self._owner_icon and child != self._activity_icon:200 if child not in self._get_fixed_icons(): 196 201 self._children.append(child) 197 202 child.connect('button-press-event', self.__button_press_cb) 198 203 child.connect('button-release-event', self.__button_release_cb) … … class FavoritesView(ViewContainer): 340 345 341 346 def set_filter(self, query): 342 347 query = query.strip() 348 matches = 0 343 349 for icon in self.get_children(): 344 if icon not in [self._owner_icon, self._activity_icon]:350 if icon not in self._get_fixed_icons(): 345 351 activity_name = icon.get_activity_name().decode('utf-8') 346 352 normalized_name = normalize_string(activity_name) 347 353 if normalized_name.find(query) > -1: 348 354 icon.alpha = 1.0 355 matches += 1 349 356 else: 350 357 icon.alpha = 0.33 351 358 359 if not matches: 360 self._add_clear_message() 361 else: 362 self._remove_message() 363 352 364 def __register_activate_cb(self, icon): 353 365 alert = Alert() 354 366 try: … … class FavoritesView(ViewContainer): 377 389 if hasattr(icon, 'set_resume_mode'): 378 390 icon.set_resume_mode(self._resume_mode) 379 391 392 def _add_clear_message(self): 393 self._message_box = MessageBox(_('No matching activities')) 394 self.add(self._message_box) 395 self._message_box.show() 396 397 clear_button = Gtk.Button(label=_('Clear search')) 398 clear_button.connect('clicked', self.__clear_button_clicked_cb) 399 clear_button.props.image = Icon(icon_name='dialog-cancel', 400 icon_size=Gtk.IconSize.BUTTON) 401 self._message_box.add_button(clear_button) 402 clear_button.show() 403 404 self._relocate_fixed_icons() 405 406 def __clear_button_clicked_cb(self, button): 407 self._box.emit('clear-clicked') 408 380 409 381 410 class ActivityIcon(CanvasIcon): 382 411 __gtype_name__ = 'SugarFavoriteActivityIcon' -
src/jarabe/desktop/groupbox.py
diff --git a/src/jarabe/desktop/groupbox.py b/src/jarabe/desktop/groupbox.py index 91c9cb5..37873ff 100644
a b 15 15 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 16 16 17 17 import logging 18 from gettext import gettext as _ 19 20 from gi.repository import Gtk 21 from gi.repository import GObject 18 22 19 23 from sugar3.graphics import style 24 from sugar3.graphics.icon import Icon 25 from sugar3.graphics.messagebox import MessageBox 20 26 21 27 from jarabe.view.buddyicon import BuddyIcon 22 28 from jarabe.model.buddy import get_owner_instance … … from jarabe.util.normalize import normalize_string 30 36 class GroupBox(ViewContainer): 31 37 __gtype_name__ = 'SugarGroupBox' 32 38 39 __gsignals__ = { 40 'clear-clicked': (GObject.SignalFlags.RUN_FIRST, None, ([])), 41 } 42 33 43 def __init__(self, toolbar): 34 44 logging.debug('STARTUP: Loading the group view') 35 45 … … class GroupBox(ViewContainer): 44 54 toolbar.connect('query-changed', self._toolbar_query_changed_cb) 45 55 toolbar.search_entry.connect('icon-press', 46 56 self.__clear_icon_pressed_cb) 57 self.connect('clear-clicked', 58 self.__clear_clicked_cb, toolbar) 59 47 60 self._friends = {} 48 61 49 62 friends_model = friends.get_model() … … class GroupBox(ViewContainer): 51 64 for friend in friends_model: 52 65 self.add_friend(friend) 53 66 67 if not self._friends: 68 self._add_no_friends_message() 69 54 70 friends_model.connect('friend-added', self._friend_added_cb) 55 71 friends_model.connect('friend-removed', self._friend_removed_cb) 56 72 … … class GroupBox(ViewContainer): 63 79 def _friend_added_cb(self, data_model, buddy_info): 64 80 self.add_friend(buddy_info) 65 81 82 if len(self._friends) == 1: 83 self._remove_message() 84 66 85 def _friend_removed_cb(self, data_model, key): 67 86 icon = self._friends[key] 68 87 self.remove(icon) 69 88 del self._friends[key] 70 89 icon.destroy() 71 90 91 if not self._friends: 92 self._add_no_friends_message() 93 72 94 def _toolbar_query_changed_cb(self, toolbar, query): 73 95 self._query = normalize_string(query.decode('utf-8')) 74 for icon in self.get_children(): 96 97 # There are no friends. 98 if not self._friends: 99 return 100 101 children = [child for child in self.get_children() 102 if child not in self._get_fixed_icons()] 103 104 matches = 0 105 for icon in children: 75 106 if hasattr(icon, 'set_filter'): 76 icon.set_filter(self._query) 107 filtered = icon.set_filter(self._query) 108 if not filtered: 109 matches += 1 110 111 # There are friends, but no one matches the search. 112 if not matches: 113 self._add_clear_message() 114 return 115 116 # There are friends and they match the search. 117 self._remove_message() 77 118 78 119 def __clear_icon_pressed_cb(self, entry, icon_pos, event): 79 120 self.grab_focus() 121 122 def _add_no_friends_message(self): 123 self._remove_message() 124 125 self._message_box = MessageBox(_('There are no friends')) 126 self.add(self._message_box) 127 self._message_box.show() 128 129 self._relocate_fixed_icons() 130 131 def _add_clear_message(self): 132 self._remove_message() 133 134 self._message_box = MessageBox(_('No matching friends')) 135 self.add(self._message_box) 136 self._message_box.show() 137 138 clear_button = Gtk.Button(label=_('Clear search')) 139 clear_button.connect('clicked', self.__clear_button_clicked_cb) 140 clear_button.props.image = Icon(icon_name='dialog-cancel', 141 icon_size=Gtk.IconSize.BUTTON) 142 self._message_box.add_button(clear_button) 143 clear_button.show() 144 145 self._relocate_fixed_icons() 146 147 def __clear_button_clicked_cb(self, button): 148 self.emit('clear-clicked') 149 150 def __clear_clicked_cb(self, widget, toolbar): 151 toolbar.clear_query() -
src/jarabe/desktop/homebox.py
diff --git a/src/jarabe/desktop/homebox.py b/src/jarabe/desktop/homebox.py index b87c345..99d0dcb 100644
a b class HomeBox(Gtk.VBox): 48 48 toolbar.connect('view-changed', self.__toolbar_view_changed_cb) 49 49 toolbar.search_entry.connect('icon-press', 50 50 self.__clear_icon_pressed_cb) 51 self._favorites_box.connect('clear-clicked', 52 self.__clear_clicked_cb, toolbar) 51 53 self._list_view.connect('clear-clicked', 52 self.__ activitylist_clear_clicked_cb, toolbar)54 self.__clear_clicked_cb, toolbar) 53 55 54 56 self._set_view(_FAVORITES_VIEW) 55 57 self._query = '' … … class HomeBox(Gtk.VBox): 108 110 def __toolbar_view_changed_cb(self, toolbar, view): 109 111 self._set_view(view) 110 112 111 def __ activitylist_clear_clicked_cb(self, widget, toolbar):113 def __clear_clicked_cb(self, widget, toolbar): 112 114 toolbar.clear_query() 113 115 114 116 def __clear_icon_pressed_cb(self, entry, icon_pos, event): -
src/jarabe/desktop/meshbox.py
diff --git a/src/jarabe/desktop/meshbox.py b/src/jarabe/desktop/meshbox.py index bc5dbde..baab5d2 100644
a b from gi.repository import Gtk 27 27 from gi.repository import GConf 28 28 29 29 from sugar3.graphics.icon import Icon 30 from sugar3.graphics.messagebox import MessageBox 30 31 from sugar3.graphics.icon import CanvasIcon 31 32 from sugar3.graphics import style 32 33 from sugar3.graphics.palette import Palette … … class NetworkManagerObserver(object): 347 348 class MeshBox(ViewContainer): 348 349 __gtype_name__ = 'SugarMeshBox' 349 350 351 __gsignals__ = { 352 'clear-clicked': (GObject.SignalFlags.RUN_FIRST, None, ([])), 353 } 354 350 355 def __init__(self, toolbar): 351 356 logging.debug('STARTUP: Loading the mesh view') 352 357 … … class MeshBox(ViewContainer): 373 378 toolbar.search_entry.connect('icon-press', 374 379 self.__clear_icon_pressed_cb) 375 380 381 self.connect('clear-clicked', 382 self.__clear_clicked_cb, toolbar) 383 376 384 for buddy_model in self._model.get_buddies(): 377 385 self._add_buddy(buddy_model) 378 386 … … class MeshBox(ViewContainer): 597 605 598 606 def _toolbar_query_changed_cb(self, toolbar, query): 599 607 self._query = normalize_string(query.decode('utf-8')) 600 for icon in self.get_children(): 608 609 children = [child for child in self.get_children() 610 if child not in self._get_fixed_icons()] 611 612 # There are no icons. 613 if not children: 614 return 615 616 matches = 0 617 for icon in children: 601 618 if hasattr(icon, 'set_filter'): 602 icon.set_filter(self._query) 619 filtered = icon.set_filter(self._query) 620 if not filtered: 621 matches += 1 622 623 # There are icons, but no one matches the search. 624 if not matches: 625 self._add_clear_message() 626 return 627 628 # There are icons and they match the search. 629 self._remove_message() 603 630 604 631 def __clear_icon_pressed_cb(self, entry, icon_pos, event): 605 632 self.grab_focus() 633 634 def _add_clear_message(self): 635 self._remove_message() 636 637 self._message_box = MessageBox(_('No matching networks or buddies')) 638 self.add(self._message_box) 639 self._message_box.show() 640 641 clear_button = Gtk.Button(label=_('Clear search')) 642 clear_button.connect('clicked', self.__clear_button_clicked_cb) 643 clear_button.props.image = Icon(icon_name='dialog-cancel', 644 icon_size=Gtk.IconSize.BUTTON) 645 self._message_box.add_button(clear_button) 646 clear_button.show() 647 648 self._relocate_fixed_icons() 649 650 def __clear_button_clicked_cb(self, button): 651 self.emit('clear-clicked') 652 653 def __clear_clicked_cb(self, widget, toolbar): 654 toolbar.clear_query() -
src/jarabe/desktop/networkviews.py
diff --git a/src/jarabe/desktop/networkviews.py b/src/jarabe/desktop/networkviews.py index 63e860d..5f91e7e 100644
a b class WirelessNetworkView(EventPulsingIcon): 383 383 self._filtered = normalized_name.find(query) == -1 384 384 self._update_icon() 385 385 self._update_color() 386 return self._filtered 386 387 387 388 def create_keydialog(self, response): 388 389 keydialog.create(self._ssid, self._flags, self._wpa_flags, … … class SugarAdhocView(EventPulsingIcon): 591 592 name = self._NAME + str(self._channel) 592 593 self._filtered = name.lower().find(query) == -1 593 594 self._update_color() 595 return self._filtered 594 596 595 597 596 598 class OlpcMeshView(EventPulsingIcon): … … class OlpcMeshView(EventPulsingIcon): 719 721 def set_filter(self, query): 720 722 self._filtered = (query != '') 721 723 self._update_color() 724 return self._filtered 722 725 723 726 def disconnect(self): 724 727 device_object_path = self._mesh_mgr.mesh_device.object_path -
src/jarabe/desktop/viewcontainer.py
diff --git a/src/jarabe/desktop/viewcontainer.py b/src/jarabe/desktop/viewcontainer.py index 4ff690d..e95f464 100644
a b class ViewContainer(Gtk.Container): 32 32 33 33 self._activity_icon = None 34 34 self._owner_icon = None 35 self._message_box = None 36 35 37 self._layout = None 36 38 37 39 self._children = [] … … class ViewContainer(Gtk.Container): 47 49 self.add(self._activity_icon) 48 50 self._activity_icon.show() 49 51 52 def _get_fixed_icons(self): 53 return [self._owner_icon, self._activity_icon, self._message_box] 54 50 55 def do_add(self, child): 51 if child != self._owner_icon and child != self._activity_icon:56 if child not in self._get_fixed_icons(): 52 57 self._children.append(child) 53 58 if child.get_realized(): 54 59 child.set_parent_window(self.get_parent_window()) … … class ViewContainer(Gtk.Container): 58 63 was_visible = child.get_visible() 59 64 if child in self._children: 60 65 self._children.remove(child) 61 62 63 64 66 child.unparent() 67 self._layout.remove(child) 68 if was_visible and self.get_visible(): 69 self.queue_resize() 65 70 66 71 def do_size_allocate(self, allocation): 67 72 self.set_allocation(allocation) 68 73 if self._owner_icon: 69 74 self._layout.setup(allocation, self._owner_icon, 70 self._activity_icon)75 self._activity_icon, self._message_box) 71 76 72 77 self._layout.allocate_children(allocation, self._children) 73 78 … … class ViewContainer(Gtk.Container): 78 83 callback(self._owner_icon) 79 84 if self._activity_icon: 80 85 callback(self._activity_icon) 86 if self._message_box: 87 callback(self._message_box) 88 89 def _remove_message(self): 90 if self._message_box: 91 self.remove(self._message_box) 92 self._message_box = None 81 93 82 94 def set_layout(self, layout): 83 95 for child in self.get_children(): 84 96 self.remove(child) 85 97 self._layout = layout 98 99 def _relocate_fixed_icons(self): 100 # The fixed icons are allocated when this container does 101 # size_allocate. So we skip if this container wasn't 102 # allocated yet, that is when allocation size = (1, 1) 103 allocation = self.get_allocation() 104 if allocation.width == 1 and allocation.height == 1: 105 return 106 107 self._layout.allocate_fixed_icons(allocation, self._owner_icon, 108 self._activity_icon, 109 self._message_box) -
src/jarabe/view/buddyicon.py
diff --git a/src/jarabe/view/buddyicon.py b/src/jarabe/view/buddyicon.py index 6320113..47ce1f6 100644
a b class BuddyIcon(CanvasIcon): 72 72 self._filtered = (normalized_name.find(query) == -1) \ 73 73 and not self._buddy.is_owner() 74 74 self._update_color() 75 return self._filtered