Beispiel #1
0
static void collection_load_thumb_step(CollectionData *cd)
{
	GList *work;
	CollectInfo *ci;

	if (!cd->list)
		{
		collection_load_stop(cd);
		return;
		}

	work = cd->list;
	ci = work->data;
	work = work->next;
	/* find first unloaded thumb */
	while (work && ci->pixbuf)
		{
		ci = work->data;
		work = work->next;
		}

	if (!ci || ci->pixbuf)
		{
		/* done */
		collection_load_stop(cd);

		/* send a NULL CollectInfo to notify end */
		if (cd->info_updated_func) cd->info_updated_func(cd, NULL, cd->info_updated_data);

		return;
		}

	/* setup loader and call it */
	cd->thumb_info = ci;
	thumb_loader_free(cd->thumb_loader);
	cd->thumb_loader = thumb_loader_new(thumb_max_width, thumb_max_height);
	thumb_loader_set_callbacks(cd->thumb_loader,
				   collection_load_thumb_done_cb,
				   collection_load_thumb_error_cb,
				   NULL,
				   cd);

	/* start it */
	if (!thumb_loader_start(cd->thumb_loader, ci->path))
		{
		/* error, handle it, do next */
		if (debug) printf("error loading thumb for %s\n", ci->path);
		collection_load_thumb_do(cd);
		collection_load_thumb_step(cd);
		}
}
Beispiel #2
0
static void
gth_file_list_update_current_thumb (GthFileList *file_list)
{
	if (file_list->priv->stop_it || (file_list->priv->queue != NULL)) {
		g_idle_add (update_thumbs_stopped, file_list);
		return;
	}

	g_return_if_fail (file_list->priv->thumb_fd != NULL);

	file_list->priv->loading_thumbs = TRUE;
	thumb_loader_set_file (file_list->priv->thumb_loader, file_list->priv->thumb_fd);
	thumb_loader_start (file_list->priv->thumb_loader);
}
Beispiel #3
0
static gboolean cache_manager_render_file(CleanData *cd)
{
	if (cd->list)
		{
		FileData *fd;
		gint success;

		fd = cd->list->data;
		cd->list = g_list_remove(cd->list, fd);

		cd->tl = (ThumbLoaderStd *)thumb_loader_new(options->thumbnails.max_width, options->thumbnails.max_height);
		thumb_loader_set_callbacks((ThumbLoader *)cd->tl,
					   cache_manager_render_thumb_done_cb,
					   cache_manager_render_thumb_done_cb,
					   NULL, cd);
		thumb_loader_set_cache((ThumbLoader *)cd->tl, TRUE, cd->local, TRUE);
		success = thumb_loader_start((ThumbLoader *)cd->tl, fd);
		if (success)
			{
			gtk_entry_set_text(GTK_ENTRY(cd->progress), fd->path);
			}
		else
			{
			thumb_loader_free((ThumbLoader *)cd->tl);
			cd->tl = NULL;
			}

		file_data_unref(fd);

		return (!success);
		}
	else if (cd->list_dir)
		{
		FileData *fd;

		fd = cd->list_dir->data;
		cd->list_dir = g_list_remove(cd->list_dir, fd);

		cache_manager_render_folder(cd, fd);

		file_data_unref(fd);

		return TRUE;
		}

	cache_manager_render_finish(cd);

	return FALSE;
}
Beispiel #4
0
static gboolean vf_thumb_next(ViewFile *vf)
{
	FileData *fd = NULL;

#if GTK_CHECK_VERSION(2,20,0)
	if (!gtk_widget_get_realized(vf->listview))
#else
	if (!GTK_WIDGET_REALIZED(vf->listview))
#endif
		{
		vf_thumb_status(vf, 0.0, NULL);
		return FALSE;
		}

	switch (vf->type)
	{
	case FILEVIEW_LIST: fd = vflist_thumb_next_fd(vf); break;
	case FILEVIEW_ICON: fd = vficon_thumb_next_fd(vf); break;
	}

	if (!fd)
		{
		/* done */
		vf_thumb_cleanup(vf);
		return FALSE;
		}

	vf->thumbs_filedata = fd;

	thumb_loader_free(vf->thumbs_loader);

	vf->thumbs_loader = thumb_loader_new(options->thumbnails.max_width, options->thumbnails.max_height);
	thumb_loader_set_callbacks(vf->thumbs_loader,
				   vf_thumb_done_cb,
				   vf_thumb_error_cb,
				   NULL,
				   vf);

	if (!thumb_loader_start(vf->thumbs_loader, fd))
		{
		/* set icon to unknown, continue */
		DEBUG_1("thumb loader start failed %s", fd->path);
		vf_thumb_do(vf, fd);

		return TRUE;
		}

	return FALSE;
}
Beispiel #5
0
static  gint
thumbview_thumbs_next (void)
{
    ZAlbumCell *cell;

    thumbview->thumbs_count++;

    if (thumbview->thumbs_stop)
    {
	thumbview_thumbs_cleanup ();
	return FALSE;
    }

    if (thumbview->thumbs_count < ZALBUM (thumbview->album)->len)
    {
	gchar  *path;
	cell =
	    ZLIST_CELL_FROM_INDEX (ZLIST (thumbview->album),
				   thumbview->thumbs_count);
	path = g_strdup (cell->name);

	if (file_type_is_movie (cell->name))
	{
	    GdkPixbuf *pixbuf = NULL;
	    GdkPixmap *pixmap;
	    GdkBitmap *mask;
	    gchar  *cache_dir;
	    mode_t  mode = 0755;
	    gfloat  status;
	    cache_dir =
		cache_get_location (CACHE_THUMBS, path, FALSE, NULL, &mode);


	    if (cache_ensure_dir_exists (cache_dir, mode))
	    {
		gchar  *cache_path;
		cache_path =
		    g_strconcat (cache_dir, "/", g_basename (cell->name),
				 PORNVIEW_CACHE_THUMB_EXT, NULL);

#ifdef USE_GTK2
		pixbuf = gdk_pixbuf_new_from_file (cache_path, NULL);
#else
		pixbuf = gdk_pixbuf_new_from_file (cache_path);
#endif
		if (pixbuf)
		{
		    gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap,
						       &mask, 128);
		    zalbum_set_pixmap (ZALBUM (thumbview->album),
				       thumbview->thumbs_count, pixmap, mask);
		    if (pixmap)
			gdk_pixmap_unref (pixmap);
		    if (mask)
			gdk_bitmap_unref (mask);
		    gdk_pixbuf_unref (pixbuf);
		}
		else
		{
		    pixbuf = image_get_video_pixbuf ();

		    gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap,
						       &mask, 128);
		    zalbum_set_pixmap (ZALBUM (thumbview->album),
				       thumbview->thumbs_count, pixmap, mask);
		    if (pixmap)
			gdk_pixmap_unref (pixmap);
		    if (mask)
			gdk_bitmap_unref (mask);
		    gdk_pixbuf_unref (pixbuf);
		}

		g_free (cache_path);
	    }

	    g_free (cache_dir);
	    g_free (path);

	    status =
		(gfloat) thumbview->thumbs_count /
		ZALBUM (thumbview->album)->len;
	    thumbview_thumbs_progressbar (status);

	    while (gtk_events_pending ())
		gtk_main_iteration ();

	    thumbview_thumbs_do (NULL);
	    return TRUE;
	}
	else
	{
	    thumb_loader_free (thumbview->thumbs_loader);
	    thumbview->thumbs_loader = thumb_loader_new (path, 100, 100);
	    g_free (path);
	    thumb_loader_set_error_func (thumbview->thumbs_loader,
					 cb_thumbview_thumbs_error, NULL);
	    if (!thumb_loader_start
		(thumbview->thumbs_loader, cb_thumbview_thumbs_done, NULL))
	    {
		thumbview_thumbs_do (NULL);
		return TRUE;
	    }

	}
	return FALSE;
    }
    else
    {
	thumbview_thumbs_cleanup ();
	return FALSE;
    }

    return TRUE;
}
Beispiel #6
0
static gboolean bar_pane_gps_marker_keypress_cb(GtkWidget *widget, ClutterButtonEvent *bevent, gpointer data)
{
	//PaneGPSData *pgd = data;
	FileData *fd;
	ClutterActor *marker;
	ClutterColor marker_colour = { MARKER_COLOUR };
	ClutterColor text_colour = { TEXT_COLOUR };
	ClutterColor thumb_colour = { THUMB_COLOUR };
	gchar *current_text;
	ClutterActor *actor;
	ClutterActor *current_image;
	GString *text;
	gint height, width, rotate;
	gchar *altitude = NULL;
	ThumbLoader *tl;

	if (bevent->button == MOUSE_BUTTON_LEFT)
		{
		marker = CLUTTER_ACTOR(widget);
		fd = g_object_get_data(G_OBJECT(marker), "file_fd");

		/* If the marker is showing a thumbnail, delete it
		 */
		current_image = champlain_marker_get_image(CHAMPLAIN_MARKER(marker));
		if (current_image != NULL)
			{
			clutter_actor_destroy(CLUTTER_ACTOR(current_image));
		 	champlain_marker_set_image(CHAMPLAIN_MARKER(marker), NULL);
			}
			
		current_text = g_strdup(champlain_marker_get_text(CHAMPLAIN_MARKER(marker)));

		/* If the marker is showing only the text character, replace it with a
		 * thumbnail and date and altitude
		 */
		if (g_strcmp0(current_text, "i") == 0)
			{
			/* If a thumbail has already been generated, use that. If not try the pixbuf of the full image.
			 * If not, call the thumb_loader to generate a thumbnail and update the marker later in the
			 * thumb_loader callback
			 */
			 if (fd->thumb_pixbuf != NULL)
				{
				actor = clutter_texture_new();
				gtk_clutter_texture_set_from_pixbuf(CLUTTER_TEXTURE(actor), fd->thumb_pixbuf, NULL);
				champlain_marker_set_image(CHAMPLAIN_MARKER(marker), actor);
				}
			else if (fd->pixbuf != NULL)
				{
				actor = clutter_texture_new();
				width = gdk_pixbuf_get_width (fd->pixbuf);
				height = gdk_pixbuf_get_height (fd->pixbuf);
				switch (fd->exif_orientation)
					{
					case 8:
						rotate = GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE;
						break;
					case 3:
						rotate = GDK_PIXBUF_ROTATE_UPSIDEDOWN;
						break;
					case 6:
						rotate = GDK_PIXBUF_ROTATE_CLOCKWISE;
						break;
					default:
						rotate = GDK_PIXBUF_ROTATE_NONE;
					}
										
					gtk_clutter_texture_set_from_pixbuf(CLUTTER_TEXTURE(actor),
										gdk_pixbuf_rotate_simple(gdk_pixbuf_scale_simple(fd->pixbuf, THUMB_SIZE, height * THUMB_SIZE / width,
										GDK_INTERP_NEAREST), rotate), NULL);
					champlain_marker_set_image(CHAMPLAIN_MARKER(marker), actor);
				}
			else
				{
				tl = thumb_loader_new(THUMB_SIZE, THUMB_SIZE);
				thumb_loader_set_callbacks(tl,
											bar_pane_gps_thumb_done_cb,
											bar_pane_gps_thumb_error_cb,
											NULL,
											marker);
				thumb_loader_start(tl, fd);
				}
				
			text = g_string_new(fd->name);
			g_string_append(text, "\n");
			g_string_append(text, text_from_time(fd->date));
			g_string_append(text, "\n");
			altitude = metadata_read_string(fd, "formatted.GPSAltitude", METADATA_FORMATTED);
			if (altitude != NULL)
				{
				g_string_append(text, altitude);
				}

			champlain_marker_set_text(CHAMPLAIN_MARKER(marker), text->str);
			champlain_marker_set_color(CHAMPLAIN_MARKER(marker), &thumb_colour);
			champlain_marker_set_text_color(CHAMPLAIN_MARKER(marker), &text_colour);
			champlain_marker_set_font_name(CHAMPLAIN_MARKER(marker), "sans 8");

			g_free(altitude);
			g_string_free(text, TRUE);
			}
		/* otherwise, revert to the hidden text marker
		 */
		else
			{
			champlain_marker_set_text(CHAMPLAIN_MARKER(marker), "i");
			champlain_marker_set_color(CHAMPLAIN_MARKER(marker), &marker_colour);
			champlain_marker_set_text_color(CHAMPLAIN_MARKER(marker), &marker_colour);
			champlain_marker_set_font_name(CHAMPLAIN_MARKER(marker), "courier 5");
			}

		g_free(current_text);
		
		return TRUE;
		}
	return TRUE;
}