Exemplo n.º 1
0
/* This is an internally used function to create pixmaps. */
GtkWidget*
create_pixmap                          (GtkWidget       *widget,
                                        const gchar     *filename)
{
  gchar *found_filename = NULL;
  GdkColormap *colormap;
  GdkPixmap *gdkpixmap;
  GdkBitmap *mask;
  GtkWidget *pixmap;
  GList *elem;

  if (!filename || !filename[0])
      return create_dummy_pixmap (widget);

  /* We first try any pixmaps directories set by the application. */
  elem = pixmaps_directories;
  while (elem)
    {
      found_filename = check_file_exists ((gchar*)elem->data, filename);
      if (found_filename)
        break;
      elem = elem->next;
    }

  /* If we haven't found the pixmap, try the source directory. */
  if (!found_filename)
    {
      found_filename = check_file_exists ("../pixmaps", filename);
    }

  if (!found_filename)
    {
      g_warning (_("Couldn't find pixmap file: %s"), filename);
      return create_dummy_pixmap (widget);
    }

  colormap = gtk_widget_get_colormap (widget);
  gdkpixmap = gdk_pixmap_colormap_create_from_xpm (NULL, colormap, &mask,
                                                   NULL, found_filename);
  if (gdkpixmap == NULL)
    {
      g_warning (_("Error loading pixmap file: %s"), found_filename);
      g_free (found_filename);
      return create_dummy_pixmap (widget);
    }
  g_free (found_filename);
  pixmap = gtk_pixmap_new (gdkpixmap, mask);
  gdk_pixmap_unref (gdkpixmap);
  gdk_bitmap_unref (mask);
  return pixmap;
}
Exemplo n.º 2
0
Arquivo: support.c Projeto: erikg/GEMS
/*
 * This is an internally used function to create pixmaps. 
 */
GtkWidget *
create_pixmap (GtkWidget * widget,
	       const gchar * filename, gboolean gnome_pixmap)
{
    GtkWidget *pixmap;
    GdkColormap *colormap;
    GdkPixmap *gdkpixmap;
    GdkBitmap *mask;
    gchar *pathname;

    if (!filename || !filename[0])
	return create_dummy_pixmap (widget, gnome_pixmap);

    pathname = gnome_pixmap_file (filename);
    if (!pathname)
    {
	g_warning (_("Couldn't find pixmap file: %s"), filename);
	return create_dummy_pixmap (widget, gnome_pixmap);
    }
    if (gnome_pixmap)
    {
	pixmap = gnome_pixmap_new_from_file (pathname);
	g_free (pathname);
	return pixmap;
    }
    colormap = gtk_widget_get_colormap (widget);
    gdkpixmap = gdk_pixmap_colormap_create_from_xpm (NULL, colormap, &mask,
						     NULL, pathname);
    if (gdkpixmap == NULL)
    {
	g_warning (_("Couldn't create pixmap from file: %s"), pathname);
	g_free (pathname);
	return create_dummy_pixmap (widget, gnome_pixmap);
    }
    g_free (pathname);

    pixmap = gtk_pixmap_new (gdkpixmap, mask);
    gdk_pixmap_unref (gdkpixmap);
    gdk_bitmap_unref (mask);
    return pixmap;
}