/* routine to load an image from the passed-in path
 */
GdkPixbuf *
nautilus_thumbnail_load_image (const char *path,
			       guint base_size,
			       guint nominal_size,
			       gboolean force_nominal,
			       double *scale_x_out,
			       double *scale_y_out)
{
	GdkPixbuf *pixbuf;
	guchar *buffer;
	gsize buflen;
	GError *error;

	error = NULL;
	
	if (!g_file_get_contents (path, (gchar **) &buffer, &buflen, &error)) {
		g_message ("Failed to load %s into memory: %s", path, error->message);

		g_error_free (error);

		return NULL;
	}

	pixbuf = get_pixbuf_from_data (buffer, buflen, path,
				       base_size, nominal_size, force_nominal,
				       scale_x_out, scale_y_out);

	g_free (buffer);

	return pixbuf;
}
示例#2
0
void set_image()
{	
  GdkPixbuf * fdata = get_pixbuf_from_data(mdata[current_buffer], 1);
  g_object_unref(dimage);
  dimage = fdata;
  gtk_image_set_from_pixbuf(GTK_IMAGE(image), fdata);

  update_sidepanel();
}
static void
async_thumbnail_read_image (GObject *source_object,
			    GAsyncResult *res,
			    gpointer callback_data)
{
	NautilusThumbnailAsyncLoadHandle *handle = callback_data;
	GdkPixbuf *pixbuf;
	double scale_x, scale_y;
	gsize file_size;
	char *file_contents;

	pixbuf = NULL;
	scale_x = scale_y = 1.0;

	if (g_file_load_contents_finish (G_FILE (source_object),
					 res,
					 &file_contents, &file_size,
					 NULL, NULL)) {
		pixbuf = get_pixbuf_from_data (file_contents, file_size,
					       handle->file_path,
					       handle->base_size,
					       handle->nominal_size,
					       handle->force_nominal,
					       &scale_x, &scale_y);
		g_free (file_contents);
	}

	handle->load_func (handle,
			   handle->file_path,
			   pixbuf, scale_x, scale_y,
			   handle->load_func_user_data);

	gdk_pixbuf_unref (pixbuf);

	g_object_unref (handle->cancellable);
	g_free (handle->file_path);
	g_free (handle);
}
示例#4
0
void update_sidepanel()
{
  int i;
  for(i = 0; i < BUFFER_COUNT; i++)
    {
      if(icons[i] != NULL)
	{
	  gtk_widget_hide(icons[i]);
	  gtk_widget_destroy(icons[i]);
	  gtk_widget_hide(icon_event_boxes[i]);
	  gtk_widget_destroy(icon_event_boxes[i]);
	  icons[i] = NULL;
	  icon_event_boxes[i] = NULL;
	}
    }

  for(i = 0; i < BUFFER_COUNT; i++)
    {
      if(mdata[i] != NULL)
	{
	  if(i == current_buffer)
	    {
	      GdkColor color;

	      gdk_color_parse("red", &color);

	      if(selected_buffer_frame != NULL)
		gtk_widget_destroy(selected_buffer_frame);
	      selected_buffer_frame = gtk_frame_new(NULL);
	      gtk_widget_modify_bg(selected_buffer_frame, GTK_STATE_NORMAL, &color);
	      gtk_box_pack_start(GTK_BOX(list_vbox), selected_buffer_frame, FALSE, TRUE, 1);

	      icons[i] = gtk_image_new();
	      icon_event_boxes[i] = gtk_event_box_new();

	      gtk_image_set_from_pixbuf(GTK_IMAGE(icons[i]), get_pixbuf_from_data(mdata[i], 0));

	      gtk_container_add(GTK_CONTAINER(selected_buffer_frame), icon_event_boxes[i]);
	      gtk_container_add(GTK_CONTAINER(icon_event_boxes[i]), icons[i]);

	      gtk_widget_show(icons[i]);
	      gtk_widget_show(icon_event_boxes[i]);
	      gtk_widget_show(selected_buffer_frame);

	      g_signal_connect(G_OBJECT(icon_event_boxes[i]), "button_press_event", G_CALLBACK(buffer_callback), (gpointer *)(size_t)i);
	    }
	  else
	    {
	      icons[i] = gtk_image_new();
	      icon_event_boxes[i] = gtk_event_box_new();

	      gtk_image_set_from_pixbuf(GTK_IMAGE(icons[i]), get_pixbuf_from_data(mdata[i], 0));

	      gtk_box_pack_start(GTK_BOX(list_vbox), icon_event_boxes[i], FALSE, TRUE, 2);
	      gtk_container_add(GTK_CONTAINER(icon_event_boxes[i]), icons[i]);

	      gtk_widget_show(icons[i]);
	      gtk_widget_show(icon_event_boxes[i]);

	      g_signal_connect(G_OBJECT(icon_event_boxes[i]), "button_press_event", G_CALLBACK(buffer_callback), (gpointer *)(size_t)i);
	    }
	}
    }
}