[Sugar-devel] [PATCH Finance] expenses with no category specified are displayed as "Unknown" fix to SL#3097

Gonzalo Odiard gonzalo at laptop.org
Sat Mar 17 15:36:13 EDT 2012


Thanks Kalpa,
What do you think about replacing:

-            catbox = gtk.Label(c)
+            # If there is no category, display as Unknown
+            if c is '':
+                catbox = gtk.Label(_('Unknown'))
+            else:
+                catbox = gtk.Label(c)

by:

+            # If there is no category, display as Unknown
+            description = c
+            if c is '':
+                description = _('Unknown')
             catbox = gtk.Label(description)

Looks simpler, right?

Gonzalo

On Sat, Mar 17, 2012 at 4:21 PM, <callkalpa at gmail.com> wrote:

> From: Kalpa Pathum Welivitigoda <callkalpa at gmail.com>
>
> ---
>  budgetscreen.py |    6 +++++-
>  chartscreen.py  |    7 +++++--
>  2 files changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/budgetscreen.py b/budgetscreen.py
> index 0e2cd98..bcbceb5 100644
> --- a/budgetscreen.py
> +++ b/budgetscreen.py
> @@ -96,7 +96,11 @@ class BudgetScreen(gtk.VBox):
>
>         # Build categories.
>         for c in self.sorted_categories:
> -            catbox = gtk.Label(c)
> +            # If there is no category, display as Unknown
> +            if c is '':
> +                catbox = gtk.Label(_('Unknown'))
> +            else:
> +                catbox = gtk.Label(c)
>             catbox.set_padding(10, 0)
>
>             color = finance.get_category_color_str(c)
> diff --git a/chartscreen.py b/chartscreen.py
> index 129be9b..b6d1977 100644
> --- a/chartscreen.py
> +++ b/chartscreen.py
> @@ -89,8 +89,11 @@ class ChartScreen(gtk.HBox):
>         for c in self.sorted_categories:
>             hbox = gtk.HBox()
>
> -            catlabel = gtk.Label()
> -            catlabel.set_markup(c)
> +            # If there is no category, display as Unknown
> +            if c is '':
> +                catlabel = gtk.Label(_('Unknown'))
> +            else:
> +                catlabel = gtk.Label(c)
>             catgroup.add_widget(catlabel)
>
>             color = finance.get_category_color_str(c)
> --
> 1.7.7.6
>
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20120317/111cc137/attachment.html>


More information about the Sugar-devel mailing list