summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Seguin <guillaume@segu.in>2007-11-14 01:44:40 +0100
committerGuillaume Seguin <guillaume@segu.in>2007-11-14 01:44:40 +0100
commitbd5ef2ff4607da7ea8d1b90524a5413729407d94 (patch)
tree8fb19343cc77fddd865c8bbdcead9f13919de8ab
parent95cc99a024a141df73388d03fccae1edfdf0c683 (diff)
downloadgnome-about-bd5ef2ff4607da7ea8d1b90524a5413729407d94.tar.gz
gnome-about-bd5ef2ff4607da7ea8d1b90524a5413729407d94.tar.bz2
* Correctly handle font size changes for header links
-rwxr-xr-xgnome-about.py75
1 files changed, 64 insertions, 11 deletions
diff --git a/gnome-about.py b/gnome-about.py
index a6ce5f3..8d79fe6 100755
--- a/gnome-about.py
+++ b/gnome-about.py
@@ -36,7 +36,7 @@ import gtk
import gnome
import cairo
-from math import pi
+from math import pi, ceil
import os, sys, random, time, gettext
@@ -742,6 +742,8 @@ class GnomeAboutHeader (gtk.Layout):
width = 0
height = 0
+ widgets = None
+
def __init__ (self, program, links):
'''Initialize object, plug map signal'''
super (GnomeAboutHeader, self).__init__ ()
@@ -760,7 +762,6 @@ class GnomeAboutHeader (gtk.Layout):
if header:
self.put (header, 0, 0)
current_y = header.get_pixbuf ().get_height ()
- base_y = current_y + 4
line = self.create_line ()
image = gtk.Image ()
image.set_from_pixmap (line, None)
@@ -769,9 +770,6 @@ class GnomeAboutHeader (gtk.Layout):
logo = self.load_logo ()
if logo:
self.put (logo, 0, 0)
- logo_size = logo.get_size_request ()
- current_x += logo_size[0] + 25
- current_y = logo_size[1] + 20
dot = self.create_dot ()
@@ -786,18 +784,66 @@ class GnomeAboutHeader (gtk.Layout):
for widget in widgets:
if put_widgets > 0:
if dot:
- image = gtk.Image ()
- image.set_from_pixmap (dot, None)
- self.put (image, current_x + 5, base_y + 6)
+ widget.dot = gtk.Image ()
+ widget.dot.set_from_pixmap (dot, None)
+ self.put (widget.dot, 0, 0)
+ else:
+ widget.dot = -1
+ else:
+ widget.dot = None
+ self.put (widget, 0, 0)
+ put_widgets += 1
+
+ if len (widgets):
+ '''Minor workaround : we connect the last created widget
+style-set signal (and not the container's one) to make sure that all
+children styles have been updated (otherwise the container is updated
+first)'''
+ widgets[-1].connect ("style-set", self.on_style_set)
+
+ self.widgets = {
+ "header" : header,
+ "logo" : logo,
+ "links" : widgets
+ }
+
+ self.place_widgets ()
+ self.show_all ()
+
+ def place_widgets (self):
+ '''Place widgets at the right place in the header'''
+ current_x = 0
+ current_y = 0
+ base_y = 0
+
+ header = self.widgets["header"]
+ if header:
+ self.move (header, 0, 0)
+ current_y = header.get_pixbuf ().get_height ()
+ base_y = current_y + 4
+
+ logo = self.widgets["logo"]
+ if logo:
+ self.move (logo, 0, 0)
+ logo_size = logo.get_size_request ()
+ current_x += logo_size[0] + 25
+ current_y = logo_size[1] + 20
+
+ links = self.widgets["links"]
+ for widget in links:
+ if widget.dot:
+ if widget.dot != -1:
+ height = widget.get_layout ().get_pixel_size ()[1]
+ dot_height = widget.dot.get_pixmap ()[0].get_size ()[1]
+ y = int (ceil (float (height) / 2)) - dot_height / 2
+ self.move (widget.dot, current_x + 5, base_y + y)
current_x += 16
- self.put (widget, current_x, base_y)
+ self.move (widget, current_x, base_y)
current_x += widget.size_request ()[0]
- put_widgets += 1
self.width = current_x + 10
self.height = current_y
self.set_size_request (self.width, self.height)
- self.show_all ()
def load_header (self):
'''Load a random header image as a gtk.Image'''
@@ -866,6 +912,13 @@ class GnomeAboutHeader (gtk.Layout):
context.paint ()
return pixmap
+ def on_style_set (self, label, old_style):
+ '''Style changed, let's replace widgets'''
+ gtk.Widget.do_style_set (label, old_style)
+ if not self.widgets:
+ return
+ self.place_widgets ()
+
gobject.type_register (GnomeAboutHeader)
class GnomeAbout (gtk.Dialog):