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

2008-04-05 Thread Milan Bouchet-Valat
Le samedi 05 avril 2008 à 06:18 +0800, 洪任諭 wrote:
 This is quoted from gtk+ API doc.
 I think this weird behavior is related to your problem.
 
 gtk_icon_info_load_icon ()
 
 GdkPixbuf*  gtk_icon_info_load_icon (GtkIconInfo 
 *icon_info,
  GError **error);
 
 Renders an icon previously looked up in an icon theme using
 gtk_icon_theme_lookup_icon(); the size will be based on the size
 passed to gtk_icon_theme_lookup_icon(). Note that the resulting pixbuf
 may not be exactly this size; an icon theme may have icons that differ
 slightly from their nominal sizes, and in addition GTK+ will avoid
 scaling icons that it considers sufficiently close to the requested
 size or for which the source image would have to be scaled up too far.
 (This maintains sharpness.)
 
 gtk+ doestn't load images in the size you specified.
 This really bothersome in some cases.
Thanks for this interesting quotation. But I can't see how this may
affect my case. Here's my scheme:
- two icon sources: one SVG and one PNG-22x22
- a GtkStatusIcon that normally is set to 22x22

Why the hell would GTK+ draw the icon from SVG in 20x20, and then
consider this as better than 22x22?! Moreover, when the SVG is removed
and I set size_wilcarded to FALSE for the PNG, the GtkStatusIcon has no
icon at all, so this is not about scaling anything.

Cheers

___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list


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

2008-04-04 Thread Milan Bouchet-Valat
Brian J. Tarricone wrote:
 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.
Indeed, GTK makes a copy of the IconSource. This is documented here:

http://library.gnome.org/devel/gtk/2.12/gtk-Themeable-Stock-Images.html#gtk-icon-set-add-source
This function copies source, so you can reuse the same source
immediately without affecting the icon set.

And I tried with several methods, only using SVG or PNG to check what
could be wrong.

Thanks anyway - other ideas?


___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list


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

2008-04-02 Thread Milan
Hi!

Improving the GtkStatusIcon support in a program, I bumped into a
problem that I believe is a bug. I reported it here:
http://bugzilla.gnome.org/show_bug.cgi?id=524488
I tried getting help on gtk-app-devel, but nobody answered. Since I'm
still not sure this is a bug, I ask here to get more information. Just
tell me if what I use is not the recommended way to do this. On the
contrary, I'd be pleased to make more tests if this is likely to be a
bug.


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.

Normally, the status icons measure: (height of the panel) - 2 px. But
this is not true in my case, the icon is always smaller than it should.
The strange point is, if I set the GtkStatus Icon directly from an icon
file, the size is 22x22.

Is that a bug in GNOME/GTK or am I doing something wrong? I guess this
would be the prefferred way of setting up a status icon, since with a
custom stock icon it can be risized without problems - but still I may
have missed something.


Thanks in advance!


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





___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list


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

2008-04-02 Thread Brian J. Tarricone
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
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list