Re: [Bug?] GtkStatusIcon bad default size when used with GtkIconFactory



Milan wrote:
I'm trying to use the GtkIconFactory system to set the icon used by
GtkStatusIcon. Once I've created the GtkIconSet for my icons (I have 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.

Not 100% sure, but I think this might be a bug in your code.  See below:

Here's for reference a part of the code that I use, if you like (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);

What happens when you create a new GtkIconSource here for the PNG icon? E.g.:

    iconSource = gtk_icon_source_new();

I'm not sure, but gtk probably doesn't make a copy of the GtkIconSource you add via gtk_icon_set_add_source(). So when you set the PNG filename a couple lines down from here, you actually overwrite the entry for the SVG icon above. Again, not completely sure here, as I don't have time to read the docs atm, but give it a try.

  iconPath =
    g_build_filename (instDir, "..", "gnunet-gtk",
                      "gnunet-gtk-status-connected.png", NULL);
  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);

  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");

	-brian


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]