On 5/26/2017 6:05 AM, John Woodsman wrote:
> When running a Gtk program under MS-Windows, there is a little icon that
> appears in the tool-tray bar at the bottom of the screen - one for each program
> that is running.
> Major applications like Word or Chrome have their own unique logos.
> But the icon for all my Gtk programs just shows the Gtk logo.
> I would rather display an icon unique to each of my programs.
> As it is, the icon is really just showing the graphics lib my program used.
Just give a non-default icon to the window, and that's what you'll see on the
taskbar. If you use Glade UI definition files, it would look like this:
Another alternative is to use a Windows resource file (.rc) file to
specify the .ico file that you want to use for your app (as in any
Windows app), use the resource compiler (rc.exe for instance) to compile
the resource file and link the compiled resource file into your app, and
so you won't need to ship that icon file as a result.
Another option is to draw the icon with cairo. You can do this at run time if you want. This way you can experiment drawing icons and if you get something that you like you can always save it out to a file. I haven't tested the following on Windows but I would think that it will work fine.
> Just give a non-default icon to the window, and that's what you'll see on the
> taskbar. If you use Glade UI definition files, it would look like this:
> <object class="GtkApplicationWindow" id="my_main_window_id">
> <property name="icon_name">name-of-the-icon-of-your-app</property>
> And in Glade itself it's just like any other property.
> Obviously, you'll need to install the icon in an appropriate place
> (share/icons/hicolor/<size>/apps/<name-of-the-icon-of-your-app>.png) and run
> gtk-update-icon-cache for it to be found.
This looks like a good solution to me. But instead of placing the icons
in external files you (I'm talking to John) may be also interested in
GResource framework  which does a similar thing like Windows resources,
that means embeds images and other data files inside the executable file
but is not based on Windows API. You will need a glib-compile-resources
utility.  Also you should see how GtkApplication object handles the
embedded resources.