After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 654678 - Message dialog's primary text font increases on every call to gtk_message_dialog_format_secondary_text
Message dialog's primary text font increases on every call to gtk_message_dia...
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Class: GtkStyleContext
3.1.x
Other Linux
: Normal normal
: ---
Assigned To: Carlos Garnacho
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2011-07-15 13:32 UTC by Rodrigo Moya
Modified: 2011-07-19 10:00 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Use secondary text label font (1.05 KB, patch)
2011-07-15 13:34 UTC, Rodrigo Moya
needs-work Details | Review

Description Rodrigo Moya 2011-07-15 13:32:24 UTC
On every call to gtk_message_dialog_format_secondary_text, the font size of the primary text label in GtkMessageDialog gets increased, as it multiplies its current size by PANGO_SCALE_LARGE (see setup_primary_label_font). I guess what it really needs to do is multiply by the secondary text font size, rather than its own.

This can be easily replicated with the following code:


#include <gtk/gtk.h>

static void
print_countdown_text (GtkWidget *dialog)
{
	static gint seconds = 10;

	gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
						  "The application will close in %d seconds", seconds);
	seconds--;
	if (seconds == 0) {
		gtk_main_quit ();
	}
}

static void
timeout_cb (gpointer data)
{
	print_countdown_text (data);
}

int
main (int argc, char *argv[])
{
	GtkWidget *dialog;

	gtk_init (&argc, &argv);

	dialog = gtk_message_dialog_new (NULL,
					 GTK_DIALOG_MODAL,
					 GTK_MESSAGE_QUESTION,
					 GTK_BUTTONS_CLOSE,
					 "Do you want to wait for the program to finish?");
	g_signal_connect (dialog, "response",
			  G_CALLBACK (gtk_main_quit), NULL);
	g_timeout_add (1000, timeout_cb, dialog);

	print_countdown_text (dialog);

	gtk_widget_show (dialog);
	gtk_main ();

	return 0;
}

Attaching a patch to fix it
Comment 1 Rodrigo Moya 2011-07-15 13:34:22 UTC
Created attachment 192028 [details] [review]
Use secondary text label font
Comment 2 Matthias Clasen 2011-07-15 15:07:55 UTC
Review of attachment 192028 [details] [review]:

Doesn't look correct to me. 

We need to figure out why gtk_widget_modify_font (priv->label, NULL) doesn't have the desired effect.
Comment 3 Matthias Clasen 2011-07-15 15:45:56 UTC
It looks like this broke with the introduction of shorthand font properties.
Over to Benjamin.
Comment 4 Matthias Clasen 2011-07-15 16:28:20 UTC
<Company> mclasen: yeah, looks like i never implemented unset_property for shorthands
<Company> shouldn't be too hard to do
Comment 5 Benjamin Otte (Company) 2011-07-19 10:00:21 UTC
commit 20c6acfc8d1871da220c4fbd7ecbaff66da22927
Author: Benjamin Otte <otte@redhat.com>
Date:   Tue Jul 19 11:57:27 2011 +0200

    reftests: Add test for recent fix
    
    https://bugzilla.gnome.org/show_bug.cgi?id=654678

commit 6aa000f65b86ee180b8ddb4dd9e4564e9f0b9752
Author: Benjamin Otte <otte@redhat.com>
Date:   Tue Jul 19 11:42:31 2011 +0200

    styleproperties: Add unset functions for shorthands
    
    This fixes calls to gtk_style_properties_unset_property() for
    shorthand properties.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=654678