[Sugar-devel] [PATCH] Disable Start menu item for entries that can't be opened(Bug#328)
Aleksey Lim
alsroot at member.fsf.org
Thu Oct 14 17:35:40 EDT 2010
On Thu, Oct 14, 2010 at 11:32:34PM +0530, Mukul Gupta wrote:
> The patch disables the Start and Start With menu items for files
> which can't be opened by any installed activity and instead
> replace it with a hover dropdown with a menu item 'No activity
> installed to start entry'
You need to pass your code through pylint and pep8 (the rest of sugar
code might not confirm pylint/pep8 but you need to leave it as is,
it will be fixed by separate patch later).
> ---
> src/jarabe/journal/palettes.py | 99 +++++++++++++++++++++------------------
> 1 files changed, 53 insertions(+), 46 deletions(-)
>
> diff --git a/src/jarabe/journal/palettes.py b/src/jarabe/journal/palettes.py
> index 7c3e5ff..56df595 100644
> --- a/src/jarabe/journal/palettes.py
> +++ b/src/jarabe/journal/palettes.py
> @@ -62,51 +62,59 @@ class ObjectPalette(Palette):
> Palette.__init__(self, primary_text=title,
> icon=activity_icon)
>
> - if metadata.get('activity_id', ''):
> - resume_label = _('Resume')
> - resume_with_label = _('Resume with')
> - else:
> - resume_label = _('Start')
> - resume_with_label = _('Start with')
> - menu_item = MenuItem(resume_label, 'activity-start')
> - menu_item.connect('activate', self.__start_activate_cb)
> - self.menu.append(menu_item)
> - menu_item.show()
> -
> - menu_item = MenuItem(resume_with_label, 'activity-start')
> - self.menu.append(menu_item)
> - menu_item.show()
> - start_with_menu = StartWithMenu(self._metadata)
> - menu_item.set_submenu(start_with_menu)
> -
> - client = gconf.client_get_default()
> - color = XoColor(client.get_string('/desktop/sugar/user/color'))
> - menu_item = MenuItem(_('Copy'))
> - icon = Icon(icon_name='edit-copy', xo_color=color,
> - icon_size=gtk.ICON_SIZE_MENU)
> - menu_item.set_image(icon)
> - menu_item.connect('activate', self.__copy_activate_cb)
> - self.menu.append(menu_item)
> - menu_item.show()
> -
> - menu_item = MenuItem(_('Send to'), 'document-send')
> - self.menu.append(menu_item)
> - menu_item.show()
> -
> - friends_menu = FriendsMenu()
> - friends_menu.connect('friend-selected', self.__friend_selected_cb)
> - menu_item.set_submenu(friends_menu)
> -
> - if detail == True:
> - menu_item = MenuItem(_('View Details'), 'go-right')
> - menu_item.connect('activate', self.__detail_activate_cb)
> - self.menu.append(menu_item)
> - menu_item.show()
> -
> - menu_item = MenuItem(_('Erase'), 'list-remove')
> - menu_item.connect('activate', self.__erase_activate_cb)
> - self.menu.append(menu_item)
> - menu_item.show()
> + if misc.get_activities(metadata):
> + if metadata.get('activity_id', ''):
> + resume_label = _('Resume')
> + resume_with_label = _('Resume with')
> + else:
> + resume_label = _('Start')
> + resume_with_label = _('Start with')
> + menu_item = MenuItem(resume_label, 'activity-start')
> + menu_item.connect('activate', self.__start_activate_cb)
> + self.menu.append(menu_item)
> + menu_item.show()
> +
> + menu_item = MenuItem(resume_with_label, 'activity-start')
> + self.menu.append(menu_item)
> + menu_item.show()
it seems redundant
> + start_with_menu = StartWithMenu(self._metadata)
> + menu_item.set_submenu(start_with_menu)
> +
> + else:
> + resume_label = _('No activity installed to start entry')
> + menu_item = MenuItem(resume_label)
> + menu_item.set_sensitive(False)
> + self.menu.append(menu_item)
> + menu_item.show()
> +
> + client = gconf.client_get_default()
> + color = XoColor(client.get_string('/desktop/sugar/user/color'))
> + menu_item = MenuItem(_('Copy'))
> + icon = Icon(icon_name='edit-copy', xo_color=color,
> + icon_size=gtk.ICON_SIZE_MENU)
> + menu_item.set_image(icon)
> + menu_item.connect('activate', self.__copy_activate_cb)
> + self.menu.append(menu_item)
> + menu_item.show()
> +
> + menu_item = MenuItem(_('Send to'), 'document-send')
> + self.menu.append(menu_item)
> + menu_item.show()
> +
> + friends_menu = FriendsMenu()
> + friends_menu.connect('friend-selected', self.__friend_selected_cb)
> + menu_item.set_submenu(friends_menu)
> +
> + if detail == True:
> + menu_item = MenuItem(_('View Details'), 'go-right')
> + menu_item.connect('activate', self.__detail_activate_cb)
> + self.menu.append(menu_item)
> + menu_item.show()
> +
> + menu_item = MenuItem(_('Erase'), 'list-remove')
> + menu_item.connect('activate', self.__erase_activate_cb)
> + self.menu.append(menu_item)
> + menu_item.show()
>
> def __start_activate_cb(self, menu_item):
> misc.resume(self._metadata)
> @@ -219,7 +227,6 @@ class StartWithMenu(gtk.Menu):
> mime_registry.set_default_activity(mime_type, service_name)
> misc.resume(self._metadata, service_name)
>
> -
> class BuddyPalette(Palette):
> def __init__(self, buddy):
> self._buddy = buddy
> --
> 1.7.0.4
>
--
Aleksey
More information about the Sugar-devel
mailing list