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 524488 - GtkStatusIcon wrong size when created from a custom stock icon
GtkStatusIcon wrong size when created from a custom stock icon
Status: RESOLVED WONTFIX
Product: gtk+
Classification: Platform
Component: Widget: GtkStatusIcon
2.10.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
: 588113 593345 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2008-03-26 14:17 UTC by Milan Bouchet-Valat
Modified: 2014-08-30 05:20 UTC
See Also:
GNOME target: ---
GNOME version: 2.21/2.22



Description Milan Bouchet-Valat 2008-03-26 14:17:27 UTC
Basically, the default size of the GtkStatusIcon is 20x20px when you create it from a custom stock icon (using GtkIconFactory), while it normally should be set to 22x22.

I'm trying to use the GtkIconFactory system to set the icon used by GtkStatusIcon. Once I've created the GtkIconSet for my icons (with SVG and PNG versions of the same icon), I use gtk_status_icon_set_from_stock. Everything goes right, except that the created icon is 20x20 px by default (i.e. when the GNOME panel is set to a size of 24 px), when it should be (like every app does) 22x22. The SVG version is thus used (because the size is non-standard), but if if only provide a PNG version of 22x22 px, it is even resized to fit the 20x20 size, and therefore is blurry.

Normally, the status icons measure: (height of the panel) - 2 px. But this is not true in my case until the panel is >= 26 px. The strange point is, if I set the GtkStatusIcon directly from an icon file, the size is 22x22. If I set it from a GTK stock icon, it also has the right size of 22x22.

I'm not really sure this is a GTK bug - it might still be a gnome-panel one.


Please just ask for any information/testing. Thanks.





Here's for reference a part of the code that I use (it's in
gnunet-gtk from the GNUnet project):

  char *instDir;
  char *iconPath;
  GtkStatusIcon *trayIcon;
  GtkIconSet *iconSet;
  GtkIconSource *iconSource;
 (...)


  iconSet = gtk_icon_set_new ();
  iconSource = gtk_icon_source_new ();
  iconPath =
    g_build_filename (instDir, "..", "gnunet-gtk",
                      "gnunet-gtk-status-connected.svg", NULL);
  gtk_icon_source_set_filename (iconSource, iconPath);
  g_free (iconPath); 
  gtk_icon_set_add_source (iconSet, iconSource);
  iconPath =
    g_build_filename (instDir, "..", "gnunet-gtk",
                      "gnunet-gtk-status-connected.png", NULL); // 22x22px icon
  gtk_icon_source_set_filename (iconSource, iconPath);
  g_free (iconPath);
  gtk_icon_source_set_size_wildcarded (iconSource, FALSE);
  gtk_icon_set_add_source (iconSet, iconSource);

  // this icon factory has already been added to the default
  gtk_icon_factory_add (GNUNET_GTK_get_iconFactory(),
                        "gnunet-gtk-status-connected",
                        iconSet);
  gtk_icon_set_unref (iconSet);
  gtk_icon_source_free (iconSource);
  gtk_status_icon_set_from_stock (trayIcon, "gnunet-gtk-status-connected");
Comment 1 Jonathan Matthew 2009-07-09 09:37:06 UTC
*** Bug 588113 has been marked as a duplicate of this bug. ***
Comment 2 Jonathan Matthew 2009-08-28 01:16:36 UTC
*** Bug 593345 has been marked as a duplicate of this bug. ***
Comment 3 Pelle K 2009-09-25 16:01:14 UTC
It would seem this issue is fixed with the rhythmbox 0.12.5 status icon in Ubuntu 9.10, for me anyway (gtk 2.18.0). Is this bug still left in gtk 2.18.0?
Comment 4 Matthias Clasen 2014-08-30 05:20:24 UTC
GtkStatusIcon has been deprecated