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 670068 - GtkEntry don't accept small size.
GtkEntry don't accept small size.
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkEntry
3.2.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2012-02-14 13:18 UTC by huzheng001@gmail.com
Modified: 2014-12-06 04:42 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description huzheng001@gmail.com 2012-02-14 13:18:44 UTC
Do a gtk_widget_set_size_request(entry, 28, 17) to the entry, you will see it is still being a normal size, but not the small size which by set.

Test program:
=====
//gcc entrysize.c -o entrysize $(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);
	g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (on_delete_event), NULL);
	GtkWidget *entry = gtk_entry_new();
	gtk_widget_set_size_request(entry, 28, 17);
	gtk_container_add(GTK_CONTAINER(window), entry);
	gtk_widget_show_all(window);
	gtk_main();
	return FALSE;
}
=====

if you compile it with
gcc entrysize.c -o entrysize $(pkg-config --cflags --libs gtk+-2.0)
you will see the entry become small(as in gtk2), but in gtk3 it fails!
Comment 1 Steffen Gutmann 2012-09-27 16:59:58 UTC
I believe this problem/bug applies in general to most if not all objects derived from GtkWidget.  For example I ran into the same issue with GtkImage where I wanted the minimum size of the GtkImage be smaller than that of the underlying image.  Using GTK2 this is possible but under GTK3 the call to gtk_widget_set_size_request does not have any effect and the minimum size is the size of the image.

In other words, gtk_widget_set_size_request stopped working with GTK3.
Comment 2 Cosimo Cecchi 2012-09-27 17:09:33 UTC
In GTK3 you can't under-allocate the widget to a size less than its minimum requisition, no. The size of the entry is calculated automatically from the font/text size and the size of the border and padding around it; if you want it smaller, you can set a smaller font size on the widget or change the padding using CSS.
Comment 3 Steffen Gutmann 2012-09-27 17:19:30 UTC
Ok, but how about for GtkImage?  Wouldn't it make sense to allow the min size to be smaller like in GTK2?  The image would then be cropped and/or centered.
Comment 4 Cosimo Cecchi 2012-09-27 20:29:29 UTC
You can force a specific size to GtkImage using its "pixel-size" property.
Comment 5 Steffen Gutmann 2012-09-28 16:27:42 UTC
No, setting the pixel-size does not have any effect on a GtkImage when using a GdkPixbuf as image.  

I think it's better to continue this topic on the gtk-devel-list since GtkImage is out of scope for the subject of this bug.
Comment 6 Matthias Clasen 2014-12-06 04:42:57 UTC
to make entries request a small size, use gtk_entry_set_width_chars() and gtk_entry_set_max_with_chars()