RE: [fltk.general] Re: FLTK Window icon for program GNU/ Linux [General Use]

32 views
Skip to first unread message

MacArthur, Ian (Leonardo, UK)

unread,
Jun 29, 2016, 5:09:58 AM6/29/16
to fltkg...@googlegroups.com
> That worked for me:

> Fl_Pixmap win_pixmap(icon_xpm);
> Fl_RGB_Image win_icon(&win_pixmap, Fl_Color(0));
> win->icon(&win_icon);

> But is it also possible to set an icon for windows from these
> "convenient functions" like fl_message() or fl_file_chooser() in a
> similar way?


Hmm, I'm not sure what you are asking for here - which icon is it that you want to change in this case?

The convenience function dialogs are usually tied to a parent application (indeed the dialogs in question are frequently modal) and *most* window managers do not show any icon for them.

What window manager are you using? What effect are you hoping to attain?



Selex ES Ltd
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 3EL
A company registered in England & Wales. Company no. 02426132
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************

Karl Harbinger

unread,
Jul 9, 2016, 1:48:56 PM7/9/16
to fltk.general, ian.ma...@leonardocompany.com
Am Mittwoch, 29. Juni 2016 11:09:58 UTC+2 schrieb MacArthur, Ian (Leonardo, UK):
Hmm, I'm not sure what you are asking for here - which icon is it that you want to change in this case?

The convenience function dialogs are usually tied to a parent application (indeed the dialogs in question are frequently modal) and *most* window managers do not show any icon for them.

What window manager are you using? What effect are you hoping to attain?
I'm using Unity, and I want to set the (pixmap) icon which will then be visible in the task bar. I can achieve this by using the code win->icon(&win_icon); , but I can't do that with fl_message() for example.
I know I can use .dekstop files, but I'd still like to have embedded icons for portable apps. I can do this for example very easily in Qt, but in FLTK it seems to be a little troublesome.

chris

unread,
Jul 10, 2016, 11:48:18 AM7/10/16
to fltkg...@googlegroups.com
Am 09.07.2016 um 19:48 schrieb Karl Harbinger:

> I'm using Unity, and I want to set the (pixmap) icon which will then be
> visible in the task bar. I can achieve this by using the code
> /win->icon(&win_icon);/ , but I can't do that with fl_message() for example.

It can be done, but only with a dirty trick. The problem is, that you
don't know the Fl_Window of the dialog and that the dialog is modal.

If you set a timeout handler *before* calling the convenience dialog
method, you can find out the Fl_Window pointer of the dialog in the
timer callback with Fl::first_window() and set it's icon.


void cb_to()
{
if ( Fl::first_window() )
{
Fl_Window *win = Fl::first_window(); // the window of the dialog
// now set the icon as usual
...
}
}

// main
...
// set timeout before opening dialog
Fl::add_timeout( 0.3, cb_to );

// the dialog
fl_message( ... )


Hacky, I know, but at least on Ubuntu 14.04 this works.

Karl Harbinger

unread,
Aug 1, 2016, 8:26:28 PM8/1/16
to fltk.general, wc...@gmx.net
Someone else already posted a solution that worked for me.
I just put the following code in my main() function before the first window is started:


Fl_Pixmap win_pixmap(icon_xpm);
Fl_RGB_Image win_icon(&win_pixmap, Fl_Color(0));
Fl_Window::default_icon(&win_icon);

This will also work on the dialoges from fl_ask.H
Reply all
Reply to author
Forward
0 new messages