Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@tomeuvizoso.net>2007-07-01 10:55:10 (GMT)
committer Tomeu Vizoso <tomeu@tomeuvizoso.net>2007-07-01 10:55:10 (GMT)
commit4aee850af7b3de3dab24aa6cf72a855162e4fddd (patch)
tree8363ae249a4ddebe8d1ddd3e0362d496705139db
parentaa5d6af260ce93495fd7bb9d19a094106c331e98 (diff)
Replace Menu for Palette.
-rw-r--r--shell/view/Shell.py5
-rw-r--r--shell/view/clipboardicon.py124
-rw-r--r--shell/view/clipboardmenu.py239
-rw-r--r--shell/view/frame/ActivitiesBox.py15
-rw-r--r--shell/view/frame/FriendsBox.py13
-rw-r--r--shell/view/frame/clipboardbox.py5
-rw-r--r--shell/view/frame/clipboardpanelwindow.py2
-rw-r--r--shell/view/frame/frame.py41
-rw-r--r--shell/view/home/FriendView.py4
-rw-r--r--shell/view/home/FriendsBox.py5
-rw-r--r--shell/view/home/HomeBox.py7
-rw-r--r--shell/view/home/HomeWindow.py5
-rw-r--r--shell/view/home/MeshBox.py11
13 files changed, 183 insertions, 293 deletions
diff --git a/shell/view/Shell.py b/shell/view/Shell.py
index 6b9c352..b4e2fea 100644
--- a/shell/view/Shell.py
+++ b/shell/view/Shell.py
@@ -26,7 +26,6 @@ import gtk
import wnck
from sugar.activity.activityhandle import ActivityHandle
-from sugar.graphics.popupcontext import PopupContext
from sugar.activity import activityfactory
from sugar.datastore import datastore
from sugar import profile
@@ -52,7 +51,6 @@ class Shell(gobject.GObject):
self._screen_rotation = 0
self._key_handler = KeyHandler(self)
- self._popup_context = PopupContext()
self._frame = Frame(self)
self._frame.show()
@@ -114,9 +112,6 @@ class Shell(gobject.GObject):
def get_frame(self):
return self._frame
- def get_popup_context(self):
- return self._popup_context
-
def join_activity(self, bundle_id, activity_id):
activity = self.get_activity(activity_id)
if activity:
diff --git a/shell/view/clipboardicon.py b/shell/view/clipboardicon.py
index 0483248..8269bb1 100644
--- a/shell/view/clipboardicon.py
+++ b/shell/view/clipboardicon.py
@@ -16,9 +16,6 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import logging
-import os
-import urlparse
-import tempfile
from gettext import gettext as _
import gobject
@@ -28,12 +25,8 @@ from view.clipboardmenu import ClipboardMenu
from sugar.graphics.xocolor import XoColor
from sugar.graphics import units
from sugar.graphics import color
-from sugar.activity import activityfactory
-from sugar.activity.bundle import Bundle
from sugar.clipboard import clipboardservice
from sugar import util
-from sugar.datastore import datastore
-from sugar.objects import mime
from sugar import profile
class ClipboardIcon(CanvasIcon):
@@ -44,9 +37,8 @@ class ClipboardIcon(CanvasIcon):
gobject.PARAM_READWRITE)
}
- def __init__(self, popup_context, object_id, name):
+ def __init__(self, object_id, name):
CanvasIcon.__init__(self)
- self._popup_context = popup_context
self._object_id = object_id
self._name = name
self._percent = 0
@@ -58,7 +50,14 @@ class ClipboardIcon(CanvasIcon):
self.props.box_height = units.grid_to_pixels(1)
self.props.scale = units.STANDARD_ICON_SCALE
self.props.xo_color = XoColor(profile.get_color().to_string())
- self._menu = None
+
+ cb_service = clipboardservice.get_instance()
+ obj = cb_service.get_object(self._object_id)
+ formats = obj['FORMATS']
+
+ self.palette = ClipboardMenu(self._object_id, self._name, self._percent,
+ self._preview, self._activity,
+ formats and formats[0] == 'application/vnd.olpc-x-sugar')
def do_set_property(self, pspec, value):
if pspec.name == 'selected':
@@ -81,20 +80,6 @@ class ClipboardIcon(CanvasIcon):
else:
self.props.background_color = color.TOOLBAR_BACKGROUND.get_int()
- def get_popup(self):
- cb_service = clipboardservice.get_instance()
- obj = cb_service.get_object(self._object_id)
- formats = obj['FORMATS']
-
- self._menu = ClipboardMenu(self._name, self._percent, self._preview,
- self._activity,
- formats[0] == 'application/vnd.olpc-x-sugar')
- self._menu.connect('action', self._popup_action_cb)
- return self._menu
-
- def get_popup_context(self):
- return self._popup_context
-
def set_state(self, name, percent, icon_name, preview, activity):
cb_service = clipboardservice.get_instance()
obj = cb_service.get_object(self._object_id)
@@ -108,62 +93,13 @@ class ClipboardIcon(CanvasIcon):
self._preview = preview
self._activity = activity
self.set_property("icon_name", icon_name)
- if self._menu:
- self._menu.set_state(name, percent, preview, activity, installable)
+ self.palette.set_state(name, percent, preview, activity, installable)
if (activity or installable) and percent < 100:
self.props.xo_color = XoColor("#000000,#424242")
else:
self.props.xo_color = XoColor(profile.get_color().to_string())
- def _open_file(self):
- if self._percent < 100:
- return
-
- # Get the file path
- cb_service = clipboardservice.get_instance()
- obj = cb_service.get_object(self._object_id)
- formats = obj['FORMATS']
- if len(formats) == 0:
- return
-
- if not self._activity and \
- not formats[0] == 'application/vnd.olpc-x-sugar':
- return
-
- uri = cb_service.get_object_data(self._object_id, formats[0])['DATA']
- if not uri.startswith('file://'):
- return
-
- (scheme, netloc, path, params, query, fragment) = urlparse.urlparse(uri)
-
- # FIXME: would be better to check for format.onDisk
- try:
- path_exists = os.path.exists(path)
- except TypeError:
- path_exists = False
-
- if path_exists:
- if self._activity:
- activityfactory.create_with_uri(self._activity, uri)
- else:
- self._install_xo(path)
- else:
- logging.debug("Clipboard item file path %s didn't exist" % path)
-
- def _popup_action_cb(self, popup, menu_item):
- action = menu_item.props.action_id
-
- if action == ClipboardMenu.ACTION_STOP_DOWNLOAD:
- raise "Stopping downloads still not implemented."
- elif action == ClipboardMenu.ACTION_DELETE:
- cb_service = clipboardservice.get_instance()
- cb_service.delete_object(self._object_id)
- elif action == ClipboardMenu.ACTION_OPEN:
- self._open_file()
- elif action == ClipboardMenu.ACTION_SAVE_TO_JOURNAL:
- self._save_to_journal()
-
def get_object_id(self):
return self._object_id
@@ -178,43 +114,3 @@ class ClipboardIcon(CanvasIcon):
else:
self.props.background_color = color.TOOLBAR_BACKGROUND.get_int()
- def _install_xo(self, path):
- bundle = Bundle(path)
- if not bundle.is_installed():
- bundle.install()
-
- def _save_to_journal(self):
- cb_service = clipboardservice.get_instance()
- obj = cb_service.get_object(self._object_id)
-
- if len(obj['FORMATS']) == 0:
- return
-
- if 'text/uri-list' in obj['FORMATS']:
- data = cb_service.get_object_data(self._object_id, 'text/uri-list')
- file_path = urlparse.urlparse(data['DATA']).path
- mime_type = mime.get_for_file(file_path)
- else:
- # TODO: Find a way to choose the best mime-type from all the available.
- mime_type = obj['FORMATS'][0]
-
- data = cb_service.get_object_data(self._object_id, mime_type)
- if data['ON_DISK']:
- file_path = urlparse.urlparse(data['DATA']).path
- else:
- f, file_path = tempfile.mkstemp()
- try:
- os.write(f, data['data'])
- finally:
- os.close(f)
-
- jobject = datastore.create()
- jobject.metadata['title'] = _('Clipboard object: %s.') % obj['NAME']
- jobject.metadata['keep'] = '0'
- jobject.metadata['buddies'] = ''
- jobject.metadata['preview'] = ''
- jobject.metadata['icon-color'] = profile.get_color().to_string()
- jobject.metadata['mime_type'] = mime_type
- jobject.file_path = file_path
- datastore.write(jobject)
-
diff --git a/shell/view/clipboardmenu.py b/shell/view/clipboardmenu.py
index e5e9bc8..4be17bf 100644
--- a/shell/view/clipboardmenu.py
+++ b/shell/view/clipboardmenu.py
@@ -14,123 +14,176 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
from gettext import gettext as _
+import tempfile
+import urlparse
+import os
import gtk
import hippo
-from sugar.graphics.menu import Menu, MenuItem
+from sugar.graphics.palette import Palette
from sugar.graphics.canvasicon import CanvasIcon
from sugar.graphics import color
from sugar.graphics import font
-
-class ClipboardMenu(Menu):
-
- ACTION_DELETE = 0
- ACTION_OPEN = 1
- ACTION_STOP_DOWNLOAD = 2
- ACTION_SAVE_TO_JOURNAL = 3
+from sugar.activity import activityfactory
+from sugar.activity.bundle import Bundle
+from sugar.clipboard import clipboardservice
+from sugar.datastore import datastore
+from sugar.objects import mime
+from sugar import profile
+
+class ClipboardMenu(Palette):
- def __init__(self, name, percent, preview, activity, installable):
- Menu.__init__(self, name)
- self.props.border = 0
+ def __init__(self, object_id, name, percent, preview, activity, installable):
+ Palette.__init__(self, name)
+
+ self._object_id = object_id
+ self._percent = percent
+ self._activity = activity
if percent < 100:
self._progress_bar = gtk.ProgressBar()
- self._update_progress_bar(percent)
-
- canvas_widget = hippo.CanvasWidget()
- canvas_widget.props.widget = self._progress_bar
- self.append(canvas_widget)
+ self._update_progress_bar()
+
+ self.set_content(self._progress_bar)
+ self._progress_bar.show()
else:
self._progress_bar = None
-
- self._remove_item = None
- self._open_item = None
- self._stop_item = None
- self._journal_item = None
+ """
if preview:
self._preview_text = hippo.CanvasText(text=preview,
size_mode=hippo.CANVAS_SIZE_WRAP_WORD)
self._preview_text.props.color = color.LABEL_TEXT.get_int()
self._preview_text.props.font_desc = font.DEFAULT.get_pango_desc()
self.append(self._preview_text)
-
- self._update_icons(percent, activity, installable)
-
- def _update_icons(self, percent, activity, installable):
- if percent == 100 and (activity or installable):
- self._add_remove_item()
- self._add_open_item()
- self._remove_stop_item()
- self._add_journal_item()
- elif percent == 100 and (not activity and not installable):
- self._add_remove_item()
- self._remove_open_item()
- self._remove_stop_item()
- self._add_journal_item()
+ """
+
+ self._remove_item = gtk.MenuItem(_('Remove')) #, 'theme:stock-remove')
+ self._remove_item.connect('activate', self._remove_item_activate_cb)
+ self.append_menu_item(self._remove_item)
+
+ self._open_item = gtk.MenuItem(_('Open')) #, 'theme:stock-keep')
+ self._open_item.connect('activate', self._open_item_activate_cb)
+ self.append_menu_item(self._open_item)
+
+ self._stop_item = gtk.MenuItem(_('Stop download')) #, 'theme:stock-close')
+ # TODO: Implement stopping downloads
+ #self._stop_item.connect('activate', self._stop_item_activate_cb)
+ self.append_menu_item(self._stop_item)
+
+ self._journal_item = gtk.MenuItem(_('Add to journal')) #, 'theme:document-save')
+ self._journal_item.connect('activate', self._journal_item_activate_cb)
+ self.append_menu_item(self._journal_item)
+
+ self._update_items_visibility(installable)
+
+ def _update_items_visibility(self, installable):
+ if self._percent == 100 and (self._activity or installable):
+ self._remove_item.show()
+ self._open_item.show()
+ self._stop_item.hide()
+ self._journal_item.show()
+ elif self._percent == 100 and (not self._activity and not installable):
+ self._remove_item.show()
+ self._open_item.hide()
+ self._stop_item.hide()
+ self._journal_item.show()
else:
- self._remove_remove_item()
- self._remove_open_item()
- self._add_stop_item()
- self._remove_journal_item()
+ self._remove_item.hide()
+ self._open_item.hide()
+ self._stop_item.show()
+ self._journal_item.hide()
- def _update_progress_bar(self, percent):
+ def _update_progress_bar(self):
if self._progress_bar:
- self._progress_bar.props.fraction = percent / 100.0
- self._progress_bar.props.text = '%.2f %%' % (percent / 100.0)
+ self._progress_bar.props.fraction = self._percent / 100.0
+ self._progress_bar.props.text = '%.2f %%' % self._percent
def set_state(self, name, percent, preview, activity, installable):
- self.set_title(name)
+ self.set_primary_text(name)
+ self._percent = percent
+ self._activity = activity
if self._progress_bar:
- self._update_progress_bar(percent)
- self._update_icons(percent, activity, installable)
-
- def _add_remove_item(self):
- if not self._remove_item:
- self._remove_item = MenuItem(ClipboardMenu.ACTION_DELETE,
- _('Remove'),
- 'theme:stock-remove')
- self.add_item(self._remove_item)
-
- def _add_open_item(self):
- if not self._open_item:
- self._open_item = MenuItem(ClipboardMenu.ACTION_OPEN,
- _('Open'),
- 'theme:stock-keep')
- self.add_item(self._open_item)
-
- def _add_stop_item(self):
- if not self._stop_item:
- self._stop_item = MenuItem(ClipboardMenu.ACTION_STOP_DOWNLOAD,
- _('Stop download'),
- 'theme:stock-close')
- self.add_item(self._stop_item)
-
- def _add_journal_item(self):
- if not self._journal_item:
- self._journal_item = MenuItem(ClipboardMenu.ACTION_SAVE_TO_JOURNAL,
- _('Add to journal'),
- 'theme:document-save')
- self.add_item(self._journal_item)
-
- def _remove_open_item(self):
- if self._open_item:
- self.remove_item(self._open_item)
- self._open_item = None
-
- def _remove_stop_item(self):
- if self._stop_item:
- self.remove_item(self._stop_item)
- self._stop_item = None
-
- def _remove_remove_item(self):
- if self._remove_item:
- self.remove_item(self._remove_item)
- self._remove_item = None
-
- def _remove_journal_item(self):
- if self._journal_item:
- self.remove_item(self._journal_item)
- self._journal_item = None
+ self._update_progress_bar()
+ self._update_items_visibility(installable)
+
+ def _open_item_activate_cb(self, menu_item):
+ if self._percent < 100:
+ return
+
+ # Get the file path
+ cb_service = clipboardservice.get_instance()
+ obj = cb_service.get_object(self._object_id)
+ formats = obj['FORMATS']
+ if len(formats) == 0:
+ return
+
+ if not self._activity and \
+ not formats[0] == 'application/vnd.olpc-x-sugar':
+ return
+
+ uri = cb_service.get_object_data(self._object_id, formats[0])['DATA']
+ if not uri.startswith('file://'):
+ return
+
+ (scheme, netloc, path, params, query, fragment) = urlparse.urlparse(uri)
+
+ # FIXME: would be better to check for format.onDisk
+ try:
+ path_exists = os.path.exists(path)
+ except TypeError:
+ path_exists = False
+
+ if path_exists:
+ if self._activity:
+ activityfactory.create_with_uri(self._activity, uri)
+ else:
+ self._install_xo(path)
+ else:
+ logging.debug("Clipboard item file path %s didn't exist" % path)
+
+ def _remove_item_activate_cb(self, menu_item):
+ cb_service = clipboardservice.get_instance()
+ cb_service.delete_object(self._object_id)
+
+ def _journal_item_activate_cb(self, menu_item):
+ cb_service = clipboardservice.get_instance()
+ obj = cb_service.get_object(self._object_id)
+
+ if len(obj['FORMATS']) == 0:
+ return
+
+ if 'text/uri-list' in obj['FORMATS']:
+ data = cb_service.get_object_data(self._object_id, 'text/uri-list')
+ file_path = urlparse.urlparse(data['DATA']).path
+ mime_type = mime.get_for_file(file_path)
+ else:
+ # TODO: Find a way to choose the best mime-type from all the available.
+ mime_type = obj['FORMATS'][0]
+
+ data = cb_service.get_object_data(self._object_id, mime_type)
+ if data['ON_DISK']:
+ file_path = urlparse.urlparse(data['DATA']).path
+ else:
+ f, file_path = tempfile.mkstemp()
+ try:
+ os.write(f, data['DATA'])
+ finally:
+ os.close(f)
+
+ jobject = datastore.create()
+ jobject.metadata['title'] = _('Clipboard object: %s.') % obj['NAME']
+ jobject.metadata['keep'] = '0'
+ jobject.metadata['buddies'] = ''
+ jobject.metadata['preview'] = ''
+ jobject.metadata['icon-color'] = profile.get_color().to_string()
+ jobject.metadata['mime_type'] = mime_type
+ jobject.file_path = file_path
+ datastore.write(jobject)
+
+ def _install_xo(self, path):
+ bundle = Bundle(path)
+ if not bundle.is_installed():
+ bundle.install()
diff --git a/shell/view/frame/ActivitiesBox.py b/shell/view/frame/ActivitiesBox.py
index 0e45eac..032a8bb 100644
--- a/shell/view/frame/ActivitiesBox.py
+++ b/shell/view/frame/ActivitiesBox.py
@@ -25,17 +25,13 @@ from sugar import profile
from model import bundleregistry
class ActivityButton(IconButton):
- def __init__(self, activity, popup_context):
- IconButton.__init__(self, icon_name=activity.get_icon(),
- tooltip=activity.get_name())
+ def __init__(self, activity):
+ IconButton.__init__(self, icon_name=activity.get_icon())
+ self.set_tooltip(activity.get_name())
self._activity = activity
- self._popup_context = popup_context
def get_bundle_id(self):
return self._activity.get_service_name()
-
- def get_popup_context(self):
- return self._popup_context
class InviteButton(IconButton):
def __init__(self, activity, invite):
@@ -54,14 +50,13 @@ class InviteButton(IconButton):
return self._invite
class ActivitiesBox(hippo.CanvasBox):
- def __init__(self, shell, popup_context):
+ def __init__(self, shell):
hippo.CanvasBox.__init__(self, orientation=hippo.ORIENTATION_HORIZONTAL)
self._shell = shell
self._shell_model = self._shell.get_model()
self._invite_to_item = {}
self._invites = self._shell_model.get_invites()
- self._popup_context = popup_context
bundle_registry = bundleregistry.get_registry()
for bundle in bundle_registry:
@@ -93,7 +88,7 @@ class ActivitiesBox(hippo.CanvasBox):
self.add_activity(bundle)
def add_activity(self, activity):
- item = ActivityButton(activity, self._popup_context)
+ item = ActivityButton(activity)
item.connect('activated', self._activity_clicked_cb)
self.append(item, 0)
diff --git a/shell/view/frame/FriendsBox.py b/shell/view/frame/FriendsBox.py
index edbd0fc..cde51f5 100644
--- a/shell/view/frame/FriendsBox.py
+++ b/shell/view/frame/FriendsBox.py
@@ -23,12 +23,8 @@ from view.BuddyIcon import BuddyIcon
from model.BuddyModel import BuddyModel
class FriendIcon(BuddyIcon):
- def __init__(self, shell, popup_context, buddy):
- BuddyIcon.__init__(self, shell, popup_context, buddy)
- self._popup_context = popup_context
-
- def get_popup_context(self):
- return self._popup_context
+ def __init__(self, shell, buddy):
+ BuddyIcon.__init__(self, shell, buddy)
def prelight(self, enter):
if enter:
@@ -37,10 +33,9 @@ class FriendIcon(BuddyIcon):
self.props.background_color = color.TOOLBAR_BACKGROUND.get_int()
class FriendsBox(hippo.CanvasBox):
- def __init__(self, shell, popup_context):
+ def __init__(self, shell):
hippo.CanvasBox.__init__(self)
self._shell = shell
- self._popup_context = popup_context
self._activity_ps = None
self._joined_hid = -1
self._left_hid = -1
@@ -63,7 +58,7 @@ class FriendsBox(hippo.CanvasBox):
return
model = BuddyModel(buddy=buddy)
- icon = FriendIcon(self._shell, self._popup_context, model)
+ icon = FriendIcon(self._shell, model)
self.append(icon)
self._buddies[buddy.props.key] = icon
diff --git a/shell/view/frame/clipboardbox.py b/shell/view/frame/clipboardbox.py
index 3bef447..e2d0fdf 100644
--- a/shell/view/frame/clipboardbox.py
+++ b/shell/view/frame/clipboardbox.py
@@ -57,9 +57,8 @@ class _ContextMap:
class ClipboardBox(hippo.CanvasBox):
- def __init__(self, popup_context):
+ def __init__(self):
hippo.CanvasBox.__init__(self)
- self._popup_context = popup_context
self._icons = {}
self._context_map = _ContextMap()
self._selected_icon = None
@@ -125,7 +124,7 @@ class ClipboardBox(hippo.CanvasBox):
on_disk=False)
def _object_added_cb(self, cb_service, object_id, name):
- icon = ClipboardIcon(self._popup_context, object_id, name)
+ icon = ClipboardIcon(object_id, name)
icon.connect('activated', self._icon_activated_cb)
self._set_icon_selected(icon)
diff --git a/shell/view/frame/clipboardpanelwindow.py b/shell/view/frame/clipboardpanelwindow.py
index a7fba17..e708c5e 100644
--- a/shell/view/frame/clipboardpanelwindow.py
+++ b/shell/view/frame/clipboardpanelwindow.py
@@ -36,7 +36,7 @@ class ClipboardPanelWindow(FrameWindow):
root = self.get_root()
- self._clipboard_box = ClipboardBox(frame.get_popup_context())
+ self._clipboard_box = ClipboardBox()
root.append(self._clipboard_box)
# Receiving dnd drops
diff --git a/shell/view/frame/frame.py b/shell/view/frame/frame.py
index e192b04..232f9d4 100644
--- a/shell/view/frame/frame.py
+++ b/shell/view/frame/frame.py
@@ -26,7 +26,6 @@ from view.frame.overlaybox import OverlayBox
from view.frame.FriendsBox import FriendsBox
from view.frame.framewindow import FrameWindow
from view.frame.clipboardpanelwindow import ClipboardPanelWindow
-from view.frame.framepopupcontext import FramePopupContext
from model.ShellModel import ShellModel
from sugar.graphics import animator
from sugar.graphics import units
@@ -140,12 +139,6 @@ class Frame(object):
self._event_area.connect('enter', self._enter_corner_cb)
self._event_area.show()
- self._popup_context = FramePopupContext()
- self._popup_context.connect('activated',
- self._popup_context_activated_cb)
- self._popup_context.connect('deactivated',
- self._popup_context_deactivated_cb)
-
self._top_panel = self._create_top_panel()
self._bottom_panel = self._create_bottom_panel()
self._left_panel = self._create_left_panel()
@@ -195,9 +188,6 @@ class Frame(object):
self.visible = True
- def get_popup_context(self):
- return self._popup_context
-
def get_current_position(self):
return self._current_position
@@ -227,7 +217,7 @@ class Frame(object):
panel = self._create_panel(hippo.ORIENTATION_HORIZONTAL)
root = panel.get_root()
- box = ActivitiesBox(self._shell, self._popup_context)
+ box = ActivitiesBox(self._shell)
root.append(box)
return panel
@@ -236,7 +226,7 @@ class Frame(object):
panel = self._create_panel(hippo.ORIENTATION_VERTICAL)
root = panel.get_root()
- box = FriendsBox(self._shell, self._popup_context)
+ box = FriendsBox(self._shell)
root.append(box)
return panel
@@ -268,7 +258,6 @@ class Frame(object):
def _connect_to_panel(self, panel):
panel.connect('enter-notify-event', self._enter_notify_cb)
- panel.connect('leave-notify-event', self._leave_notify_cb)
def _update_position(self):
screen_h = gtk.gdk.screen_height()
@@ -301,34 +290,8 @@ class Frame(object):
self.show()
gobject.timeout_add(2000, lambda: self.hide())
- def _popup_context_activated_cb(self, popup_context):
- self._mouse_listener.mouse_enter()
-
- def _popup_context_deactivated_cb(self, popup_context):
- if not self._hover:
- self._mouse_listener.mouse_leave()
-
def _enter_notify_cb(self, window, event):
- # FIXME clicks cause leave/notify, ignore
- if event.state == gtk.gdk.BUTTON1_MASK:
- return
- if self._hover:
- return
-
- self._hover = True
self._mouse_listener.mouse_enter()
-
- def _leave_notify_cb(self, window, event):
- # FIXME clicks cause leave/notify, ignore
- if event.state == gtk.gdk.BUTTON1_MASK:
- return
- if not self._hover:
- return
-
- if not self._is_hover():
- self._hover = False
- if not self._popup_context.is_active():
- self._mouse_listener.mouse_leave()
def _drag_motion_cb(self, window, context, x, y, time):
self._mouse_listener.mouse_enter()
diff --git a/shell/view/home/FriendView.py b/shell/view/home/FriendView.py
index 6530957..a899a63 100644
--- a/shell/view/home/FriendView.py
+++ b/shell/view/home/FriendView.py
@@ -25,13 +25,13 @@ from model import bundleregistry
from view.BuddyIcon import BuddyIcon
class FriendView(hippo.CanvasBox):
- def __init__(self, shell, menu_shell, buddy, **kwargs):
+ def __init__(self, shell, buddy, **kwargs):
hippo.CanvasBox.__init__(self, **kwargs)
self._pservice = presenceservice.get_instance()
self._buddy = buddy
- self._buddy_icon = BuddyIcon(shell, menu_shell, buddy)
+ self._buddy_icon = BuddyIcon(shell, buddy)
self._buddy_icon.props.scale = units.LARGE_ICON_SCALE
self.append(self._buddy_icon)
diff --git a/shell/view/home/FriendsBox.py b/shell/view/home/FriendsBox.py
index 80dfd4b..2ce2e3b 100644
--- a/shell/view/home/FriendsBox.py
+++ b/shell/view/home/FriendsBox.py
@@ -26,11 +26,10 @@ from view.home.FriendView import FriendView
class FriendsBox(SpreadBox):
__gtype_name__ = 'SugarFriendsBox'
- def __init__(self, shell, menu_shell):
+ def __init__(self, shell):
SpreadBox.__init__(self, background_color=0xe2e2e2ff)
self._shell = shell
- self._menu_shell = menu_shell
self._friends = {}
self._my_icon = MyIcon(units.LARGE_ICON_SCALE)
@@ -45,7 +44,7 @@ class FriendsBox(SpreadBox):
friends.connect('friend-removed', self._friend_removed_cb)
def add_friend(self, buddy_info):
- icon = FriendView(self._shell, self._menu_shell, buddy_info)
+ icon = FriendView(self._shell, buddy_info)
self.add_item(icon)
self._friends[buddy_info.get_key()] = icon
diff --git a/shell/view/home/HomeBox.py b/shell/view/home/HomeBox.py
index a42ef74..a885445 100644
--- a/shell/view/home/HomeBox.py
+++ b/shell/view/home/HomeBox.py
@@ -124,20 +124,17 @@ class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
def release(self):
pass
-# TODO: Most or all of it should move to CanvasIcon.
class HomeMyIcon(MyIcon):
- _POPUP_PALETTE_DELAY = 100
def __init__(self, shell, scale):
MyIcon.__init__(self, scale)
self._shell = shell
- self._palette = Palette(profile.get_nick_name())
- self._palette.props.invoker = CanvasInvoker(self)
+ self.set_tooltip(profile.get_nick_name())
shutdown_menu_item = gtk.MenuItem(_('Shutdown'))
shutdown_menu_item.connect('activate', self._shutdown_activate_cb)
- self._palette.append_menu_item(shutdown_menu_item)
+ self.get_palette().append_menu_item(shutdown_menu_item)
shutdown_menu_item.show()
def _shutdown_activate_cb(self, menuitem):
diff --git a/shell/view/home/HomeWindow.py b/shell/view/home/HomeWindow.py
index e1c341d..d8322c6 100644
--- a/shell/view/home/HomeWindow.py
+++ b/shell/view/home/HomeWindow.py
@@ -18,7 +18,6 @@ import gtk
import hippo
import cairo
-from sugar.graphics.menushell import MenuShell
from sugar.graphics import units
import sugar
@@ -54,8 +53,8 @@ class HomeWindow(gtk.Window):
self.connect('focus-out-event', self._focus_out_cb)
self._home_box = HomeBox(shell)
- self._friends_box = FriendsBox(shell, MenuShell(self))
- self._mesh_box = MeshBox(shell, MenuShell(self))
+ self._friends_box = FriendsBox(shell)
+ self._mesh_box = MeshBox(shell)
self._transition_box = TransitionBox()
self._canvas.set_root(self._home_box)
diff --git a/shell/view/home/MeshBox.py b/shell/view/home/MeshBox.py
index 0d2b106..46cb024 100644
--- a/shell/view/home/MeshBox.py
+++ b/shell/view/home/MeshBox.py
@@ -163,7 +163,7 @@ class MeshDeviceView(PulsingIcon):
]
class ActivityView(SnowflakeBox):
- def __init__(self, shell, menu_shell, model):
+ def __init__(self, shell, model):
SnowflakeBox.__init__(self)
self._shell = shell
@@ -197,11 +197,10 @@ class ActivityView(SnowflakeBox):
self._shell.join_activity(bundle_id, self._model.get_id())
class MeshBox(SpreadBox):
- def __init__(self, shell, menu_shell):
+ def __init__(self, shell):
SpreadBox.__init__(self, background_color=0xe2e2e2ff)
self._shell = shell
- self._menu_shell = menu_shell
self._model = shell.get_model().get_mesh()
self._buddies = {}
self._activities = {}
@@ -281,7 +280,7 @@ class MeshBox(SpreadBox):
self._mesh = None
def _add_alone_buddy(self, buddy_model):
- icon = BuddyIcon(self._shell, self._menu_shell, buddy_model)
+ icon = BuddyIcon(self._shell, buddy_model)
if buddy_model.is_owner():
self.set_center_item(icon)
else:
@@ -313,11 +312,11 @@ class MeshBox(SpreadBox):
else:
activity = self._activities[activity_model.get_id()]
- icon = BuddyIcon(self._shell, self._menu_shell, buddy_model)
+ icon = BuddyIcon(self._shell, buddy_model)
activity.add_buddy_icon(buddy_model.get_key(), icon)
def _add_activity(self, activity_model):
- icon = ActivityView(self._shell, self._menu_shell, activity_model)
+ icon = ActivityView(self._shell, activity_model)
self.add_item(icon)
self._activities[activity_model.get_id()] = icon