Commit 43ab55e6 authored by Stephan Arts's avatar Stephan Arts

Connect the image-list and icon-bar to the thumbnailer.

parent 95b5c150
......@@ -33,6 +33,7 @@
#include "util.h"
#include "file.h"
#include "thumbnailer.h"
#include "settings.h"
#include "marshal.h"
#include "icon_bar.h"
......@@ -327,6 +328,7 @@ struct _RsttoIconBarPrivate
GtkAdjustment *vadjustment;
RsttoSettings *settings;
RsttoThumbnailer *thumbnailer;
RsttoThumbnailSize thumbnail_size;
......@@ -550,6 +552,7 @@ rstto_icon_bar_init (RsttoIconBar *icon_bar)
icon_bar->priv->show_text = TRUE;
icon_bar->priv->auto_center = TRUE;
icon_bar->priv->settings = rstto_settings_new ();
icon_bar->priv->thumbnailer = rstto_thumbnailer_new();
icon_bar->priv->thumbnail_size = rstto_settings_get_uint_property (
icon_bar->priv->settings,
......@@ -573,7 +576,6 @@ rstto_icon_bar_init (RsttoIconBar *icon_bar)
"notify::thumbnail-size",
G_CALLBACK (cb_rstto_thumbnail_size_changed),
icon_bar);
}
......@@ -597,6 +599,7 @@ rstto_icon_bar_finalize (GObject *object)
g_object_unref (G_OBJECT (icon_bar->priv->layout));
g_object_unref (G_OBJECT (icon_bar->priv->settings));
g_object_unref (G_OBJECT (icon_bar->priv->thumbnailer));
(*G_OBJECT_CLASS (rstto_icon_bar_parent_class)->finalize) (object);
}
......@@ -913,6 +916,8 @@ rstto_icon_bar_expose (
GdkRectangle area;
RsttoIconBar *icon_bar = RSTTO_ICON_BAR (widget);
GList *lp;
RsttoFile *file;
GtkTreeIter iter;
if (expose->window != icon_bar->priv->bin_window)
return FALSE;
......@@ -936,7 +941,14 @@ rstto_icon_bar_expose (
area.height = icon_bar->priv->item_height;
if (gdk_region_rect_in (expose->region, &area) != GDK_OVERLAP_RECTANGLE_OUT)
{
iter = item->iter;
gtk_tree_model_get (icon_bar->priv->model, &iter,
icon_bar->priv->file_column, &file,
-1);
rstto_thumbnailer_queue_file (icon_bar->priv->thumbnailer, file);
rstto_icon_bar_paint_item (icon_bar, item, &expose->area);
}
}
return TRUE;
......
......@@ -32,6 +32,7 @@
#include "util.h"
#include "file.h"
#include "image_list.h"
#include "thumbnailer.h"
#include "settings.h"
static void
......@@ -67,6 +68,12 @@ cb_rstto_wrap_images_changed (
GParamSpec *pspec,
gpointer user_data);
static void
cb_rstto_thumbnailer_ready(
RsttoThumbnailer *thumbnailer,
RsttoFile *file,
gpointer user_data);
static void
rstto_image_list_monitor_dir (
RsttoImageList *image_list,
......@@ -206,6 +213,7 @@ struct _RsttoImageListPriv
gint stamp;
GFileMonitor *monitor;
RsttoSettings *settings;
RsttoThumbnailer *thumbnailer;
GtkFileFilter *filter;
GList *images;
......@@ -300,6 +308,7 @@ rstto_image_list_init(RsttoImageList *image_list)
image_list->priv = g_new0 (RsttoImageListPriv, 1);
image_list->priv->stamp = g_random_int();
image_list->priv->settings = rstto_settings_new ();
image_list->priv->thumbnailer = rstto_thumbnailer_new();
image_list->priv->filter = gtk_file_filter_new ();
g_object_ref_sink (image_list->priv->filter);
gtk_file_filter_add_pixbuf_formats (image_list->priv->filter);
......@@ -316,6 +325,12 @@ rstto_image_list_init(RsttoImageList *image_list)
G_CALLBACK (cb_rstto_wrap_images_changed),
image_list);
g_signal_connect (
G_OBJECT(image_list->priv->thumbnailer),
"ready",
G_CALLBACK (cb_rstto_thumbnailer_ready),
image_list);
}
static void
......@@ -363,6 +378,12 @@ rstto_image_list_dispose(GObject *object)
image_list->priv->settings = NULL;
}
if (image_list->priv->thumbnailer)
{
g_object_unref (image_list->priv->thumbnailer);
image_list->priv->thumbnailer = NULL;
}
if (image_list->priv->filter)
{
g_object_unref (image_list->priv->filter);
......@@ -1426,3 +1447,25 @@ image_list_model_get_value (
break;
}
}
static void
cb_rstto_thumbnailer_ready(
RsttoThumbnailer *thumbnailer,
RsttoFile *file,
gpointer user_data)
{
RsttoImageList *image_list = RSTTO_IMAGE_LIST (user_data);
GtkTreePath *path_ = NULL;
GtkTreeIter iter;
gint index_;
index_ = g_list_index (image_list->priv->images, file);
if (index_ > 0)
{
path_ = gtk_tree_path_new();
gtk_tree_path_append_index(path_,index_);
gtk_tree_model_get_iter (GTK_TREE_MODEL (image_list), &iter, path_);
gtk_tree_model_row_changed (GTK_TREE_MODEL(image_list), path_, &iter);
}
}
......@@ -77,6 +77,14 @@ static GObjectClass *parent_class = NULL;
static RsttoThumbnailer *thumbnailer_object;
enum
{
RSTTO_THUMBNAILER_SIGNAL_READY = 0,
RSTTO_THUMBNAILER_SIGNAL_COUNT
};
static gint rstto_thumbnailer_signals[RSTTO_THUMBNAILER_SIGNAL_COUNT];
enum
{
PROP_0,
......@@ -119,6 +127,8 @@ struct _RsttoThumbnailerPriv
RsttoSettings *settings;
GSList *queue;
GSList *in_process_queue;
gint handle;
gboolean show_missing_thumbnailer_error;
......@@ -198,6 +208,18 @@ rstto_thumbnailer_class_init (GObjectClass *object_class)
object_class->set_property = rstto_thumbnailer_set_property;
object_class->get_property = rstto_thumbnailer_get_property;
rstto_thumbnailer_signals[RSTTO_THUMBNAILER_SIGNAL_READY] = g_signal_new("ready",
G_TYPE_FROM_CLASS(thumbnailer_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
0,
NULL,
NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE,
1,
G_TYPE_OBJECT,
NULL);
}
/**
......@@ -381,14 +403,17 @@ rstto_thumbnailer_queue_request_timer (
g_return_val_if_fail ( RSTTO_IS_THUMBNAILER (thumbnailer), FALSE);
thumbnailer->priv->in_process_queue = thumbnailer->priv->queue;
thumbnailer->priv->queue = NULL;
uris = g_new0 (
const gchar *,
g_slist_length(thumbnailer->priv->queue) + 1);
g_slist_length(thumbnailer->priv->in_process_queue) + 1);
mimetypes = g_new0 (
const gchar *,
g_slist_length (thumbnailer->priv->queue) + 1);
g_slist_length (thumbnailer->priv->in_process_queue) + 1);
iter = thumbnailer->priv->queue;
iter = thumbnailer->priv->in_process_queue;
while (iter)
{
if (iter->data)
......@@ -477,9 +502,9 @@ cb_rstto_thumbnailer_request_finished (
g_return_if_fail ( RSTTO_IS_THUMBNAILER (thumbnailer) );
g_slist_foreach (thumbnailer->priv->queue, (GFunc)g_object_unref, NULL);
g_slist_free (thumbnailer->priv->queue);
thumbnailer->priv->queue = NULL;
g_slist_foreach (thumbnailer->priv->in_process_queue, (GFunc)g_object_unref, NULL);
g_slist_free (thumbnailer->priv->in_process_queue);
thumbnailer->priv->in_process_queue = NULL;
}
static void
......@@ -491,7 +516,7 @@ cb_rstto_thumbnailer_thumbnail_ready (
{
RsttoThumbnailer *thumbnailer = RSTTO_THUMBNAILER (data);
RsttoFile *file;
GSList *iter = thumbnailer->priv->queue;
GSList *iter = thumbnailer->priv->in_process_queue;
gint x = 0;
const gchar *f_uri;
......@@ -508,12 +533,18 @@ cb_rstto_thumbnailer_thumbnail_ready (
f_uri = rstto_file_get_uri (file);
if (strcmp (uri[x], f_uri) == 0)
{
thumbnailer->priv->queue = g_slist_remove (
thumbnailer->priv->queue,
g_signal_emit (
G_OBJECT (thumbnailer),
rstto_thumbnailer_signals[RSTTO_THUMBNAILER_SIGNAL_READY],
0,
file,
NULL);
thumbnailer->priv->in_process_queue = g_slist_remove (
thumbnailer->priv->in_process_queue,
file);
g_object_unref (file);
iter = thumbnailer->priv->queue;
iter = thumbnailer->priv->in_process_queue;
x++;
}
else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment