Setting WM icon?



Hi, I've been trying to set the WM icon for my GTK+ apps for quite 
some time now and I still can't seem to get it to work. 

Most of the time (IceWM) displays as just the generic `X' icon.
Attached below is the function that I have to set the icon. Note the icon
data I used is a #included 48x48 xpm file.

--
Sincerely,                  ,"-_                         \|/
-Capt. Taura M.             ,   O=__                    --X--
..__                         ,_JNMNNEO=_                 /|\
OMNOUMmnne.                  {OMMNNNEEEEOO=_
UOOOBIOOOEOMMn.               'LONMMMMNNEEEOOO=.__..,,..
UUOOEUUOOOOOOOObe              '"=OMMMMWNEEEOOOOO,"=OEEEOO=,._
OOUUUIEEIOONNOIUbe.                "7OMMMMNNNNNWWEEEEOOOOOO"   "'.
EEBNNMMMNWNWWEEIMMNe.             __  7EMMMNNNNNWWWEEEEEEEOO.     " .
NNMMMMWWWMMMWEINMMMNn            "=BBEEEEMMMMMMMMNNNWWWEEOOOOO=._     .
                  http://furry.ao.net/~learfox/

void GUISetWMIcon(GdkWindow *w, u_int8_t **icon)
{
        gint width, height;
        GdkWindow *icon_window, *parent;
        GdkPixmap *pixmap;
        GdkBitmap *mask;
        GtkStyle *style;
        
        gint attr_flags;
        GdkWindowAttr attr;


        /* Create pixmap from icon data. */
        style = gtk_widget_get_default_style();
        if(style == NULL)
            return;
        pixmap = gdk_pixmap_create_from_xpm_d(
            w,
            &mask,
            &style->bg[GTK_STATE_NORMAL],
            (gchar **)icon
        );
        /* Get size of newly created pixmap as the size to use
         * throughout.
         */
        gdk_window_get_size((GdkWindow *)pixmap, &width, &height);

        /* Get parent of the window (usually the root window). */
        parent = gdk_window_get_parent(w);
        if(parent == NULL)
            return;

        /* Create window to hold the WM icon. */
        attr_flags = GDK_WA_WMCLASS | GDK_WA_NOREDIR;
        attr.width = width;
        attr.height = height;
        attr.wclass = GDK_INPUT_OUTPUT; 
        attr.window_type = GDK_WINDOW_TOPLEVEL;
        attr.wmclass_name = "Eterm";
        attr.wmclass_class = "Eterm";
        attr.override_redirect = FALSE;
        icon_window = gdk_window_new(parent, &attr, attr_flags);
        if(icon_window == NULL)
            return;

        /* Set icon. */
        gdk_window_set_icon(w, icon_window, pixmap, mask);
        gdk_pixmap_unref(pixmap);
        gdk_bitmap_unref(mask);
        gdk_window_unref(icon_window);

        return;
}





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]