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 670082 - GtkLabel request more space blow and on the right.
GtkLabel request more space blow and on the right.
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkLabel
3.2.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
: 670234 673643 702752 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2012-02-14 16:08 UTC by huzheng001@gmail.com
Modified: 2015-11-26 08:22 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description huzheng001@gmail.com 2012-02-14 16:08:03 UTC
Test program:
=====
//gcc label.c -o label $(pkg-config --cflags --libs gtk+-3.0)

#include <gtk/gtk.h>

gboolean on_delete_event(GtkWidget * window, GdkEvent *event , gpointer data)
{
	gtk_main_quit();
	return TRUE;
}

int main(int argc, char **argv)
{
	gtk_init(&argc, &argv);
	GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_resizable(GTK_WINDOW (window), FALSE);
	g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (on_delete_event), NULL);
	GtkWidget *fixed = gtk_fixed_new ();
	gtk_widget_set_size_request (fixed, 50, 50);
	gtk_container_add(GTK_CONTAINER(window), fixed);
	GtkWidget *label = gtk_label_new("The label is not limited in the fixed widget(which is 50*50). And much more space are requested blow and on the right.");
	gtk_widget_set_size_request (label, 155, -1);
	gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
	gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
	gtk_fixed_put (GTK_FIXED (fixed), label, 10, 10);
	gtk_widget_show_all(window);
	gtk_main();
	return FALSE;
}
=====

Three problem:
1. More space is requested blow the label.

2. More space is requested on the right of the label.
if you remove
gtk_window_set_resizable(GTK_WINDOW (window), FALSE);
It will not request more space on the right.

3. The label is not limited in the fixed widget, if you compile this program as
gcc label.c -o label $(pkg-config --cflags --libs gtk+-2.0)
You will see the label is limited in the fixed widget in gtk2, which is right!
Comment 1 Matthias Clasen 2013-05-13 01:26:33 UTC
*** Bug 670234 has been marked as a duplicate of this bug. ***
Comment 2 Arx Cruz 2013-06-21 14:33:22 UTC
This is also impacting #702752 and #673643 on Zenity
Comment 3 Arx Cruz 2013-09-25 13:50:26 UTC
*** Bug 702752 has been marked as a duplicate of this bug. ***
Comment 4 huzheng001@gmail.com 2013-11-22 10:53:41 UTC
When will this bug be fixed? I am waiting for it!!!
Comment 5 Matthias Clasen 2013-11-22 14:26:53 UTC
There's no point in waiting for it. GtkLabel behaves as it should here, although it may be a little surprising at first.

You need to set suitable values for char-width and max-char-width.
Comment 6 huzheng001@gmail.com 2013-11-23 02:18:52 UTC
I have added these two lines to the test program, but it still didn't solve the problem! We need to set the max widget size, not max characters, for example, Chinese characters are wider than English characters. Characters' wide size are not fixed, while we need a fixed max wide size!
 
    gtk_label_set_width_chars(GTK_LABEL (label), 12);
    gtk_label_set_max_width_chars(GTK_LABEL (label), 24);
Comment 7 huzheng001@gmail.com 2014-04-08 00:50:42 UTC
When will this bug be fixed? I am waiting for it eagerly(StarDict)!!
Can you tell me your paypal account? I would like to donate some money for this bug fix!!!
Comment 8 Matthias Clasen 2014-04-08 11:25:23 UTC
gtk has no concept of max widget size. why do you think you need to set this ?
specifying label width in characters instead of pixels is generally preferred, because it adapts to font change, etc.
Comment 9 huzheng001@gmail.com 2014-04-09 10:54:12 UTC
Test program:
=====
//gcc label3.c -o label3 $(pkg-config --cflags --libs gtk+-3.0)

#include <gtk/gtk.h>

gboolean on_delete_event(GtkWidget * window, GdkEvent *event , gpointer data)
{
    gtk_main_quit();
    return TRUE;
}

