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 710600 - Re-sizing of primary/secondary icon inside GtkEntry
Re-sizing of primary/secondary icon inside GtkEntry
Status: RESOLVED INCOMPLETE
Product: gtk+
Classification: Platform
Component: Widget: GtkEntry
3.8.x
Other Linux
: Normal major
: ---
Assigned To: gtk-bugs
gtk-bugs
: 724522 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2013-10-22 03:51 UTC by Himanshu
Modified: 2017-07-31 19:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Primary and secondary icons are placed inside GtkEntry .The dimension of icons is fixed . (2.55 KB, image/png)
2013-10-22 03:51 UTC, Himanshu
  Details
Application source code to show the usage of new API . (19.25 KB, patch)
2013-10-22 04:24 UTC, Himanshu
none Details | Review

Description Himanshu 2013-10-22 03:51:17 UTC
Created attachment 257811 [details]
Primary and secondary icons are placed inside GtkEntry .The dimension of icons is fixed .

GtkEntry is a widget used in GTK+ to write text . Icons can be placed at the start and end of GtkEntry . In GtkEntry , only fixed size icon of dimension 16 x 16 can be placed . But applications developer may require to change the icon size according to the size of GtkEntry .  This is not possible in latest release of GTK+ . Due to this there is lot of size difference between icon and GtkEntry which does not look good if the size of GtkEntry is much bigger than the size of icon .
Comment 1 Himanshu 2013-10-22 04:24:19 UTC
Created attachment 257813 [details] [review]
Application source code to show the usage of new API .

I provided new feature enhancement in  GtkEntry to resize the icon through API 
( gtk_entry_set_icon_from_pixbuf_at_size(  GtkEntry             *entry,
                                	   GtkEntryIconPosition icon_pos,
                                	   GdkPixbuf            *pixbuf, 
                                            GtkIconSize GTK_ICON_SIZE_VARIABLE ).
This  interface allows application developers to change the icon size to any desired dimension from the application source code .

void
gtk_entry_set_icon_from_pixbuf_at_size (GtkEntry       *entry,
                                	GtkEntryIconPosition icon_pos,
                                	GdkPixbuf       *pixbuf, 
					GtkIconSize     GTK_ICON_SIZE_VARIABLE)			        

{
  GtkEntryPrivate *priv;
  EntryIconInfo *icon_info;
  g_return_if_fail (GTK_IS_ENTRY (entry));
  g_return_if_fail (IS_VALID_ICON_POSITION (icon_pos));

  priv = entry->priv;

  if ((icon_info = priv->icons[icon_pos]) == NULL)
    icon_info = construct_icon_info (GTK_WIDGET (entry), icon_pos);

  g_object_freeze_notify (G_OBJECT (entry));

  if (pixbuf)
    g_object_ref (pixbuf);

  gtk_entry_clear (entry, icon_pos);
 
  if (pixbuf)
    {
  
        _gtk_icon_helper_set_pixbuf (icon_info->icon_helper, pixbuf);
        _gtk_icon_helper_set_icon_size (icon_info->icon_helper,
                                        GTK_ICON_SIZE_VARIABLE );

      if (icon_pos == GTK_ENTRY_ICON_PRIMARY)
        {
          g_object_notify (G_OBJECT (entry), "primary-icon-pixbuf");
          g_object_notify (G_OBJECT (entry), "primary-icon-storage-type");
        }
      else
        {
          g_object_notify (G_OBJECT (entry), "secondary-icon-pixbuf");
          g_object_notify (G_OBJECT (entry), "secondary-icon-storage-type");
        }

      if (gtk_widget_get_mapped (GTK_WIDGET (entry)))
          gdk_window_show_unraised (icon_info->window);

      g_object_unref (pixbuf);
    }
  
  if (gtk_widget_get_visible (GTK_WIDGET (entry)))
    gtk_widget_queue_resize (GTK_WIDGET (entry));

  g_object_thaw_notify (G_OBJECT (entry));
}

 gtk icon size is set by _gtk_icon_helper_set_icon_size .
Earlier this is called as 
_gtk_icon_helper_set_icon_size (icon_info->icon_helper,
                                GTK_ICON_SIZE_MENU);

GTK_ICON_SIZE_MENU is an enum value of icon size 16 x 16 .

In the new API , I replaced GTK_ICON_SIZE_MENU with GTK_ICON_SIZE_VARIABLE in _gtk_icon_helper_set_icon_size function call . 

In application source code we can create new GtkIconSize as below :

GtkIconSize GTK_ICON_SIZE_VARIABLE  =   gtk_icon_size_register ( "gtk-primary"   , 25 , 25 ); 

This GTK_ICON_SIZE_VARIABLE can be passed to new API implemented by me in the below manner :

gtk_entry_set_icon_from_pixbuf_at_size 
         ( GtkEntry * entry,
           GtkEntryIconPosition icon_pos,
           GdkPixbuf            *pixbuf,
           GtkIconSize GTK_ICON_SIZE_VARIABLE )

Please find the application source code as an attachment to show the usage of new API .Attachments include source code , glade file
Comment 2 Daniel Boles 2017-07-31 19:32:16 UTC
*** Bug 724522 has been marked as a duplicate of this bug. ***
Comment 3 Daniel Boles 2017-07-31 19:33:12 UTC
Comment on attachment 257813 [details] [review]
Application source code to show the usage of new API .

This does not appear to be "Application source code". What are we supposed to do with it?
Comment 4 Daniel Boles 2017-07-31 19:37:39 UTC
Anyway, how to implement variable icon sizes is an ongoing discussion that I have seen several times on IRC, and therefore:

 * For GTK+ 3, it's unlikely that the stable/LTS GTK+ 3 will see any change here

 * For GTK+ 4, variable icon sizes is an ongoing discussion that I've seen in IRC
   several times, so it'll probably happen eventually - at which point it will
   need to do something considerably more thorough than simply adding a variable
   size to one of the multiple ways to set an icon on one single widget class.