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

Bug#696699: cdebconf-gtk-udeb: Improper display of “info” messages



Source: cdebconf-gtk-udeb
Version: 0.180
Severity: important
Tags: d-i patch

Hi,

the display of “info” messages is currently broken. For reference, those
are set through db_info, by a handful of packages (excluding false
positives in busybox and cdebconf):
| ~/debian-installer/packages$ grep db_info -r|egrep -v '^(busybox|cdebconf)/'
| babelbox/preseed_early:db_info babelbox/info || true
| lowmem/lowmem_debconf:db_info lowmem/info
| lowmem/main-menu.d/5lowmem:	db_info lowmem/info
| rescue/main-menu.d/10rescue:	db_info rescue/info

An example of broken banner is attached (rescue mode with French
selected). It had been on my radar for a while but I hadn't time to work
on it until now.

I'm suggesting that we move the info message to the left, and that we
center it vertically. I'm attaching a patch that implements that as well
as screenshots with a fixed banner with two different languages.

One should note that the 'Sans 12' font is currently hardcoded, we
should probably look into making gtk-set-font help us pick the right
font and the right size. If that seems to be a good idea, I'll probably
suggest that in another bug report; something to fix during the jessie
release cycle, I'd say.

Comments?

Mraw,
KiBi.

Attachment: broken-banner.png
Description: PNG image

>From 08fea0fa9f5579bac20b8342994374d955fd381a Mon Sep 17 00:00:00 2001
From: Cyril Brulebois <kibi@debian.org>
Date: Wed, 26 Dec 2012 00:24:14 +0100
Subject: [PATCH] =?UTF-8?q?Fix=20the=20display=20of=20info=20messages=20(e.g?=
 =?UTF-8?q?.=20=E2=80=9CRescue=20mode=E2=80=9D).?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Do that by aligning them on the left (rather than on the right, on top
of either the “debian” or the Debian swirl), also centering them
vertically, getting rid of magic numbers in the process.
---
 debian/changelog              |    9 +++++++++
 src/modules/frontend/gtk/ui.c |   22 ++++++++++++++++------
 2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index eebc79d..a508216 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+cdebconf (0.181) UNRELEASED; urgency=low
+
+  * Fix the display of info messages (e.g. “Rescue mode”) by aligning them
+    on the left (rather than on the right, on top of either the “debian”
+    or the Debian swirl), also centering them vertically, getting rid of
+    magic numbers in the process.
+
+ -- Cyril Brulebois <kibi@debian.org>  Tue, 25 Dec 2012 23:59:38 +0100
+
 cdebconf (0.180) unstable; urgency=low
 
   [ Updated translations ]
diff --git a/src/modules/frontend/gtk/ui.c b/src/modules/frontend/gtk/ui.c
index 86272a0..b8eefad 100644
--- a/src/modules/frontend/gtk/ui.c
+++ b/src/modules/frontend/gtk/ui.c
@@ -50,6 +50,13 @@
 # include "di.h"
 #endif
 
+/* XXX: This is a bit nasty, but g_signal_connect_after() can only
+ * pass a single data pointer, so let's remember the logo height when
+ * it gets added, so that handle_exposed_banner can vertically align
+ * the info text (e.g. “Rescue mode”).
+ */
+static int logo_height;
+
 /* documented in cdebconf_gtk.h */
 void cdebconf_gtk_add_common_layout(struct frontend * fe,
                                     struct question * question,
@@ -92,8 +99,6 @@ static gboolean handle_exposed_banner(GtkWidget * widget,
                                       GdkEventExpose * event,
                                       struct frontend * fe)
 {
-    struct frontend_data * fe_data = fe->data;
-    GdkScreen * screen;
     GdkWindow * window;
     PangoFontDescription * font;
     PangoLayout * layout;
@@ -112,12 +117,12 @@ static gboolean handle_exposed_banner(GtkWidget * widget,
         font = pango_font_description_from_string("Sans 12");
         pango_layout_set_font_description(layout, font);
         pango_layout_get_pixel_size(layout, &text_width, &text_height);
-        screen = gtk_window_get_screen(GTK_WINDOW(fe_data->window));
         window = gtk_widget_get_window(widget);
-        /* XXX: damn magic numbers */
+        /* Left-align, vertically-center */
         gdk_draw_layout(window, gdk_gc_new(window),
-            gdk_screen_get_width(screen) - text_width - 4
-            - DEFAULT_PADDING * 2, 4, layout);
+                        DEFAULT_PADDING * 2,
+                        (logo_height - text_height) / 2,
+                        layout);
         g_object_unref(layout);
         pango_font_description_free(font);
         g_free(message);
@@ -138,6 +143,7 @@ static void create_banner(struct frontend * fe, GtkWidget * container)
 {
     GtkWidget * banner;
     GtkWidget * logo;
+    GdkPixbuf * pixbuf;
 
     /* XXX: check NULL! */
     banner = gtk_event_box_new();
@@ -146,6 +152,10 @@ static void create_banner(struct frontend * fe, GtkWidget * container)
     gtk_misc_set_padding(GTK_MISC(logo), 0, 0);
     gtk_container_add(GTK_CONTAINER(banner), logo);
 
+    /* Remember the logo height: */
+    pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(logo));
+    logo_height = gdk_pixbuf_get_height(pixbuf);
+
     g_signal_connect_after(G_OBJECT(banner), "expose_event",
                            G_CALLBACK(handle_exposed_banner), fe);
 
-- 
1.7.10.4

Attachment: fixed-banner-1.png
Description: PNG image

Attachment: fixed-banner-2.png
Description: PNG image


Reply to: