home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / evbl0627.zip / everblue_20010627.zip / x11 / Xlib_GetIconName.c < prev    next >
C/C++ Source or Header  |  2000-06-15  |  3KB  |  83 lines

  1. #include "Xlib.h"
  2. #include "Xlib_private.h" 
  3.  
  4. /*
  5.  
  6. Copyright 1986, 1998  The Open Group
  7.  
  8. All Rights Reserved.
  9.  
  10. The above copyright notice and this permission notice shall be included in
  11. all copies or substantial portions of the Software.
  12.  
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
  16. OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  17. AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  18. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  19.  
  20. Except as contained in this notice, the name of The Open Group shall not be
  21. used in advertising or otherwise to promote the sale, use or other dealings
  22. in this Software without prior written authorization from The Open Group.
  23.  
  24. */
  25.  
  26.  
  27.  
  28. /*
  29.  * Arguments
  30.  * 
  31.  *  display            Specifies the connection to the X server. 
  32.  *  w                  Specifies the window. 
  33.  *  icon_name_return   Returns the window's icon name, which is a null-terminated string. 
  34.  * 
  35.  * 
  36.  * Description
  37.  * 
  38.  * The XGetIconName() function returns the name to be displayed in the specified window's icon. If it succeeds, it returns a
  39.  * nonzero status; otherwise, if no icon name has been set for the window, it returns zero. If you never assigned a name to the
  40.  * window, XGetIconName() sets icon_name_return to NULL. If the data returned by the server is in the Latin Portable Character
  41.  * Encoding, then the returned string is in the Host Portable Character Encoding. Otherwise, the result is implementation
  42.  * dependent. When finished with it, a client must free the icon name string using XFree(). 
  43.  * 
  44.  * XGetIconName() can generate a BadWindow error. 
  45.  * 
  46.  * 
  47.  * Diagnostics
  48.  * 
  49.  *  BadWindow        A value for a Window argument does not name a defined Window. 
  50.  * 
  51.  */
  52.  
  53.  
  54. Status XGetIconName (register Display *dpy, Window w, char **icon_name)
  55. {
  56.     Atom actual_type;
  57.     int actual_format;
  58.     unsigned long nitems;
  59.     unsigned long leftover;
  60.     unsigned char *data = NULL;
  61.  
  62.     DBUG_ENTER("XGetIconName");
  63.     if (XGetWindowProperty(dpy, w, XA_WM_ICON_NAME, 0L, (long)BUFSIZ, False,
  64.         XA_STRING, 
  65.     &actual_type,
  66.     &actual_format, &nitems, &leftover, &data) != Success) {
  67.         *icon_name = NULL;
  68.     DBUG_RETURN(0);
  69.     }
  70.     if ( (actual_type == XA_STRING) &&  (actual_format == 8) ) {
  71.  
  72.     /* The data returned by XGetWindowProperty is guarranteed to
  73.     contain one extra byte that is null terminated to make retrieveing
  74.     string properties easy. */
  75.  
  76.     *icon_name = (char*)data;
  77.     DBUG_RETURN(1);
  78.     }
  79.     if (data) Xfree ((char *)data);
  80.     *icon_name = NULL;
  81.     DBUG_RETURN(0);
  82. }
  83.