 |
|
| Linux Forum Index » Linux Development - Applications » How to change my c++ program's icon?... |
|
Page 2 of 2 Goto page Previous 1, 2 |
|
| Author |
Message |
| Josef Moellers... |
Posted: Thu Sep 24, 2009 4:55 am |
|
|
|
Guest
|
Ryan McCoskrie wrote:
Quote: Dos-Man 64 wrote:
On Sep 22, 3:38 pm, Ryan McCoskrie <ryan.mccosk... at (no spam) invalid.invalid
wrote:
I think the best advise here is forget everything you know about
computers[1].
_ALL_ of it.
Search for "Unix programming"[2] on the web.
Start learning again.
[1] I had to do this as well a while ago.
[2] This will mostly be C and shell script but
the principles are mainly what you need to
learn.
Well, I am an excellent C programmer already. Well, that's my opinion
anyway. And I am familiar with shell scripting already. Where I
struggle is in determining how X does some things differently than the
way Microsoft Windows was doing it. It's the same general tasks that
are being performed; it's just a matter of the tasks being done
differently.
The reason that I said to look those up is because your dealing with a
different way of thinking about programming.
Embedding icons into executables is a cute idea but also kinda' silly
sounding. Why would you want that kind of a feature on a natively command
line operating system?
Things have advanced in the last 30 odd years.
If the application is one that requires a GUI, it would make perfect sense.
Also, all applications that run on the command line also run inside a
GUI, so it would be "a cute idea" to have the icon embedded. Note that
you are not forced to have an icon embedded, but you could, if you
wanted to.
You could have an ELF section which contains one (or more) icons. If
that section is not present, or if you cannot open that file for
reading, you just deal with the application as usual.
However, I'm not sure whether all GUIs (this is where Linux differs from
some other OS) can handle the same subset of icon types and resolutions.
Josef
--
These are my personal views and not those of Fujitsu Technology Solutions!
Josef Möllers (Pinguinpfleger bei FTS)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://de.ts.fujitsu.com/imprint.html |
|
|
| Back to top |
|
|
|
| Dos-Man 64... |
Posted: Thu Sep 24, 2009 5:49 pm |
|
|
|
Guest
|
On Sep 24, 5:55 am, Josef Moellers <josef.moell... at (no spam) ts.fujitsu.com>
wrote:
Quote: Ryan McCoskrie wrote:
Dos-Man 64 wrote:
On Sep 22, 3:38 pm, Ryan McCoskrie <ryan.mccosk... at (no spam) invalid.invalid
wrote:
I think the best advise here is forget everything you know about
computers[1].
_ALL_ of it.
Search for "Unix programming"[2] on the web.
Start learning again.
[1] I had to do this as well a while ago.
[2] This will mostly be C and shell script but
the principles are mainly what you need to
learn.
Well, I am an excellent C programmer already. Well, that's my opinion
anyway. And I am familiar with shell scripting already. Where I
struggle is in determining how X does some things differently than the
way Microsoft Windows was doing it. It's the same general tasks that
are being performed; it's just a matter of the tasks being done
differently.
The reason that I said to look those up is because your dealing with a
different way of thinking about programming.
Embedding icons into executables is a cute idea but also kinda' silly
sounding. Why would you want that kind of a feature on a natively command
line operating system?
Things have advanced in the last 30 odd years.
If the application is one that requires a GUI, it would make perfect sense.
Also, all applications that run on the command line also run inside a
GUI, so it would be "a cute idea" to have the icon embedded. Note that
you are not forced to have an icon embedded, but you could, if you
wanted to.
You could have an ELF section which contains one (or more) icons. If
that section is not present, or if you cannot open that file for
reading, you just deal with the application as usual.
However, I'm not sure whether all GUIs (this is where Linux differs from
some other OS) can handle the same subset of icon types and resolutions.
Josef
--
These are my personal views and not those of Fujitsu Technology Solutions!
Josef Möllers (Pinguinpfleger bei FTS)
If failure had no penalty success would not be a prize (T.. Pratchett)
Company Details:http://de.ts.fujitsu.com/imprint.html
I'm with you This seems to me to be a legitimate GUI-based OS
(although not all instances that are running are running in graphical
mode.) Icons are a part of that. The applications do have a default
icon assigned to them anyway, so it makes sense for the programmer to
have some say over what icon is used, but with the end user having the
final say and being able to change it if they so desire. Well, that's
just my opinion. Icons really don't add anything to the executable's
size, usually less than 1k. An application using a default icon
probably wouldn't add more than a handful of bytes to indicate there
is no icon. |
|
|
| Back to top |
|
|
|
| John Hasler... |
Posted: Fri Sep 25, 2009 5:11 am |
|
|
|
Guest
|
Dos-Man 64 writes:
Quote: The applications do have a default icon assigned to them anyway...
Not necessarily. I use a GUI but have no icons assigned to anything.
Quote: ...so it makes sense for the programmer to have some say over what
icon is used, but with the end user having the final say and being
able to change it if they so desire.
The programmer can include a default icon in his package without putting
it in the executable. There is no reason to cram everything into one
file.
--
John Hasler
jhasler at (no spam) newsguy.com
Dancing Horse Hill
Elmwood, WI USA |
|
|
| Back to top |
|
|
|
| Rainer Weikusat... |
Posted: Fri Sep 25, 2009 5:36 am |
|
|
|
Guest
|
Josef Moellers <josef.moellers at (no spam) ts.fujitsu.com> writes:
Quote: Ryan McCoskrie wrote:
Dos-Man 64 wrote:
[...]
Quote: The reason that I said to look those up is because your dealing with
a different way of thinking about programming.
Embedding icons into executables is a cute idea but also kinda' silly
sounding. Why would you want that kind of a feature on a natively command
line operating system?
Things have advanced in the last 30 odd years.
On UNIX(*) and anything similar, both GUI- and CLI-interfaces have
advanced since 1979. What hasn't "advanced" or to no significant
degree is the sorry mess which was once 'the DOS CLI' and the poor
internal organization of Windows-systems, which basically still follow
the 'every application in its own directory'-tree mantra, dating back
to the ancient times when 'the sysadmin' was the person responsible for
compiling, installing and maintaining all software on a system
manually.
Quote: If the application is one that requires a GUI, it would make perfect
sense.
I don't think that it makes 'perfect sense' to complement a messy
desk with a messy desktop, both consisting of a random assortment of
rectangular things meant to be useful at some unspecified time in the
past, but actually just collection dust[*] 'just in case'.
[*] Assuming a compositing desktop, why not implement virtual
dust? Would make the thing more realistic, wouldn't it? |
|
|
| Back to top |
|
|
|
| Joe Beanfish... |
Posted: Fri Sep 25, 2009 10:36 am |
|
|
|
Guest
|
John Hasler wrote:
Quote: Dos-Man 64 writes:
The applications do have a default icon assigned to them anyway...
Not necessarily. I use a GUI but have no icons assigned to anything.
...so it makes sense for the programmer to have some say over what
icon is used, but with the end user having the final say and being
able to change it if they so desire.
The programmer can include a default icon in his package without putting
it in the executable. There is no reason to cram everything into one
file.
Many GUI apps already come with icons but they are located in random places
with random names with no way to associate the program to it's icon as far
as the desktop is concerned. Each program could include install code and
files to teach the various desktops how to associate but it would be simpler
if the icon was just in the executable. CLI programs could remain none
the wiser about icons as the icon section should be completely optional.
Granted it makes an issue of how the end user would use a different icon
when desired but at least it would provide a reasonable default. |
|
|
| Back to top |
|
|
|
| David Schwartz... |
Posted: Sat Sep 26, 2009 6:43 am |
|
|
|
Guest
|
On Sep 25, 4:11 am, John Hasler <jhas... at (no spam) newsguy.com> wrote:
Quote: The programmer can include a default icon in his package without putting
it in the executable. There is no reason to cram everything into one
file.
It seems like this creates some impossible requirements. Okay, so I
have my executable, but now you say I need a separate file for the
icon. Okay, but that's not convenient to ship. So I package it into a
single installer executable. Now, I need an icon for that installer
executable, and I'm back to having more than one file. So, again, I
need to package it.
Only a way to combine an icon with an executable avoids the need to
distribute more than one file.
DS |
|
|
| Back to top |
|
|
|
| John Hasler... |
Posted: Sat Sep 26, 2009 11:18 am |
|
|
|
Guest
|
I wrote:
Quote: The programmer can include a default icon in his package without putting
it in the executable. Â There is no reason to cram everything into one
file.
DS writes:
Quote: Okay, so I have my executable, but now you say I need a separate file
for the icon. Okay, but that's not convenient to ship. So I package it
into a single installer executable. Now, I need an icon for that
installer executable, and I'm back to having more than one file. So,
again, I need to package it.
You might want to read up on the concept of packages, package
management, and package managers. Build your .deb or .rpm correctly and
the package management system will put your icons where the desktop
environments can find them (and there is no need, of course, for an
installer).
Quote: Only a way to combine an icon with an executable avoids the need to
distribute more than one file.
A .deb or .rpm is a single file.
--
John Hasler
jhasler at (no spam) newsguy.com
Dancing Horse Hill
Elmwood, WI USA |
|
|
| Back to top |
|
|
|
| Lew Pitcher... |
Posted: Sat Sep 26, 2009 11:34 am |
|
|
|
Guest
|
On September 26, 2009 12:43, in comp.os.linux.development.apps, David
Schwartz (davids at (no spam) webmaster.com) wrote:
Quote: On Sep 25, 4:11Â am, John Hasler <jhas... at (no spam) newsguy.com> wrote:
The programmer can include a default icon in his package without putting
it in the executable. Â There is no reason to cram everything into one
file.
It seems like this creates some impossible requirements. Okay, so I
have my executable, but now you say I need a separate file for the
icon. Okay, but that's not convenient to ship. So I package it into a
single installer executable. Now, I need an icon for that installer
executable, and I'm back to having more than one file. So, again, I
need to package it.
Only a way to combine an icon with an executable avoids the need to
distribute more than one file.
Long ago, I made an attempt at learning how to write GUI programs with the
Xlib toolkit, and acquired Volume 1 of "Xlib Programming Manual" by Adrian
Nye. In Chapter 3, the author discusses the development of a basic X
application, and presents the associated source code. Part of the
discussion centred around preparing and presenting the icon.
There is no requirement that the icon be stored as a separate file from the
application code. Indeed, the example from the above book has the icon as
an integral part of the binary.
To the OP, the technique outlined in "Xlib Programming Manual" looked like
#define icon_bitmap_width 40
#define icon_bitmap_height 40
static unsigned char icon_bitmap_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x1f, 0xfe, 0xff,
0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0xff,
0x3f, 0xfe, 0xff, 0xff, 0xff, 0x3f, 0x1e, 0x00, 0x3e, 0x00, 0x3c, 0x1e,
0x00, 0x3e, 0x00, 0x3c, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x3e,
0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00,
0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x03, 0x3e, 0x60, 0x00, 0xe0, 0x1c,
0x3e, 0x9c, 0x03, 0x98, 0x67, 0x3e, 0xf3, 0x0c, 0xc4, 0x8f, 0xbe, 0xf8,
0x11, 0x98, 0x67, 0x3e, 0xf3, 0x0c, 0xe0, 0x1c, 0x3e, 0x9c, 0x03, 0x00,
0x03, 0x3e, 0x60, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x3e,
0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00,
0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00,
0x3e, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00,
0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00,
0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x3e,
0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00,
0x00, 0x00, 0x3e, 0x00, 0x00, 0xf8, 0x00, 0x7f, 0x00, 0x1f, 0x20, 0x00,
0x7f, 0x00, 0x04, 0x40, 0x00, 0x00, 0x00, 0x02};
...
Display *display;
Window win;
Pixmap icon_pixmap;
char *window_name = "Basic Window Program";
char *icon_name = "basicwin";
XSizeHints *size_hints;
XWMHints *wm_hints;
XClassHint *class_hints;
...
if (!(wm_hints = XAllocWMHints()))
ErrorAbort("failure allocating memory (XAllocWMHints)",NULL);
...
/* Create pixmap of depth 1 (bitmap) for icon */
icon_pixmap = XCreateBitmapFromData(display, win,
icon_bitmap_bits,
icon_bitmap_width,
icon_bitmap_height);
...
wm_hints->icon_pixmap = icon_pixmap;
wm_hints->flags = StateHint | IconPixmapHint | InputHint;
...
XSetWMProperties(display, win,
&windowName,
&iconName,
argv, argc,
size_hints, wm_hints, class_hints);
Perhaps there are parallel methods in the toolkit you used to build your C++
program.
--
Lew Pitcher
Master Codewright & JOAT-in-training | Registered Linux User #112576
http://pitcher.digitalfreehold.ca/ | GPG public key available by request
---------- Slackware - Because I know what I'm doing. ------ |
|
|
| Back to top |
|
|
|
| Joe Beanfish... |
Posted: Mon Sep 28, 2009 11:00 am |
|
|
|
Guest
|
Lew Pitcher wrote:
Quote: On September 26, 2009 12:43, in comp.os.linux.development.apps, David
Schwartz (davids at (no spam) webmaster.com) wrote:
On Sep 25, 4:11 am, John Hasler <jhas... at (no spam) newsguy.com> wrote:
The programmer can include a default icon in his package without putting
it in the executable. There is no reason to cram everything into one
file.
It seems like this creates some impossible requirements. Okay, so I
have my executable, but now you say I need a separate file for the
icon. Okay, but that's not convenient to ship. So I package it into a
single installer executable. Now, I need an icon for that installer
executable, and I'm back to having more than one file. So, again, I
need to package it.
Only a way to combine an icon with an executable avoids the need to
distribute more than one file.
Long ago, I made an attempt at learning how to write GUI programs with the
Xlib toolkit, and acquired Volume 1 of "Xlib Programming Manual" by Adrian
Nye. In Chapter 3, the author discusses the development of a basic X
application, and presents the associated source code. Part of the
discussion centred around preparing and presenting the icon.
There is no requirement that the icon be stored as a separate file from the
application code. Indeed, the example from the above book has the icon as
an integral part of the binary.
To the OP, the technique outlined in "Xlib Programming Manual" looked like
#define icon_bitmap_width 40
#define icon_bitmap_height 40
static unsigned char icon_bitmap_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x1f, 0xfe, 0xff,
0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0xff,
0x3f, 0xfe, 0xff, 0xff, 0xff, 0x3f, 0x1e, 0x00, 0x3e, 0x00, 0x3c, 0x1e,
0x00, 0x3e, 0x00, 0x3c, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x3e,
0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00,
0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x03, 0x3e, 0x60, 0x00, 0xe0, 0x1c,
0x3e, 0x9c, 0x03, 0x98, 0x67, 0x3e, 0xf3, 0x0c, 0xc4, 0x8f, 0xbe, 0xf8,
0x11, 0x98, 0x67, 0x3e, 0xf3, 0x0c, 0xe0, 0x1c, 0x3e, 0x9c, 0x03, 0x00,
0x03, 0x3e, 0x60, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x3e,
0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00,
0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00,
0x3e, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00,
0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00,
0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x3e,
0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00,
0x00, 0x00, 0x3e, 0x00, 0x00, 0xf8, 0x00, 0x7f, 0x00, 0x1f, 0x20, 0x00,
0x7f, 0x00, 0x04, 0x40, 0x00, 0x00, 0x00, 0x02};
...
Display *display;
Window win;
Pixmap icon_pixmap;
char *window_name = "Basic Window Program";
char *icon_name = "basicwin";
XSizeHints *size_hints;
XWMHints *wm_hints;
XClassHint *class_hints;
...
if (!(wm_hints = XAllocWMHints()))
ErrorAbort("failure allocating memory (XAllocWMHints)",NULL);
...
/* Create pixmap of depth 1 (bitmap) for icon */
icon_pixmap = XCreateBitmapFromData(display, win,
icon_bitmap_bits,
icon_bitmap_width,
icon_bitmap_height);
...
wm_hints->icon_pixmap = icon_pixmap;
wm_hints->flags = StateHint | IconPixmapHint | InputHint;
...
XSetWMProperties(display, win,
&windowName,
&iconName,
argv, argc,
size_hints, wm_hints, class_hints);
Perhaps there are parallel methods in the toolkit you used to build your C++
program.
That works ok for displaying your icon while running but there's still no
way for a 3rd party like a file manager to get the icon. |
|
|
| Back to top |
|
|
|
| Dos-Man 64... |
Posted: Mon Sep 28, 2009 12:14 pm |
|
|
|
Guest
|
On Sep 28, 2:08 pm, markhob... at (no spam) hotpop.donottypethisbit.com (Mark
Hobley) wrote:
Quote: Dos-Man 64 <ChairS... at (no spam) mail.com> wrote:
My understanding is that the icon is inside the windows binary.
Yes. That is true for Microsoft Windows, but not for Linux. On some versions
of Microsoft Windows, there is an object packaging tool that allows you
to change the embedded icon.
This is not the case in Linux. The icon is a separate entity, and is not
embedded, so you can associate any icon you like with the program,
providing that the window manager supports such a feature.
Mark.
--
Mark Hobley
Linux User: #370818 http://markhobley.yi.org/
I would think/hope that there would be a utility which would allow you
to change the embedded icon, relieving you from ever having to worry
about it again. I'm actually not aware of any windows utilities that
do this, but that doesn't mean that there aren't any. |
|
|
| Back to top |
|
|
|
| John Hasler... |
Posted: Mon Sep 28, 2009 12:23 pm |
|
|
|
Guest
|
Joe Beanfish writes:
Quote: That works ok for displaying your icon while running but there's still
no way for a 3rd party like a file manager to get the icon.
Of course there is. It looks in /usr/share/pixmaps where the package
manager put the icon file that shipped as part of the package (but not
part of the executable).
--
John Hasler
jhasler at (no spam) newsguy.com
Dancing Horse Hill
Elmwood, WI USA |
|
|
| Back to top |
|
|
|
| Mark Hobley... |
Posted: Mon Sep 28, 2009 1:08 pm |
|
|
|
Guest
|
Dos-Man 64 <ChairShot at (no spam) mail.com> wrote:
Quote: My understanding is that the icon is inside the windows binary.
Yes. That is true for Microsoft Windows, but not for Linux. On some versions
of Microsoft Windows, there is an object packaging tool that allows you
to change the embedded icon.
This is not the case in Linux. The icon is a separate entity, and is not
embedded, so you can associate any icon you like with the program,
providing that the window manager supports such a feature.
Mark.
--
Mark Hobley
Linux User: #370818 http://markhobley.yi.org/ |
|
|
| Back to top |
|
|
|
| Lew Pitcher... |
Posted: Mon Sep 28, 2009 1:32 pm |
|
|
|
Guest
|
On September 28, 2009 15:08, in comp.os.linux.development.apps, Mark Hobley
(markhobley at (no spam) hotpop.donottypethisbit.com) wrote:
Quote: Dos-Man 64 <ChairShot at (no spam) mail.com> wrote:
My understanding is that the icon is inside the windows binary.
Yes. That is true for Microsoft Windows, but not for Linux. On some
versions of Microsoft Windows, there is an object packaging tool that
allows you to change the embedded icon.
This is not the case in Linux. The icon is a separate entity, and is not
embedded, so you can associate any icon you like with the program,
providing that the window manager supports such a feature.
I hate to tell you, but in X (the typical GUI environment on Linux), the
icon /may/ be a separate entity, or it /may/ be embedded within the
program.
--
Lew Pitcher
Master Codewright & JOAT-in-training | Registered Linux User #112576
http://pitcher.digitalfreehold.ca/ | GPG public key available by request
---------- Slackware - Because I know what I'm doing. ------ |
|
|
| Back to top |
|
|
|
|
|
All times are GMT - 5 Hours
The time now is Sun Nov 29, 2009 9:53 pm
|
|