[Sugar-devel] [PATCH v3 sugar] Disable Start menu item for entries that can't be opened(Bug#328)

Aleksey Lim alsroot at member.fsf.org
Sat Oct 16 08:51:30 EDT 2010


On Sat, Oct 16, 2010 at 05:16:31PM +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'
> ---
>  src/jarabe/journal/palettes.py |   42 +++++++++++++++++++++++----------------
>  1 files changed, 25 insertions(+), 17 deletions(-)
> 
> v1->v2: Patch remade as per pep8 standards
> v2->v3: Revised English wording and optimised behaviour for bundles
> 
> diff --git a/src/jarabe/journal/palettes.py b/src/jarabe/journal/palettes.py
> index 7c3e5ff..aa09cf0 100644
> --- a/src/jarabe/journal/palettes.py
> +++ b/src/jarabe/journal/palettes.py
> @@ -62,22 +62,30 @@ 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()
> +        if misc.get_activities(metadata) or misc.is_bundle(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()
> -        start_with_menu = StartWithMenu(self._metadata)
> -        menu_item.set_submenu(start_with_menu)
> +            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)
> +
> +        else:
> +            resume_label = _('No activity is available 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'))
> @@ -204,9 +212,9 @@ class StartWithMenu(gtk.Menu):
>  
>          if not self.get_children():
>              if metadata.get('activity_id', ''):

+1 for the rest but not sure about this one:
> -                resume_label = _('No activity to resume entry')
> +                resume_label = _('No activity is available to resume entry')
>              else:
> -                resume_label = _('No activity to start entry')
> +                resume_label = _('No activity is available to start entry')
we will break translators work w/o the reason (new wording leaves meaning
the same), afaik it is not common practice, better will be changing en
translation via translate.sl.o rather than in code.

>              menu_item = MenuItem(resume_label)
>              menu_item.set_sensitive(False)
>              self.append(menu_item)
> -- 
> 1.7.0.4
> 

-- 
Aleksey


More information about the Sugar-devel mailing list