[gnome-clocks] Make the digital clock width relative to the pixbuf



commit 4cb39d43e50cda4be2e7fa6233ae7b166a8bcbff
Author: Paolo Borelli <pborelli gnome org>
Date:   Sun Dec 2 15:07:48 2012 +0100

    Make the digital clock width relative to the pixbuf
    
    We want the clock to be centered on the image, so its width should
    always be smaller than the pixbuf, even when there is a long name which
    makes the cell larger

 gnomeclocks/widgets.py |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/gnomeclocks/widgets.py b/gnomeclocks/widgets.py
index 5033707..20598ac 100644
--- a/gnomeclocks/widgets.py
+++ b/gnomeclocks/widgets.py
@@ -85,9 +85,12 @@ class DigitalClockRenderer(Gtk.CellRendererPixbuf):
         cr.clip()
         cr.translate(cell_area.x, cell_area.y)
 
-        # for now the space around the digital clock is hardcoded,
-        # we need to know the width to create the pango layouts
-        margin = 16
+        # for now the space around the digital clock is hardcoded and
+        # relative to the image width (not the width of the cell which
+        # may be larger in case of long city names).
+        # We need to know the width to create the pango layouts
+        pixbuf_margin = (cell_area.width - self.props.pixbuf.get_width()) // 2
+        margin = 12 + pixbuf_margin
         padding = 12
         w = cell_area.width - 2 * margin
 
@@ -138,7 +141,6 @@ class DigitalClockRenderer(Gtk.CellRendererPixbuf):
 
             xpad, ypad = self.get_padding()
             direction = widget.get_direction()
-
             if direction == Gtk.TextDirection.RTL:
                 x_offset = xpad
             else:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]