GNOME Bugzilla – Bug 724522
Primary/Secondary icon resizing in GtkEntry
Last modified: 2017-07-31 19:32:16 UTC
Hi All , In GtkEntry widget , the size of primary/secondary icon is fixed to 16 x 16 pixels irrespective of size of GtkEntry. gtk_entry_set_icon_from_pixbuf API is used for setting primary/secondary icon in GtkEntry , but icon is always set of dimension of GTK_ICON_SIZE_MENU ( 16 x 16 ). Primary/secondary icon should scale to size of any desired input from application . Please find the proposed patch below : In GtkEntry source code (gtkentry.c) I implemented new API "gtk_entry_set_icon_from_pixbuf_at_size" so that user can change the size to any desired dimension . _gtk_icon_helper_set_icon_size (icon_info->icon_helper, icon_size ); Usage of API in application code : int main( int argc, char *argv[] ) { gtk_init (&argc, &argv); GtkBuilder *builder = gtk_builder_new (); gtk_builder_add_from_file (builder, "icon.glade", NULL); window = GTK_WIDGET (gtk_builder_get_object (builder, "window1")); gtk_entry1 = GTK_WIDGET (gtk_builder_get_object (builder, "entry1")); gtk_entry2 = GTK_WIDGET (gtk_builder_get_object (builder, "entry2")); pixbuf_entry1 = gdk_pixbuf_new_from_file("primary_icon.png", NULL); pixbuf_entry2 = gdk_pixbuf_new_from_file("secondary_icon.png", NULL ); pixbuf_entry3 = gdk_pixbuf_new_from_file("primary_icon.png" , NULL); pixbuf_entry4 = gdk_pixbuf_new_from_file("secondary_icon.png" ,NULL); /* Creating icon size of varied dimension */ GtkIconSize GTK_ICON_SIZE_1_PRIMARY = gtk_icon_size_register ( "gtk-1-primary" , 16 , 16 ); GtkIconSize GTK_ICON_SIZE_1_SECONDARY = gtk_icon_size_register ( "gtk-2-secondary" , 83 , 53 ); GtkIconSize GTK_ICON_SIZE_2_PRIMARY = gtk_icon_size_register ( "gtk-1-primary" , 35 , 35 ); GtkIconSize GTK_ICON_SIZE_2_SECONDARY = gtk_icon_size_register ( "gtk-2-secondary" , 55 , 35 ); gtk_entry_set_icon_from_pixbuf_at_size (GTK_ENTRY(gtk_entry1),GTK_ENTRY_ICON_PRIMARY, pixbuf_entry1,GTK_ICON_SIZE_1_PRIMARY ); gtk_entry_set_icon_from_pixbuf_at_size (GTK_ENTRY(gtk_entry1),GTK_ENTRY_ICON_SECONDARY,pixbuf_entry2,GTK_ICON_SIZE_1_SECONDARY ); gtk_entry_set_icon_from_pixbuf_at_size (GTK_ENTRY(gtk_entry2),GTK_ENTRY_ICON_PRIMARY, pixbuf_entry3,GTK_ICON_SIZE_2_PRIMARY ); gtk_entry_set_icon_from_pixbuf_at_size (GTK_ENTRY(gtk_entry2),GTK_ENTRY_ICON_SECONDARY,pixbuf_entry4,GTK_ICON_SIZE_2_SECONDARY ); gtk_widget_show_all (window); gtk_main (); return 0; }
No patch was provided here, and anyway this is a dupe of Bug 710600; please make any updates there instead of starting another bug. *** This bug has been marked as a duplicate of bug 710600 ***