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

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



Control: tag -1 pending

Cyril Brulebois <kibi@debian.org> (26/12/2012):
> 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.

(I meant to say: RTL does work fine.)

> 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?

Samuel seems to like the idea, and pointed out that frontend_data is
our friend to hold frontend-specific data (I initially only looked
into the frontend struct, which wouldn't be the proper way to do
that).

I've added an extra patch to my local branch and verified it was still
working fine; will push to master/upload in a few minutes.

Combined diff against current master attached.

Mraw,
KiBi.
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/fe_data.h b/src/modules/frontend/gtk/fe_data.h
index 701577e..7ea5ad3 100644
--- a/src/modules/frontend/gtk/fe_data.h
+++ b/src/modules/frontend/gtk/fe_data.h
@@ -59,6 +59,14 @@ struct frontend_data
      */
     GtkWidget * title;
 
+    /** Logo size, used to display info messages.
+     *
+     * @see create_banner()
+     * @see handle_exposed_banner()
+     */
+    int logo_width;
+    int logo_height;
+
     /** Internal data of the handler of progress commands.
      *
      * @see progress.c
diff --git a/src/modules/frontend/gtk/ui.c b/src/modules/frontend/gtk/ui.c
index 86272a0..6d94d6b 100644
--- a/src/modules/frontend/gtk/ui.c
+++ b/src/modules/frontend/gtk/ui.c
@@ -93,7 +93,6 @@ static gboolean handle_exposed_banner(GtkWidget * widget,
                                       struct frontend * fe)
 {
     struct frontend_data * fe_data = fe->data;
-    GdkScreen * screen;
     GdkWindow * window;
     PangoFontDescription * font;
     PangoLayout * layout;
@@ -112,12 +111,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,
+                        (fe_data->logo_height - text_height) / 2,
+                        layout);
         g_object_unref(layout);
         pango_font_description_free(font);
         g_free(message);
@@ -136,8 +135,10 @@ static gboolean handle_exposed_banner(GtkWidget * widget,
  */
 static void create_banner(struct frontend * fe, GtkWidget * container)
 {
+    struct frontend_data * fe_data = fe->data;
     GtkWidget * banner;
     GtkWidget * logo;
+    GdkPixbuf * pixbuf;
 
     /* XXX: check NULL! */
     banner = gtk_event_box_new();
@@ -146,6 +147,11 @@ 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 size: */
+    pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(logo));
+    fe_data->logo_width = gdk_pixbuf_get_width(pixbuf);
+    fe_data->logo_height = gdk_pixbuf_get_height(pixbuf);
+
     g_signal_connect_after(G_OBJECT(banner), "expose_event",
                            G_CALLBACK(handle_exposed_banner), fe);
 

Attachment: signature.asc
Description: Digital signature


Reply to: