Re: Does gnumeric have an icon?



On  4 Feb, James Henstridge scribbled:
->  The code I use to set the icon is a little different.  You only have to
->  give the window argument to gdk_window_set_icon if you want to have more
->  control over the icon than just a static pixmap.  Also, I don't think you
->  are supposed to specify the background colour to
->  gdk_pixmap_create_from_xpm_d if you want a transparent icon.
->  
->  The code I use in gnorpm is this:
->  
->  void set_icon(GtkWidget *w) {
->    GdkWindow *win;
->    GdkPixmap *icon;
->    GdkBitmap *mask;
->  
->    gtk_widget_realize(w);
->    win = w->window;
->    if (!win) return;
->  
->    icon = gdk_pixmap_create_from_xpm_d(win, &mask, NULL, rpm_icon);
->    gdk_window_set_icon(win, NULL, icon, mask);
->  }
->  
->  And yes, this works fine with fvwm2 :)

anfd goes comepletely against ICCCM - its bad programs like this that
make WM's have to pick up the pieces fro borken apps that dont obey the
standards set out by X.

please read them and you'll find you are NOT allowed to have icon
pixmaps of depth other than 1 bit. higher bit-depths are not allowed -
netscape disobeys this and is NOt an example to follow. I suggest if
you want color icons look at Electic Eyes or Balsa - they use icon
windows - these the app is free to create in any bit depth and fill
with whatever data the app so pleases to fill it with. Please also obey
ICCCM and do NOt create icons in sizes other than those specified by the
IconSizes hint. This below is MUCH more correct code.

  GtkWidget *w;
  GdkWindow *ic_win;
  GdkWindowAttr att;
  XIconSize *is;
  int i, count, j;
  GdkPixmap *pmap, *mask;

  /* create out toplevel window widget */
  w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_wmclass(GTK_WINDOW(w), "ee", "Image Viewer");
  gtk_window_set_title(GTK_WINDOW(w), _("Electric Eyes"));
  /* snip */
  gtk_widget_realize(w);

  /* Guess what - UNLIKE every app out there, we are going to read the icon */
  /* size hints and follow them AND follow ICCM by providing an icon window */
  /* not a color pixmap sicne technically we're only allowed to provide */
  /* mono pixmaps - not color ones */
  if ((XGetIconSizes(GDK_DISPLAY(), GDK_ROOT_WINDOW(), &is, &count)) &&
      (count > 0))
    {
      i = 0; /* use first icon size - not much point using the others */
      att.width = is[i].max_width;
      att.height = 3 * att.width / 4;
      if (att.height < is[i].min_height)
        att.height = is[i].min_height;
      if (att.height > is[i].max_height)
        att.height = is[i].max_height;
      if (is[i].width_inc > 0)
        {
          j = ((att.width - is[i].min_width) / is[i].width_inc);
          att.width = is[i].min_width +(j * is[i].width_inc);
        }
      if (is[i].height_inc > 0)
        {
          j = ((att.height - is[i].min_height) / is[i].height_inc);
          att.height = is[i].min_height +(j * is[i].height_inc);
        }
      XFree(is);
    }
  else /* no icon size hints at all? ok - invent our own size */
    {
      att.width = 32;
      att.height = 24;
    }
  att.wclass = GDK_INPUT_OUTPUT;
  att.window_type = GDK_WINDOW_TOPLEVEL;
  att.x = 0;
  att.y = 0;
  att.visual = gdk_imlib_get_visual();
  att.colormap = gdk_imlib_get_colormap();
  ic_win = gdk_window_new(NULL, &att, GDK_WA_VISUAL | GDK_WA_COLORMAP);
  if (!default_img)
    default_img = gdk_imlib_create_image_from_xpm_data(stdimg_xpm);
  gdk_window_set_icon(w->window, ic_win, NULL, NULL);
  gdk_imlib_render(default_img, att.width, att.height);
  pmap = gdk_imlib_move_image(default_img);
  mask = gdk_imlib_move_mask(default_img);
  gdk_window_set_back_pixmap(ic_win, pmap, FALSE);
  gdk_window_clear(ic_win);
  gdk_window_shape_combine_mask(ic_win, mask, 0, 0);
  gdk_imlib_free_pixmap(pmap);


->  
->  James Henstridge.
->  
->  --
->  Email: james@daa.com.au
->  WWW:   http://www.daa.com.au/~james/
->  
->  
->  On Wed, 3 Feb 1999, Miguel de Icaza wrote:
->  
->  > 
->  > > Here is how I do it, copied from a tutorial or doc somewhere:
->  > 
->  > Well, I will have to trust the sample code as at least with fvwm2 it
->  > did not work.
->  > 
->  > Miguel.
->  > 
->  > 
->  > -- 
->  >         FAQ: Frequently-Asked Questions at http://www.gnome.org/gnomefaq
->  >          To unsubscribe: mail gnome-list-request@gnome.org with 
->  >                        "unsubscribe" as the Subject.
->  > 
->  
->  

-- 
--------------- Codito, ergo sum - "I code, therefore I am" --------------------
raster@rasterman.com       /\___ /\ ___/||\___ ____/|/\___  raster@redhat.com
Carsten Haitzler           | _ //__\\ __||_ __\\ ___|| _ /  Red Hat Advanced
218/21 Conner Drive        || // __ \\_ \ | |   \ _/_|| /   Development Labs
Chapel Hill NC 27514 USA   ||\\\/  \//__/ |_|   /___/||\\   919 547 0012 ext 282
+1 (919) 929 9443, 801 4392   For pure Enlightenment   http://www.rasterman.com/

              \|/ ____ \|/  For those of you unaware. This face here is in fact
	      "@'/ ,. \@"   a Linux Kernel Error Message.
	      /_| \__/ |_\
		 \__U_/
							   



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