Esempio n. 1
0
/* This is an internally used function to create pixmaps. */
GdkPixbuf*
create_pixbuf                          (const gchar     *filename)
{
  gchar *pathname = NULL;
  GdkPixbuf *pixbuf;
  GError *error = NULL;

  if (!filename || !filename[0])
      return NULL;

  pathname = find_pixmap_file (filename);

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

  pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
  if (!pixbuf)
    {
      fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
               pathname, error->message);
      g_error_free (error);
    }
  g_free (pathname);
  return pixbuf;
}
Esempio n. 2
0
/* This is an internally used function to create pixmaps. */
GtkWidget *create_pixmap(GtkWidget * widget, const gchar * filename)
{
	gchar *pathname = NULL;
	GtkWidget *pixmap;
	if (!filename || !filename[0])
		return gtk_image_new();
	pathname = find_pixmap_file(filename);
	if (!pathname) {
		g_warning(_("Couldn't find pixmap file: %s"), filename);
		return gtk_image_new();
	}
	pixmap = gtk_image_new_from_file(pathname);
	g_free(pathname);
	return pixmap;
}
Esempio n. 3
0
void add_stock_icon (const gchar *filename, const gchar *stock_id)
  {
  GtkIconSource *icon_source = NULL ;
  GtkIconSet *icon_set = NULL ;
  static GtkIconFactory *icon_factory = NULL ;
  char *psz = NULL ;

  if (NULL == icon_factory)
    gtk_icon_factory_add_default (icon_factory = gtk_icon_factory_new ()) ;

  if (NULL != (icon_source = gtk_icon_source_new ()))
    {
    gtk_icon_source_set_filename (icon_source, psz = find_pixmap_file (filename)) ;
    if (NULL == (icon_set = gtk_icon_factory_lookup (icon_factory, stock_id)))
      {
      icon_set = gtk_icon_set_new () ;
      gtk_icon_factory_add (icon_factory, stock_id, icon_set) ;
      }
    gtk_icon_set_add_source (icon_set, icon_source) ;
    }
  }
Esempio n. 4
0
// This is an internally used function to create pixmaps.
GtkWidget *create_pixmap (GtkWidget *widget, const gchar *filename)
  {
  gchar *pathname = NULL;
  GtkWidget *pixmap;

  if (!filename || !filename[0])
    return gtk_image_new ();

  pathname = find_pixmap_file (filename);

  DBG_SUP (fprintf (stderr, "Found '%s' here: '%s'\n", filename, pathname)) ;

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

  pixmap = gtk_image_new_from_file (pathname);
  g_free (pathname);
  return pixmap;
  }