diff options
author | Pierre Ossman <ossman@cendio.se> | 2012-03-27 12:50:54 +0000 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2012-03-27 12:50:54 +0000 |
commit | 8eb3508b7365aefddf98671b1a962366d480b237 (patch) | |
tree | b9737a1e6b7db3cdc826592314d4382748af9c2e /vncviewer/vncviewer.cxx | |
parent | 64127708e070f248f4db1ed57375de25c0ce0ce4 (diff) | |
download | tigervnc-8eb3508b7365aefddf98671b1a962366d480b237.tar.gz tigervnc-8eb3508b7365aefddf98671b1a962366d480b237.zip |
Set a proper icon for the vncviewer windows on Unix and Windows.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4878 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'vncviewer/vncviewer.cxx')
-rw-r--r-- | vncviewer/vncviewer.cxx | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/vncviewer/vncviewer.cxx b/vncviewer/vncviewer.cxx index 5fe7fe08..1f6fca56 100644 --- a/vncviewer/vncviewer.cxx +++ b/vncviewer/vncviewer.cxx @@ -48,6 +48,7 @@ #include <FL/Fl.H> #include <FL/Fl_Widget.H> +#include <FL/Fl_PNG_Image.H> #include <FL/fl_ask.H> #include <FL/x.H> @@ -58,6 +59,7 @@ #include "UserDialog.h" #ifdef WIN32 +#include "resource.h" #include "win32.h" #endif @@ -121,6 +123,69 @@ static void init_fltk() // WM_CLASS for the window. Fl_Window::default_xclass("vncviewer"); + // Set the default icon for all windows. +#ifdef HAVE_FLTK_ICONS +#ifdef WIN32 + HICON lg, sm; + + lg = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON), + IMAGE_ICON, GetSystemMetrics(SM_CXICON), + GetSystemMetrics(SM_CYICON), + LR_DEFAULTCOLOR | LR_SHARED); + sm = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON), + IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), + GetSystemMetrics(SM_CYSMICON), + LR_DEFAULTCOLOR | LR_SHARED); + + Fl_Window::default_icons(lg, sm); +#elif ! defined(__APPLE__) + const int icon_sizes[] = {48, 32, 24, 16}; + + Fl_PNG_Image *icons[4]; + int count; + + count = 0; + + // FIXME: Follow icon theme specification + for (size_t i = 0;i < sizeof(icon_sizes)/sizeof(icon_sizes[0]);i++) { + char icon_path[PATH_MAX]; + bool exists; + + sprintf(icon_path, "%s/icons/hicolor/%dx%d/tigervnc.png", + DATA_DIR, icon_sizes[i], icon_sizes[i]); + +#ifndef WIN32 + struct stat st; + if (stat(icon_path, &st) != 0) +#else + struct _stat st; + if (_stat(icon_path, &st) != 0) + return(false); +#endif + exists = false; + else + exists = true; + + if (exists) { + icons[count] = new Fl_PNG_Image(icon_path); + if (icons[count]->w() == 0 || + icons[count]->h() == 0 || + icons[count]->d() != 4) { + delete icons[count]; + continue; + } + + count++; + } + } + + Fl_Window::default_icons((const Fl_RGB_Image**)icons, count); + + for (int i = 0;i < count;i++) + delete icons[i]; +#endif +#endif // FLTK_HAVE_ICONS + // This makes the "icon" in dialogs rounded, which fits better // with the above schemes. fl_message_icon()->box(FL_UP_BOX); |