GNOME Bugzilla – Bug 670068
GtkEntry don't accept small size.
Last modified: 2014-12-06 04:42:57 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!
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.
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.
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.
You can force a specific size to GtkImage using its "pixel-size" property.
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.
to make entries request a small size, use gtk_entry_set_width_chars() and gtk_entry_set_max_with_chars()