~bertrand-rousseau/gtg/new-task-list-layout

« back to all changes in this revision

Viewing changes to GTG/gtk/browser/CellRendererTask.py

  • Committer: Bertrand Rousseau
  • Date: 2012-07-28 22:51:30 UTC
  • Revision ID: bertrand.rousseau@gmail.com-20120728225130-qybuodlnv1pua7v8
Push some pixels

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
class TagRenderer:
45
45
 
46
46
    XPAD = 4
47
 
    YPAD = 1
 
47
    YPAD = 2
48
48
 
49
49
    def __init__(self, gc, cr, pc):
50
50
        self.gc = gc
72
72
        self.__update_tag_area()
73
73
 
74
74
    def __update_pango_layout(self):
75
 
        font_desc = pango.FontDescription()
76
75
        attr = pango.AttrList()
77
 
        scale = pango.AttrScale(pango.SCALE_SMALL, 0, -1)
78
 
        attr.insert(scale)
 
76
        size = pango.AttrSize(8 * pango.SCALE, 0, -1)
 
77
        attr.insert(size)
79
78
        self.layout.set_attributes(attr)
80
79
 
81
80
    def __update_txt_area(self):
168
167
            "Task", "The cell task", gobject.PARAM_READWRITE),
169
168
    }
170
169
 
171
 
    DFT_HEIGHT      = 38
 
170
    DFT_HEIGHT      = 42
172
171
    DFT_DATE_OFFSET = 120
173
172
    ICON_SIZE       = 16
174
173
 
280
279
        pixbuf = gtk.icon_theme_get_default().load_icon( \
281
280
            "gtg-task-start-date", self.ICON_SIZE, 0)
282
281
        icon_x = orig_x + self.get_property("xpad") + rr_width - self.DFT_DATE_OFFSET + 5
283
 
        icon_y = orig_y + self.get_property("ypad") + int((rr_height/2-1-self.ICON_SIZE))
 
282
        icon_y = orig_y + self.get_property("ypad") + 2 + int((rr_height/2-3-self.ICON_SIZE))
284
283
        gdkcontext.set_source_pixbuf(pixbuf, icon_x, icon_y)
285
284
        gdkcontext.paint()
286
285
        # text
290
289
            text = "-"
291
290
        layout.set_text(text)
292
291
        txt_x = icon_x + 16 + 8
293
 
        txt_y = orig_y + self.get_property("ypad") + int((rr_height/2-1-txt_height)/2)
 
292
        txt_y = orig_y + self.get_property("ypad") + 2 + int((rr_height/2-3-txt_height)/2)
294
293
        attr = pango.AttrList()
295
294
        if Date.today() > sdate:
296
295
            pa_fgcolor = pango.AttrForeground(61440, 20480, 20480, 0, -1)
306
305
        pixbuf = gtk.icon_theme_get_default().load_icon( \
307
306
            "gtg-task-due-date", self.ICON_SIZE, 0)
308
307
        icon_x = orig_x + self.get_property("xpad") + rr_width - self.DFT_DATE_OFFSET + 5
309
 
        icon_y = orig_y + self.get_property("ypad") + rr_height/2 + 1 + int((rr_height/2-1-self.ICON_SIZE))
 
308
        icon_y = orig_y + self.get_property("ypad") + rr_height/2 + 1 + int((rr_height/2-3-self.ICON_SIZE))
310
309
        gdkcontext.set_source_pixbuf(pixbuf, icon_x, icon_y)
311
310
        gdkcontext.paint()
312
311
        # text
316
315
            text = "-"
317
316
        layout.set_text(text)
318
317
        txt_x = icon_x + 16 + 8
319
 
        txt_y = orig_y + self.get_property("ypad") + rr_height/2 + 1 + int((rr_height/2-1-txt_height)/2)
 
318
        txt_y = orig_y + self.get_property("ypad") + rr_height/2 + 1 + int((rr_height/2-3-txt_height)/2)
320
319
        attr = pango.AttrList()
321
320
        if Date.today() > ddate:
322
321
            pa_fgcolor = pango.AttrForeground(61440, 20480, 20480, 0, -1)
328
327
 
329
328
        # Task title
330
329
        txt_x = orig_x + self.get_property("xpad") + 5
331
 
        txt_y = orig_y + self.get_property("ypad") + 1
 
330
        txt_y = orig_y + self.get_property("ypad") + 4
332
331
        my_color = gtk.gdk.color_parse("#000000")
333
332
        gdkcontext.set_source_color(my_color)
334
333
        layout = pango.Layout(pc)
336
335
        layout.set_ellipsize(pango.ELLIPSIZE_END)
337
336
        font_desc = pango.FontDescription()
338
337
        font_desc.set_weight("bold")
 
338
        font_desc.set_size(10 * pango.SCALE)
339
339
        layout.set_font_description(font_desc)
340
340
        layout.set_text(self.task.get_title())
341
341
        window.draw_layout(gc, txt_x, txt_y, layout, None, None)
346
346
        # Tag label
347
347
        tag_lst = self.task.get_tags()
348
348
        tag_x = orig_x + self.get_property("xpad") + rr_width - self.DFT_DATE_OFFSET - tag_w - 10
349
 
        tag_y = orig_y + self.get_property("ypad") + 3
 
349
        tag_y = orig_y + self.get_property("ypad") + 4
350
350
        for i in xrange(len(tag_lst)):
351
351
            tag = tag_lst[i]
352
352
            if tag.get_attribute("color") is not None or \
360
360
 
361
361
        # Task excerpt
362
362
        txt_x = orig_x + self.get_property("xpad") + 5
363
 
        txt_y = orig_y + self.get_property("ypad") + rr_height/2 + 1 + int((rr_height/2-1-txt_height)/2)
 
363
        txt_y = orig_y + self.get_property("ypad") + 4 + title_height + 5 + int((rr_height - 4 - title_height - 5 - txt_height)/2)
364
364
        layout = pango.Layout(pc)
365
 
        font_desc = pango.FontDescription()
366
 
        font_desc.set_size(9 * pango.SCALE )
367
 
        layout.set_font_description(font_desc)
368
365
        layout.set_width( (rr_width - self.DFT_DATE_OFFSET - 10 - 10) * pango.SCALE)
369
366
        layout.set_ellipsize(pango.ELLIPSIZE_END)
370
367
        attr = pango.AttrList()
371
368
        pa_fgcolor = pango.AttrForeground(34815, 33790, 34047, 0, -1)
372
369
        attr.insert(pa_fgcolor)
 
370
        size = pango.AttrSize(8 * pango.SCALE, 0, -1)
 
371
        attr.insert(size)
373
372
        layout.set_attributes(attr)
374
373
        text = self.task.get_excerpt(strip_tags=True, strip_subtasks=True)
375
374
        layout.set_text(text.replace('\n', ' '))