Forum: Ruby-Gnome 2 image with emblem?

Posted by Michal Suchanek (Guest)
on 2011-08-16 10:54
(Received via mailing list)
Hello,

Is there a widget or simple combination of widgets that would display
an image with an emblem?

I see this used in many GTK applications but can't find any widget for 
it.

I will need a few buttons that could be constructed of standard images 
this way.

Thanks

Michal
Posted by Marc Heiler (shevegen)
on 2011-08-16 22:01
You mean to overlay an image on another image?

This is possible with Pixbuf. The standard ruby-gnome distribution has 
an example for that if I recall correctly.
Posted by Michal Suchanek (Guest)
on 2011-08-17 12:10
(Received via mailing list)
On 16 August 2011 22:01, Marc Heiler <ruby-forum-incoming@andreas-s.net> 
wrote:
> You mean to overlay an image on another image?
>
> This is possible with Pixbuf. The standard ruby-gnome distribution has
> an example for that if I recall correctly.

Yes, it's totally possible to create a new image combining two images
using gdk or otherwise.

It's nice that it's possible to do with ruby-gnome2, too.

What I was asking if there was a widget that would not require
actually combining the image. Ideally one that glade can display.

There is GLib::EmblemedIcon but no obvious way to display the icon as an 
image.

Thanks

Michal
Posted by Michal Suchanek (Guest)
on 2011-08-17 13:59
(Received via mailing list)
On 16 August 2011 22:01, Marc Heiler <ruby-forum-incoming@andreas-s.net> 
wrote:
> You mean to overlay an image on another image?
>
> This is possible with Pixbuf. The standard ruby-gnome distribution has
> an example for that if I recall correctly.
>

More precisely, it has an example of overlaying an image over 
checkerboard.

The composite! method (and its description) is broken.

While the description mentions a check_size parameter it's not
included in the parameter list.

The check_size parameter (or whatever is on its expected position) can
be set to zero which leads to gtk looping.

There is no way to set the dest_x and dest_y shown in the operation 
diagram.

The operation diagram shows the apple image applied with transparency
but actual method puts black background in place of the image's
transparent pixels.

The check1 and check2 colors are integers but the meaning of the
integers is not detailed. I set them to zero which might be
responsible for the black background but sane color meanings values
would assign full transparency to 0.

The second method call in the composite example actually does overlay
an image with transparency as can be seen when the second and third
call are swapped and the image not replaced with empty one in between
but why it is so is somewhat of a mystery as the method parameters
aren't really described anywhere nor does the method match any C or
python Pixbuf method.

Of course, there's always the source.

Thanks

Michal
Posted by Michal Suchanek (Guest)
on 2011-08-17 18:29
(Received via mailing list)
On 17 August 2011 13:58, Michal Suchanek <hramrach@centrum.cz> wrote:
>
> transparent pixels.
>
> The check1 and check2 colors are integers but the meaning of the
> integers is not detailed. I set them to zero which might be
> responsible for the black background but sane color meanings values
> would assign full transparency to 0.

The example achieves transparency be leaving out the checkerboard
arguments altogether.

Using that I can construct a combined image like this:

class Gtk::Widget
   def stock_icon_with_emblem icon, emblem
      icon = render_icon(icon ,Gtk::IconSize::DIALOG, nil).dup
      emblem = render_icon(emblem ,Gtk::IconSize::BUTTON, nil)
      icon.composite! emblem, icon.width - emblem.width, icon.height -
emblem.height, emblem.width, emblem.height, icon.width - emblem.width,
icon.width - emblem.width, 1, 1, Gdk::Pixbuf::INTERP_NEAREST, 255
      Gtk::Image.new icon
   end
end


@builder['button_restore'].image =
         @builder['button_restore'].stock_icon_with_emblem
@builder['image_disk'].stock, @builder['image_down'].stock

Thanks

Michal
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.