~mjz/awn-extras/to-do-two

« back to all changes in this revision

Viewing changes to applets/maintained/to-do/icon.py

  • Committer: Matt
  • Date: 2010-06-01 02:39:21 UTC
  • Revision ID: sharkbaitbobby@gmail.com-20100601023921-dboizxmmjtcugule
Full read/write, even across multiple applets!
Handle to-do.xml not existing, having errors, etc etc etc.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
    #Get the needed data based on the icon type
51
51
 
52
52
    #progress: border shows progress, number shows percent completed
53
 
    if _list['icon_mode'] in ('1', '2'):
54
 
        if len(_list) == 0:
55
 
            progress = 100
56
 
 
57
 
        else:
58
 
            progress = 0
59
 
            num_unfinished = 0
60
 
            num_items = 0
61
 
 
62
 
            for child in _list:
63
 
                if isinstance(child, backends.Group):
64
 
                    for item in child:
65
 
                        if int(item['progress']) != 100:
66
 
                            num_unfinished += 1
67
 
 
68
 
                        num_items += 1
69
 
                        progress += int(item['progress'])
70
 
 
71
 
                else:
72
 
                    if int(child['progress']) != 100:
 
53
    if len(_list) == 0:
 
54
        progress = 100
 
55
        num_unfinished = 0
 
56
 
 
57
    else:
 
58
        progress = 0
 
59
        num_unfinished = 0
 
60
        num_items = 0
 
61
 
 
62
        for child in _list:
 
63
            if isinstance(child, backends.Group):
 
64
                for item in child:
 
65
                    if int(item['progress']) != 100:
73
66
                        num_unfinished += 1
74
67
 
75
68
                    num_items += 1
76
 
                    progress += int(child['progress'])
77
 
 
78
 
            if num_unfinished == 0:
79
 
                progress = 100
 
69
                    progress += int(item['progress'])
80
70
 
81
71
            else:
82
 
                progress = progress / num_items
 
72
                if int(child['progress']) != 100:
 
73
                    num_unfinished += 1
 
74
 
 
75
                num_items += 1
 
76
                progress += int(child['progress'])
 
77
 
 
78
        if num_unfinished == 0:
 
79
            progress = 100
 
80
 
 
81
        else:
 
82
            progress = progress / num_items
83
83
 
84
84
    #Outer circle
85
85
    cr.set_source_rgba(*colors[0].get_cairo_color())
118
118
 
119
119
    #Draw the inside circle and fill it
120
120
    cr.set_source_rgba(*colors[1].get_cairo_color())
121
 
    cr.arc(size / 2.0, size / 2.0, size / 2.0 - 3, 0, 2 * pi)
 
121
    cr.arc(size / 2.0, size / 2.0, size / 2.0 - 2.5, 0, 2 * pi)
122
122
    cr.clip()
123
123
    cr.paint()
124
124
 
138
138
 
139
139
    #1-digit number
140
140
    if len(text) == 1:
141
 
        cr.move_to(*scale(size, 13, 38))
 
141
        cr.move_to(*scale(size, 13, 36))
142
142
        cr.set_font_size(*scale(size, 38))
143
143
        cr.show_text(text)
144
144
 
145
145
    #2-digit number
146
146
    elif len(text) == 2:
147
 
        cr.move_to(*scale(size, 8, 33))
 
147
        cr.move_to(*scale(size, 8, 31))
148
148
        cr.set_font_size(*scale(size, 26))
149
149
        cr.show_text(text)
150
150
 
151
151
    #3+-digit number
152
152
    elif len(text) == 3:
153
 
        cr.move_to(*scale(size, 7, 30))
 
153
        cr.move_to(*scale(size, 7, 28))
154
154
        cr.set_font_size(*scale(size, 19))
155
155
        cr.show_text(text)
156
156
 
157
157
    #100% or the user is crazy (>= 1000 items)
158
158
    else:
159
 
        cr.move_to(*scale(size, 6, 29))
 
159
        cr.move_to(*scale(size, 6, 27))
160
160
        cr.set_font_size(*scale(size, 15))
161
161
        cr.show_text(text)
162
162