Merge lp:~roadmr/checkbox/621880 into lp:checkbox

Proposed by Daniel Manrique
Status: Merged
Merged at revision: 922
Proposed branch: lp:~roadmr/checkbox/621880
Merge into: lp:checkbox
Diff against target: 162 lines (+60/-8)
4 files modified
checkbox_gtk/gtk_interface.py (+41/-3)
debian/changelog (+7/-0)
gtk/checkbox-gtk.ui (+2/-1)
po/checkbox.pot (+10/-4)
To merge this branch: bzr merge lp:~roadmr/checkbox/621880
Reviewer Review Type Date Requested Status
Marc Tardif (community) Approve
Review via email: mp+64204@code.launchpad.net

Description of the change

I removed the static "hardware database" string from the header graphic and it's now rendered from within the gtk+ code for the interface. Other than internationalization of the string, this could enable us to do interesting things with the header and the text it contains, might be useful in order to more easily customize an updated header, and/or in preparation for Ubuntu Friendly where checkbox's visual presentation might change.

All this was done using Cairo and Pango, gi.repository and the new "draw" signal to be as GTK3-compliant as possible.

Tested to run under both Natty and Oneiric.

To post a comment you must log in.
Revision history for this message
Marc Tardif (cr3) wrote :

Looks good, I just moved your changelog comment from 0.12.2 to 0.12.1 since the latter hasn't been released in Ubuntu yet. Thanks man!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'checkbox_gtk/gtk_interface.py'
2--- checkbox_gtk/gtk_interface.py 2011-05-17 13:47:10 +0000
3+++ checkbox_gtk/gtk_interface.py 2011-06-10 15:51:29 +0000
4@@ -22,7 +22,8 @@
5 from gettext import gettext as _
6 from string import Template
7
8-from gi.repository import Gtk, Gdk
9+from gi.repository import Gtk, Gdk, Pango, PangoCairo
10+import cairo
11
12 from checkbox.job import UNINITIATED
13 from checkbox.user_interface import (UserInterface,
14@@ -32,7 +33,6 @@
15 # Import to register HyperTextView type with gtk
16 from checkbox_gtk.hyper_text_view import HyperTextView
17
18-
19 ANSWER_TO_BUTTON = {
20 YES_ANSWER: "radio_button_yes",
21 NO_ANSWER: "radio_button_no",
22@@ -85,6 +85,19 @@
23 self._dialog = self._get_widget("dialog_main")
24 self._dialog.set_title(title)
25
26+ #Setup and handler to render pixmap and translatable description text.
27+ self.IMAGE_HEAD_BACKGROUND = posixpath.join(data_path,
28+ "checkbox-gtk-head.png")
29+ self.FONT = "Ubuntu"
30+ self.TEXT =_("hardware database")
31+
32+ image_head=self._get_widget("image_head")
33+ try:
34+ image_head.connect("draw",self.draw_image_head)
35+ except TypeError:
36+ #Looks like GTK+ 2.x
37+ image_head.connect("expose-event",self.draw_image_head)
38+
39 # Set wait transient for dialog
40 self._wait = self._get_widget("window_wait")
41 self._wait.set_transient_for(self._dialog)
42@@ -501,7 +514,7 @@
43 message_dialog.set_title(_("Info"))
44
45 for index, option in enumerate(options):
46- button = getattr(gtk, "STOCK_%s" % option.upper())
47+ button = getattr(Gtk, "STOCK_%s" % option.upper())
48 message_dialog.add_buttons(button, index)
49
50 self._run_dialog(message_dialog)
51@@ -522,3 +535,28 @@
52 message_dialog.add_buttons(Gtk.STOCK_CLOSE, NEXT)
53 self._run_dialog(message_dialog)
54 message_dialog.hide()
55+
56+ def draw_image_head(self, widget, data):
57+ #Render the background we read from an image
58+ background_image = cairo.ImageSurface.create_from_png(
59+ self.IMAGE_HEAD_BACKGROUND)
60+ cairo_drawing_context = Gdk.cairo_create(widget.get_window())
61+ cairo_drawing_context.set_source_surface(background_image,0,0)
62+ cairo_drawing_context.paint()
63+ #Text rendering with Pango is more involved but potentially
64+ #better for l10n and i18n purposes
65+ font_description = Pango.FontDescription()
66+ font_description.set_family(self.FONT)
67+ font_description.set_weight(Pango.Weight.NORMAL)
68+ font_description.set_absolute_size(12 * Pango.SCALE)
69+
70+ pango_drawing_context = widget.get_pango_context()
71+ pango_text_layout = Pango.Layout(context=pango_drawing_context)
72+ pango_text_layout.set_font_description(font_description)
73+ pango_text_layout.set_text(self.TEXT, -1)
74+
75+ #Color to render text
76+ cairo_drawing_context.set_source_rgb(0,0,0)
77+ #Position to render text
78+ cairo_drawing_context.move_to(100,45)
79+ PangoCairo.show_layout(cairo_drawing_context,pango_text_layout)
80
81=== modified file 'debian/changelog'
82--- debian/changelog 2011-06-06 20:38:04 +0000
83+++ debian/changelog 2011-06-10 15:51:29 +0000
84@@ -1,3 +1,10 @@
85+checkbox (0.12.2) oneiric; urgency=low
86+
87+ * Render header text dynamically over the image background, and updated pot
88+ file with the new string. (LP: #621880)
89+
90+ -- Daniel Manrique <daniel.manrique@canonical.com> Thu, 09 Jun 2011 15:57:58 -0400
91+
92 checkbox (0.12.1) oneiric; urgency=low
93
94 [Brendan Donegan]
95
96=== modified file 'gtk/checkbox-gtk-head.png'
97Binary files gtk/checkbox-gtk-head.png 2009-02-09 21:34:00 +0000 and gtk/checkbox-gtk-head.png 2011-06-10 15:51:29 +0000 differ
98=== modified file 'gtk/checkbox-gtk.ui'
99--- gtk/checkbox-gtk.ui 2011-05-20 21:22:31 +0000
100+++ gtk/checkbox-gtk.ui 2011-06-10 15:51:29 +0000
101@@ -23,7 +23,8 @@
102 <object class="GtkImage" id="image_head">
103 <property name="visible">True</property>
104 <property name="yalign">0</property>
105- <property name="pixbuf">checkbox-gtk-head.png</property>
106+ <property name="width_request">-1</property>
107+ <property name="height_request">69</property>
108 </object>
109 </child>
110 </object>
111
112=== modified file 'po/checkbox.pot'
113--- po/checkbox.pot 2011-04-05 16:11:50 +0000
114+++ po/checkbox.pot 2011-06-10 15:51:29 +0000
115@@ -8,10 +8,11 @@
116 msgstr ""
117 "Project-Id-Version: PACKAGE VERSION\n"
118 "Report-Msgid-Bugs-To: \n"
119-"POT-Creation-Date: 2011-04-05 12:01-0400\n"
120+"POT-Creation-Date: 2011-06-09 16:18-0400\n"
121 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
122 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
123 "Language-Team: LANGUAGE <LL@li.org>\n"
124+"Language: \n"
125 "MIME-Version: 1.0\n"
126 "Content-Type: text/plain; charset=CHARSET\n"
127 "Content-Transfer-Encoding: 8bit\n"
128@@ -52,6 +53,7 @@
129 msgstr ""
130
131 #: ../gtk/checkbox-gtk.ui.h:9 ../checkbox_gtk/gtk_interface.py:488
132+#: checkbox_gtk/gtk_interface.py:503
133 msgid "_Test"
134 msgstr ""
135
136@@ -1278,15 +1280,15 @@
137 msgid "Test Again"
138 msgstr ""
139
140-#: ../checkbox_gtk/gtk_interface.py:457
141+#: ../checkbox_gtk/gtk_interface.py:457 checkbox_gtk/gtk_interface.py:472
142 msgid "_Test Again"
143 msgstr ""
144
145-#: ../checkbox_gtk/gtk_interface.py:499
146+#: ../checkbox_gtk/gtk_interface.py:499 checkbox_gtk/gtk_interface.py:514
147 msgid "Info"
148 msgstr ""
149
150-#: ../checkbox_gtk/gtk_interface.py:518
151+#: ../checkbox_gtk/gtk_interface.py:518 checkbox_gtk/gtk_interface.py:533
152 msgid "Error"
153 msgstr ""
154
155@@ -1433,3 +1435,7 @@
156 #: ../scripts/internet_test:140
157 msgid "Internet connection fully established"
158 msgstr ""
159+
160+#: checkbox_gtk/gtk_interface.py:92
161+msgid "hardware database"
162+msgstr ""

Subscribers

People subscribed via source and target branches