int main(int argc, char **argv)
{
    gtk_init(&argc, &argv);
    GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    //gtk_window_set_resizable(GTK_WINDOW (window), FALSE);
    g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK
(on_delete_event), NULL);
    GtkWidget *fixed = gtk_fixed_new ();
    //gtk_widget_set_size_request (fixed, 50, 50);
    gtk_container_add(GTK_CONTAINER(window), fixed);
    GtkWidget *label = gtk_label_new("您在使用最新版的星际译王!\n\n最新版本信息:\n星际译王-3.0.1 发布了。\n新特性:\n* Debian支持。\n* Dict.cn插件。\n* vs2005编译支持。\n* Windows TTS引擎单词朗读插件。\n* WordNet插件。\n* 正则表达式查询支持。\n* IP地址查询插件。\n* 大量其他改进。\n\n最近的新闻:\n        南无阿弥陀佛!南无破有如来(速证须陀洹果)!南无宝小相如来(速证阿罗汉果)!南无四维空间破有如来!        开窍:善心行恶法(硬汉),善心行俗法(爱敬法)。一切有大力,其心无嫉妒。去掉嫉妒心长强壮:思维想通大家都可以很厉害,不必嫉妒!        生起对他人的恭敬心则长得高,你看长得高的人都有恭敬心!        生起感恩心则生活得幸福!        所有爱情都是伤感的,因为爱情里掺了欲望,因此菩萨抛弃爱情(诸漏是苦)。  要不掺欲望真心地爱!   终于解脱了爱情。解脱爱情的关键在于去掉淫欲贪!        由爱欲故生忧,由爱欲故生怖,若离于爱欲,无忧亦无怖!        修成财神法,每月布施工资80%到90%,坚持5到7个月,实践者成财神,财富上亿!\n");
    gtk_widget_set_size_request (label, 455, -1);
    gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
    gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
    gtk_label_set_width_chars(GTK_LABEL (label), 12);
    gtk_label_set_max_width_chars(GTK_LABEL (label), 24);
    gtk_fixed_put (GTK_FIXED (fixed), label, 10, 10);
    gtk_widget_show_all(window);
    gtk_main();
    return FALSE;
}
=====

Problem:
More space is requested blow the label!
Comment 10 Arx Cruz 2014-04-18 20:42:34 UTC
*** Bug 673643 has been marked as a duplicate of this bug. ***
Comment 11 Yann 2014-04-19 00:11:54 UTC
Matthias,
I am not sure to understand your comment #5 : do you mean this bug is invalid?
If so, then I guess bug #673643 is not duplicate?
Comment 12 dennis123321 2014-05-18 20:53:12 UTC
(In reply to comment #11)
> Matthias,
> I am not sure to understand your comment #5 : do you mean this bug is invalid?
> If so, then I guess bug #673643 is not duplicate?

That's what it sounds like to me...

I have the oversized dialogs issue with Zenity. Just noticed it today as I was using GTK2 zenity previously.
Comment 13 Matthias Clasen 2014-05-19 12:57:17 UTC
the example in comment 9 has some unneeded complications in it that make it hard to see whats going on.

here is a version that gets a reasonable window size:

int main(int argc, char **argv)
{
    gtk_init(&argc, &argv);
    GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    GtkWidget *label = gtk_label_new("您在使用最新版的星际译王!\n\n最新版本信息:\n星>际译王-3.0.1\
发布了。\n新特性:\n* Debian支持。\n* Dict.cn插件。\n* vs2005编译支持。\n* Windows TTS>引擎单词朗读插件。\n*\
WordNet插件。\n* 正则表达式查询支持。\n* IP地址查询插件。\n* 大量其他改进。\n\n最近的新
闻:\n       \
南无阿弥陀佛!南无破有如来(速证须陀洹果)!南无宝小相如来(速证阿罗汉果)!南无四维空>间破有如来!  \
开窍:善心行恶法(硬汉),善心行俗法(爱敬法)。一切有大力,其心无嫉妒。去掉嫉妒心长强>壮:思维想通大家都可以很厉害,不必嫉妒!       \
生起对他人的恭敬心则长得高,你看长得高的人都有恭敬心!        生起感恩心则生活得幸福!       \
所有爱情都是伤感的,因为爱情里掺了欲望,因此菩萨抛弃爱情(诸漏是苦)。  要不掺欲望真心>地爱!   终于解脱了爱情。解脱爱情的关键在于去掉淫欲贪!      \
 由爱欲故生忧,由爱欲故生怖,若离于爱欲,无忧亦无怖!       \
修成财神法,每月布施工资80%到90%,坚持5到7个月,实践者成财神,财富上亿!\n");
    gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
    gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
    gtk_label_set_width_chars(GTK_LABEL (label), 40);
    gtk_label_set_max_width_chars(GTK_LABEL (label), 40);
    gtk_container_add(GTK_CONTAINER(window), label);
    gtk_widget_show_all(window);
    gtk_main();
    return FALSE;
}
Comment 14 huzheng001@gmail.com 2015-11-26 08:22:06 UTC
It seems this bug is fixed now!!!