embedded icons

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

embedded icons

Zane C. B-H.
Any one know of any modules or etc that make embedding a icon in the
Perl code easy?

_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list

signature.asc (203 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: embedded icons (solved)

Zane C. B-H.
On Fri, 28 May 2010 05:24:21 -0500
"Zane C.B." <[hidden email]> wrote:

> Any one know of any modules or etc that make embedding a icon in the
> Perl code easy?

Solved this using XPM. The format is very easy to escape and embed.

_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list

signature.asc (203 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: embedded icons

csincock-gmail
In reply to this post by Zane C. B-H.

I don't know of any modules off the top of my head
but you can do something like this:

--example

  my @default_icon_xpm_data = (
  '9 9 2 1',
  '       c None',
  '.      c #000000',
  '         ',
  ' ... ... ',
  ' ..   .. ',
  ' . . . . ',
  '    .    ',
  ' . . . . ',
  ' ..   .. ',
  ' ... ... ',
  '         '
  );

  Gtk2::Gdk::Pixbuf->new_from_xpm_data(@resize_xpm_data)
  my $pixb = Gtk2::Gdk::Pixbuf->new_from_xpm_data(@default_icon_xpm_data);
  my ($pixmap,$mask)= $pixb->render_pixmap_and_mask(100);
  my $img=Gtk2::Image->new_from_pixmap($pixmap,$mask);

--end of example

you can save the icon you want to embed as an xpm file, then open it in
a text editor, and copy the data lines into a perl list as above.
(the xpm file format is actually C code for a list of strings).

cheers,
Chris


On Fri, 28 May 2010 12:00:21 +0000
[hidden email] wrote:

> Date: Fri, 28 May 2010 05:24:21 -0500
> From: "Zane C.B." <[hidden email]>
> Any one know of any modules or etc that make embedding a icon in the
> Perl code easy?
_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

Re: embedded icons (solved)

Grant McLean
In reply to this post by Zane C. B-H.
On Fri, 2010-05-28 at 08:48 -0500, Zane C.B. wrote:
> On Fri, 28 May 2010 05:24:21 -0500
> "Zane C.B." <[hidden email]> wrote:
>
> > Any one know of any modules or etc that make embedding a icon in the
> > Perl code easy?
>
> Solved this using XPM. The format is very easy to escape and embed.

Yes, XPM is good for that purpose.  Another alternative is to use the
contents of a PNG file as a base64_encoded block:

my $png_data = decode_base64(<<'EOF');
iVBORw0KGgoAAAANSUhEUgAAAIcAAABTCAMAAACCluQBAAAAwFBMVEW7u7gwIiIrKyhBJyM8Ojc3
O0BkMzE6QlZSPDxxMS46Tjk7R2NASVBhPjtDTEdOSEo7TXGBNjQ8YDp2Q0OFQ0FFWX4/WY9MYUyc
PjxnV1haXVxTXXOURkRAYJ49djxBZa2rSEZAa7u3RkVReFE/b8o6jTnFR0Vsb25BdNg7eOlFduFk
...
a2zP5zW3xZQ0fuOLYRfxved9wZTfwdzffm4xfuVy3qzzw3Cx7m0Xw8vHf/sainxj8/EvuJzo499x
HT7+B67/AKql/D/6JY9WAAAAAElFTkSuQmCC
EOF

my $loader = Gtk2::Gdk::PixbufLoader->new;
$loader->write($png_data);
$loader->close;
return $loader->get_pixbuf;

XPM has the advantage that you can edit the image with your text editor,
but the PNG option is useful with larger more detailed images.

Cheers
Grant

_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

Re: embedded icons (solved)

muppet-6
In reply to this post by Zane C. B-H.

On May 28, 2010, at 9:48 AM, Zane C.B. wrote:

> On Fri, 28 May 2010 05:24:21 -0500
> "Zane C.B." <[hidden email]> wrote:
>
>> Any one know of any modules or etc that make embedding a icon in the
>> Perl code easy?
>
> Solved this using XPM. The format is very easy to escape and embed.

xpm2perl doesn't appear to have made it to git, but exists for this very purpose.

http://gtk2-perl.cvs.sourceforge.net/viewvc/gtk2-perl/gtk2-perl-xs/helpers/xpm2perl?revision=1.1&view=markup


http://gtk2-perl.cvs.sourceforge.net/viewvc/*checkout*/gtk2-perl/gtk2-perl-xs/helpers/xpm2perl?revision=1.1

--
And now we see that Evil will always triumph, because Good is dumb.
  -- Lord Dark Helmet

_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list