Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS2
-rw-r--r--lib/sugar/graphics/Makefile.am1
-rw-r--r--shell/view/BuddyIcon.py20
-rw-r--r--shell/view/home/FriendsBox.py2
-rw-r--r--shell/view/home/Makefile.am1
-rw-r--r--shell/view/home/MeshBox.py123
-rw-r--r--shell/view/home/spreadlayout.py (renamed from lib/sugar/graphics/spreadlayout.py)13
-rw-r--r--shell/view/home/transitionbox.py2
8 files changed, 143 insertions, 21 deletions
diff --git a/NEWS b/NEWS
index 28a71b2..16ecf8b 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,5 @@
+* #3119: Implement some basic search capabilities in the mesh view. (tomeu)
+
Snapshot d456f6c633
* New experimental screenshot code. (marco)
diff --git a/lib/sugar/graphics/Makefile.am b/lib/sugar/graphics/Makefile.am
index df2f472..0a3a846 100644
--- a/lib/sugar/graphics/Makefile.am
+++ b/lib/sugar/graphics/Makefile.am
@@ -15,7 +15,6 @@ sugar_PYTHON = \
palettegroup.py \
panel.py \
roundbox.py \
- spreadlayout.py \
style.py \
toggletoolbutton.py \
toolbox.py \
diff --git a/shell/view/BuddyIcon.py b/shell/view/BuddyIcon.py
index 95365aa..a56a1c5 100644
--- a/shell/view/BuddyIcon.py
+++ b/shell/view/BuddyIcon.py
@@ -22,9 +22,9 @@ from view.BuddyMenu import BuddyMenu
class BuddyIcon(CanvasIcon):
def __init__(self, shell, buddy, size=style.STANDARD_ICON_SIZE):
- CanvasIcon.__init__(self, icon_name='computer-xo',
- xo_color=buddy.get_color(), size=size)
+ CanvasIcon.__init__(self, icon_name='computer-xo', size=size)
+ self._greyed_out = False
self._shell = shell
self._buddy = buddy
self._buddy.connect('appeared', self._buddy_presence_change_cb)
@@ -34,7 +34,21 @@ class BuddyIcon(CanvasIcon):
palette = BuddyMenu(shell, buddy)
self.set_palette(palette)
+ self._update_color()
+
def _buddy_presence_change_cb(self, buddy, color=None):
# Update the icon's color when the buddy comes and goes
- self.props.xo_color = buddy.get_color()
+ self._update_color()
+
+ def _update_color(self):
+ if self._greyed_out:
+ self.props.stroke_color = style.COLOR_INACTIVE_STROKE.get_svg()
+ self.props.fill_color = style.COLOR_INACTIVE_FILL.get_svg()
+ else:
+ self.props.xo_color = self._buddy.get_color()
+
+ def set_filter(self, query):
+ self._greyed_out = (self._buddy.get_nick().lower().find(query) == -1) \
+ and not self._buddy.is_owner()
+ self._update_color()
diff --git a/shell/view/home/FriendsBox.py b/shell/view/home/FriendsBox.py
index 9a9ca9b..e9efc57 100644
--- a/shell/view/home/FriendsBox.py
+++ b/shell/view/home/FriendsBox.py
@@ -20,12 +20,12 @@ import hippo
import gobject
from sugar import profile
-from sugar.graphics.spreadlayout import SpreadLayout
from sugar.graphics import style
from sugar.graphics.icon import CanvasIcon
from sugar.graphics.palette import Palette
from view.home.FriendView import FriendView
+from view.home.spreadlayout import SpreadLayout
class FriendsBox(hippo.CanvasBox):
__gtype_name__ = 'SugarFriendsBox'
diff --git a/shell/view/home/Makefile.am b/shell/view/home/Makefile.am
index 9beb651..6916806 100644
--- a/shell/view/home/Makefile.am
+++ b/shell/view/home/Makefile.am
@@ -10,4 +10,5 @@ sugar_PYTHON = \
MyIcon.py \
proc_smaps.py \
snowflakelayout.py \
+ spreadlayout.py \
transitionbox.py
diff --git a/shell/view/home/MeshBox.py b/shell/view/home/MeshBox.py
index 86daac5..c579435 100644
--- a/shell/view/home/MeshBox.py
+++ b/shell/view/home/MeshBox.py
@@ -15,19 +15,19 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import random
+from gettext import gettext as _
+import logging
import hippo
import gobject
import gtk
-from gettext import gettext as _
-from sugar.graphics.spreadlayout import SpreadLayout
from sugar.graphics.icon import CanvasIcon
from sugar.graphics import style
-from sugar.graphics import xocolor
from sugar.graphics.icon import get_icon_state
from sugar.graphics import style
from sugar.graphics import palette
+from sugar.graphics import iconentry
from sugar import profile
from model import accesspointmodel
@@ -38,6 +38,7 @@ from hardware import nmclient
from view.BuddyIcon import BuddyIcon
from view.pulsingicon import PulsingIcon
from view.home.snowflakelayout import SnowflakeLayout
+from view.home.spreadlayout import SpreadLayout
from hardware.nmclient import NM_802_11_CAP_PROTO_WEP, NM_802_11_CAP_PROTO_WPA, NM_802_11_CAP_PROTO_WPA2
@@ -50,6 +51,7 @@ class AccessPointView(PulsingIcon):
self._model = model
self._meshdev = mesh_device
self._disconnect_item = None
+ self._greyed_out = False
self.connect('activated', self._activate_cb)
@@ -146,11 +148,21 @@ class AccessPointView(PulsingIcon):
if self._disconnect_item:
self._disconnect_item.hide()
self.props.pulse_time = 0.0
- self.props.colors = [
- [ style.Color(self._device_stroke).get_svg(),
- style.Color(self._device_fill).get_svg() ]
- ]
+ if self._greyed_out:
+ self.props.colors = [
+ [ style.COLOR_INACTIVE_STROKE.get_svg(),
+ style.COLOR_INACTIVE_FILL.get_svg() ]
+ ]
+ else:
+ self.props.colors = [
+ [ style.Color(self._device_stroke).get_svg(),
+ style.Color(self._device_fill).get_svg() ]
+ ]
+
+ def set_filter(self, query):
+ self._greyed_out = self._model.props.name.lower().find(query) == -1
+ self._update_state()
_MESH_ICON_NAME = 'network-mesh'
@@ -277,9 +289,81 @@ class ActivityView(hippo.CanvasBox):
bundle_id = self._model.get_bundle_id()
self._shell.join_activity(bundle_id, self._model.get_id())
+ def set_filter(self, query):
+ if self._model.activity.props.name.lower().find(query) == -1:
+ self._icon.xo_color = [style.COLOR_INACTIVE_STROKE.get_svg(),
+ style.COLOR_INACTIVE_FILL.get_svg()]
+ else:
+ self._icon.xo_color = self._model.get_color()
+
+_AUTOSEARCH_TIMEOUT = 1000
+
+class MeshToolbar(gtk.Toolbar):
+ __gtype_name__ = 'MeshToolbar'
+
+ __gsignals__ = {
+ 'query-changed': (gobject.SIGNAL_RUN_FIRST,
+ gobject.TYPE_NONE,
+ ([str]))
+ }
+
+ def __init__(self):
+ gtk.Toolbar.__init__(self)
+
+ self._query = None
+ self._autosearch_timer = None
+
+ self._add_separator()
+
+ tool_item = gtk.ToolItem()
+ tool_item.set_expand(True)
+ self.insert(tool_item, -1)
+ tool_item.show()
+
+ self._search_entry = iconentry.IconEntry()
+ self._search_entry.set_icon_from_name(iconentry.ICON_ENTRY_PRIMARY, 'system-search')
+ self._search_entry.add_clear_button()
+ self._search_entry.connect('activate', self._entry_activated_cb)
+ self._search_entry.connect('changed', self._entry_changed_cb)
+ tool_item.add(self._search_entry)
+ self._search_entry.show()
+
+ self._add_separator()
+
+ def _add_separator(self):
+ separator = gtk.SeparatorToolItem()
+ separator.set_size_request(style.GRID_CELL_SIZE, style.GRID_CELL_SIZE)
+ separator.props.draw = False
+ self.insert(separator, -1)
+ separator.show()
+
+ def _entry_activated_cb(self, entry):
+ if self._autosearch_timer:
+ gobject.source_remove(self._autosearch_timer)
+ new_query = entry.props.text
+ if self._query != new_query:
+ self._query = new_query
+ self.emit('query-changed', self._query)
+
+ def _entry_changed_cb(self, entry):
+ if not entry.props.text:
+ entry.activate()
+ return
+
+ if self._autosearch_timer:
+ gobject.source_remove(self._autosearch_timer)
+ self._autosearch_timer = gobject.timeout_add(_AUTOSEARCH_TIMEOUT,
+ self._autosearch_timer_cb)
+
+ def _autosearch_timer_cb(self):
+ logging.debug('_autosearch_timer_cb')
+ self._autosearch_timer = None
+ self._search_entry.activate()
+ return False
+
class MeshBox(hippo.CanvasBox):
def __init__(self, shell):
- hippo.CanvasBox.__init__(self, background_color=0xe2e2e2ff)
+ hippo.CanvasBox.__init__(self)
self._shell = shell
self._model = shell.get_model().get_mesh()
@@ -289,9 +373,18 @@ class MeshBox(hippo.CanvasBox):
self._mesh = {}
self._buddy_to_activity = {}
self._suspended = True
+ self._query = ''
- self._layout = SpreadLayout()
- self.set_layout(self._layout)
+ self._toolbar = MeshToolbar()
+ self._toolbar.connect('query-changed', self._toolbar_query_changed_cb)
+ self.append(hippo.CanvasWidget(widget=self._toolbar))
+
+ self._layout_box = hippo.CanvasBox(background_color=0xe2e2e2ff)
+ self.append(self._layout_box, hippo.PACK_EXPAND)
+
+ center_vertical_offset = - style.GRID_CELL_SIZE
+ self._layout = SpreadLayout(center_vertical_offset)
+ self._layout_box.set_layout(self._layout)
for buddy_model in self._model.get_buddies():
self._add_alone_buddy(buddy_model)
@@ -377,6 +470,9 @@ class MeshBox(hippo.CanvasBox):
else:
self._layout.add(icon)
+ if hasattr(icon, 'set_filter'):
+ icon.set_filter(self._query)
+
self._buddies[buddy_model.get_key()] = icon
def _remove_alone_buddy(self, buddy_model):
@@ -441,3 +537,10 @@ class MeshBox(hippo.CanvasBox):
self._suspended = False
for ap in self._access_points.values():
ap.props.paused = False
+
+ def _toolbar_query_changed_cb(self, toolbar, query):
+ self._query = query.lower()
+ for icon in self._layout_box.get_children():
+ if hasattr(icon, 'set_filter'):
+ icon.set_filter(self._query)
+
diff --git a/lib/sugar/graphics/spreadlayout.py b/shell/view/home/spreadlayout.py
index 7bd1ff1..d7eae7d 100644
--- a/lib/sugar/graphics/spreadlayout.py
+++ b/shell/view/home/spreadlayout.py
@@ -167,11 +167,13 @@ class _Grid(gobject.GObject):
self._array[col + row * self.width] = value
-class SpreadLayout(gobject.GObject,hippo.CanvasLayout):
+class SpreadLayout(gobject.GObject, hippo.CanvasLayout):
__gtype_name__ = 'SugarSpreadLayout'
- def __init__(self):
+ def __init__(self, center_vertical_offset=0):
gobject.GObject.__init__(self)
+ self._center_vertical_offset = center_vertical_offset
+
min_width, width = self.do_get_width_request()
min_height, height = self.do_get_height_request(width)
@@ -225,9 +227,10 @@ class SpreadLayout(gobject.GObject,hippo.CanvasLayout):
else:
min_w, child_width = child.get_width_request()
min_h, child_height = child.get_height_request(child_width)
- child.allocate(x + (width - child_width) / 2,
- y + (height - child_height) / 2,
- child_width, child_height, origin_changed)
+ child_x = x + (width - child_width) / 2
+ child_y = y + (height - child_height + self._center_vertical_offset) / 2
+ child.allocate(child_x, child_y, child_width, child_height,
+ origin_changed)
def _get_child_grid_size(self, child):
min_width, width = child.get_width_request()
diff --git a/shell/view/home/transitionbox.py b/shell/view/home/transitionbox.py
index 421bf9e..f1ba4fb 100644
--- a/shell/view/home/transitionbox.py
+++ b/shell/view/home/transitionbox.py
@@ -19,9 +19,9 @@ import gobject
from sugar.graphics import style
from sugar.graphics import animator
-from sugar.graphics.spreadlayout import SpreadLayout
from view.home.MyIcon import MyIcon
+from view.home.spreadlayout import SpreadLayout
class _Animation(animator.Animation):
def __init__(self, icon, start_size, end_size):