[Xfce4-commits] <ristretto:stephan/icon-bar> Replace thumbnail-bar with exo-icon-bar
Stephan Arts
noreply at xfce.org
Mon Jan 9 18:42:02 CET 2012
Updating branch refs/heads/stephan/icon-bar
to 9a1cad6c07c0282aa2b2ef690e656aaa886d2093 (commit)
from e8937cd89c5299d3215708f2df5df3e20b14b11e (commit)
commit 9a1cad6c07c0282aa2b2ef690e656aaa886d2093
Author: Stephan Arts <stephan at xfce.org>
Date: Mon Jan 9 18:38:58 2012 +0100
Replace thumbnail-bar with exo-icon-bar
po/POTFILES.in | 2 -
src/Makefile.am | 2 -
src/image_list.c | 403 ++++++++++++++++++++-
src/main_window.c | 51 ++-
src/thumbnail.c | 388 --------------------
src/thumbnail.h | 74 ----
src/thumbnail_bar.c | 991 ---------------------------------------------------
src/thumbnail_bar.h | 72 ----
src/thumbnailer.c | 36 +-
src/thumbnailer.h | 9 +-
10 files changed, 438 insertions(+), 1590 deletions(-)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 45f5007..fdb6c04 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -6,9 +6,7 @@ src/privacy_dialog.c
src/preferences_dialog.c
src/properties_dialog.c
src/image_list.c
-src/thumbnail.c
src/thumbnailer.c
-src/thumbnail_bar.c
src/wallpaper_manager.c
src/xfce_wallpaper_manager.c
src/gnome_wallpaper_manager.c
diff --git a/src/Makefile.am b/src/Makefile.am
index c5e810e..b211c95 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -13,8 +13,6 @@ ristretto_SOURCES = \
xfce_wallpaper_manager.c xfce_wallpaper_manager.h \
gnome_wallpaper_manager.c gnome_wallpaper_manager.h \
app_menu_item.c app_menu_item.h \
- thumbnail_bar.c thumbnail_bar.h \
- thumbnail.c thumbnail.h \
thumbnailer.c thumbnailer.h \
marshal.c marshal.h \
file.c file.h \
diff --git a/src/image_list.c b/src/image_list.c
index 5881651..800e0f5 100644
--- a/src/image_list.c
+++ b/src/image_list.c
@@ -33,6 +33,11 @@
#include "image_list.h"
#include "settings.h"
+static void
+rstto_image_list_tree_model_init (GtkTreeModelIface *iface);
+static void
+rstto_image_list_tree_sortable_init(GtkTreeSortableIface *iface);
+
static void
rstto_image_list_init(RsttoImageList *);
static void
@@ -86,6 +91,77 @@ iter_set_position (
gint pos,
gboolean sticky);
+/***************************************/
+/* Begin TreeModelIface Functions */
+/***************************************/
+
+static GtkTreeModelFlags
+image_list_model_get_flags ( GtkTreeModel *tree_model );
+
+static gint
+image_list_model_get_n_columns ( GtkTreeModel *tree_model );
+
+static GType
+image_list_model_get_column_type (
+ GtkTreeModel *tree_model,
+ gint index_ );
+
+static gboolean
+image_list_model_get_iter (
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ GtkTreePath *path );
+
+static GtkTreePath *
+image_list_model_get_path (
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter );
+
+static void
+image_list_model_get_value (
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ gint column,
+ GValue *value );
+
+static gboolean
+image_list_model_iter_children (
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ GtkTreeIter *parent );
+
+static gboolean
+image_list_model_iter_has_child (
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter );
+
+static gboolean
+image_list_model_iter_parent (
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ GtkTreeIter *child );
+
+static gint
+image_list_model_iter_n_children (
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter );
+
+static gboolean
+image_list_model_iter_nth_child (
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ GtkTreeIter *parent,
+ gint n );
+
+static gboolean
+image_list_model_iter_next (
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter );
+
+/***************************************/
+/* End TreeModelIface Functions */
+/***************************************/
+
static RsttoImageListIter * rstto_image_list_iter_new ();
static gint
@@ -98,8 +174,7 @@ static GObjectClass *iter_parent_class = NULL;
enum
{
- RSTTO_IMAGE_LIST_SIGNAL_NEW_IMAGE = 0,
- RSTTO_IMAGE_LIST_SIGNAL_REMOVE_IMAGE,
+ RSTTO_IMAGE_LIST_SIGNAL_REMOVE_IMAGE = 0,
RSTTO_IMAGE_LIST_SIGNAL_REMOVE_ALL,
RSTTO_IMAGE_LIST_SIGNAL_COUNT
};
@@ -122,7 +197,8 @@ struct _RsttoImageListIterPriv
struct _RsttoImageListPriv
{
- GFileMonitor *monitor;
+ gint stamp;
+ GFileMonitor *monitor;
RsttoSettings *settings;
GtkFileFilter *filter;
@@ -141,6 +217,18 @@ static gint rstto_image_list_iter_signals[RSTTO_IMAGE_LIST_ITER_SIGNAL_COUNT];
GType
rstto_image_list_get_type (void)
{
+ static const GInterfaceInfo tree_model_info =
+ {
+ (GInterfaceInitFunc) rstto_image_list_tree_model_init,
+ NULL,
+ NULL
+ };
+ static const GInterfaceInfo tree_sort_info =
+ {
+ (GInterfaceInitFunc) rstto_image_list_tree_sortable_init,
+ NULL,
+ NULL
+ };
static GType rstto_image_list_type = 0;
if (!rstto_image_list_type)
@@ -160,15 +248,51 @@ rstto_image_list_get_type (void)
};
rstto_image_list_type = g_type_register_static (G_TYPE_OBJECT, "RsttoImageList", &rstto_image_list_info, 0);
+
+ g_type_add_interface_static (rstto_image_list_type, GTK_TYPE_TREE_MODEL, &tree_model_info);
+
+ g_type_add_interface_static (rstto_image_list_type, GTK_TYPE_TREE_SORTABLE, &tree_sort_info);
}
+
+
return rstto_image_list_type;
}
static void
+rstto_image_list_tree_model_init (GtkTreeModelIface *iface)
+{
+ iface->get_flags = image_list_model_get_flags;
+ iface->get_n_columns = image_list_model_get_n_columns;
+ iface->get_column_type = image_list_model_get_column_type;
+ iface->get_iter = image_list_model_get_iter;
+ iface->get_path = image_list_model_get_path;
+ iface->get_value = image_list_model_get_value;
+ iface->iter_children = image_list_model_iter_children;
+ iface->iter_has_child = image_list_model_iter_has_child;
+ iface->iter_n_children = image_list_model_iter_n_children;
+ iface->iter_nth_child = image_list_model_iter_nth_child;
+ iface->iter_parent = image_list_model_iter_parent;
+ iface->iter_next = image_list_model_iter_next;
+}
+
+static void
+rstto_image_list_tree_sortable_init(GtkTreeSortableIface *iface)
+{
+#if 0
+ iface->get_sort_column_id = sq_archive_store_get_sort_column_id;
+ iface->set_sort_column_id = sq_archive_store_set_sort_column_id;
+ iface->set_sort_func = sq_archive_store_set_sort_func; /*NOT SUPPORTED*/
+ iface->set_default_sort_func = sq_archive_store_set_default_sort_func; /*NOT SUPPORTED*/
+ iface->has_default_sort_func = sq_archive_store_has_default_sort_func;
+#endif
+}
+
+static void
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->filter = gtk_file_filter_new ();
g_object_ref_sink (image_list->priv->filter);
@@ -197,18 +321,6 @@ rstto_image_list_class_init(RsttoImageListClass *nav_class)
object_class->dispose = rstto_image_list_dispose;
- rstto_image_list_signals[RSTTO_IMAGE_LIST_SIGNAL_NEW_IMAGE] = g_signal_new("new-image",
- G_TYPE_FROM_CLASS(nav_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- 0,
- NULL,
- NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1,
- G_TYPE_OBJECT,
- NULL);
-
rstto_image_list_signals[RSTTO_IMAGE_LIST_SIGNAL_REMOVE_IMAGE] = g_signal_new("remove-image",
G_TYPE_FROM_CLASS(nav_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
@@ -275,6 +387,9 @@ rstto_image_list_add_file (
GtkFileFilterInfo filter_info;
GList *image_iter = g_list_find (image_list->priv->images, file);
GSList *iter = image_list->priv->iterators;
+ gint i = 0;
+ GtkTreePath *path = NULL;
+ GtkTreeIter t_iter;
g_return_val_if_fail ( NULL != file , FALSE);
g_return_val_if_fail ( RSTTO_IS_FILE (file) , FALSE);
@@ -294,8 +409,8 @@ rstto_image_list_add_file (
image_list->priv->images = g_list_insert_sorted (image_list->priv->images, file, rstto_image_list_get_compare_func (image_list));
image_list->priv->n_images++;
+ i = g_list_index (image_list->priv->images, file);
- g_signal_emit (G_OBJECT (image_list), rstto_image_list_signals[RSTTO_IMAGE_LIST_SIGNAL_NEW_IMAGE], 0, file, NULL);
/** TODO: update all iterators */
while (iter)
{
@@ -305,6 +420,14 @@ rstto_image_list_add_file (
}
iter = g_slist_next (iter);
}
+
+ path = gtk_tree_path_new();
+ gtk_tree_path_append_index (path, i);
+ t_iter.stamp = image_list->priv->stamp;
+ t_iter.user_data = file;
+ t_iter.user_data3 = GINT_TO_POINTER(i);
+
+ gtk_tree_model_row_inserted(GTK_TREE_MODEL(image_list), path, &t_iter);
return TRUE;
}
else
@@ -315,8 +438,6 @@ rstto_image_list_add_file (
return FALSE;
}
- g_signal_emit (G_OBJECT (image_list), rstto_image_list_signals[RSTTO_IMAGE_LIST_SIGNAL_NEW_IMAGE], 0, image_iter->data, NULL);
-
return TRUE;
}
@@ -1058,3 +1179,249 @@ cb_rstto_wrap_images_changed (
image_list->priv->wrap_images = g_value_get_boolean (&val_wrap_images);
}
+
+/***************************************/
+/* TreeModelIface Functions */
+/***************************************/
+
+static GtkTreeModelFlags
+image_list_model_get_flags ( GtkTreeModel *tree_model )
+{
+ g_debug("%s", __FUNCTION__);
+ g_return_val_if_fail(RSTTO_IS_IMAGE_LIST(tree_model), (GtkTreeModelFlags)0);
+
+ return (GTK_TREE_MODEL_LIST_ONLY | GTK_TREE_MODEL_ITERS_PERSIST);
+}
+
+static gint
+image_list_model_get_n_columns ( GtkTreeModel *tree_model )
+{
+ g_debug("%s", __FUNCTION__);
+ g_return_val_if_fail(RSTTO_IS_IMAGE_LIST(tree_model), 0);
+
+ return 2;
+}
+
+static GType
+image_list_model_get_column_type (
+ GtkTreeModel *tree_model,
+ gint index_ )
+{
+ g_debug("%s", __FUNCTION__);
+ g_return_val_if_fail(RSTTO_IS_IMAGE_LIST(tree_model), G_TYPE_INVALID);
+
+ switch (index_)
+ {
+ case 0: /* filename */
+ return G_TYPE_STRING;
+ case 1:
+ return GDK_TYPE_PIXBUF;
+ break;
+ default:
+ return G_TYPE_INVALID;
+ break;
+ }
+}
+
+static gboolean
+image_list_model_get_iter (
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ GtkTreePath *path )
+{
+ gint *indices;
+ gint depth;
+ gint index_;
+ RsttoImageList *image_list;
+ RsttoFile *file = NULL;
+
+ g_debug("%s", __FUNCTION__);
+ g_return_val_if_fail(RSTTO_IS_IMAGE_LIST(tree_model), FALSE);
+
+ image_list = RSTTO_IMAGE_LIST (tree_model);
+
+ indices = gtk_tree_path_get_indices(path);
+ depth = gtk_tree_path_get_depth(path) - 1;
+
+ /* only support list: depth is always 0 */
+ g_return_val_if_fail(depth == 0, FALSE);
+
+ index_ = indices[depth];
+
+ if (index_ >= 0)
+ {
+ file = g_list_nth_data (image_list->priv->images, index_);
+ }
+
+ if (NULL == file)
+ {
+ return FALSE;
+ }
+
+ /* set the stamp, identify the iter as ours */
+ iter->stamp = image_list->priv->stamp;
+
+ iter->user_data = file;
+
+ /* the index_ in the child list */
+ iter->user_data3 = GINT_TO_POINTER(index_);
+ return TRUE;
+}
+
+static GtkTreePath *
+image_list_model_get_path (
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter )
+{
+ GtkTreePath *path = NULL;
+ RsttoFile *file = NULL;
+ gint pos;
+
+ g_debug("%s", __FUNCTION__);
+ g_return_val_if_fail(RSTTO_IS_IMAGE_LIST(tree_model), NULL);
+
+ file = RSTTO_FILE (iter->user_data);
+ pos = GPOINTER_TO_INT (iter->user_data3);
+
+ path = gtk_tree_path_new();
+ gtk_tree_path_append_index(path, pos);
+
+ return path;
+}
+
+static gboolean
+image_list_model_iter_children (
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ GtkTreeIter *parent )
+{
+ RsttoFile *file = NULL;
+ RsttoImageList *image_list;
+
+ g_debug("%s", __FUNCTION__);
+ g_return_val_if_fail(RSTTO_IS_IMAGE_LIST(tree_model), FALSE);
+
+ /* only support lists: parent is always NULL */
+ g_return_val_if_fail(parent == NULL, FALSE);
+
+ image_list = RSTTO_IMAGE_LIST (tree_model);
+
+ file = g_list_nth_data (image_list->priv->images, 0);
+
+ if (NULL == file)
+ {
+ return FALSE;
+ }
+
+ iter->stamp = image_list->priv->stamp;
+ iter->user_data = file;
+ iter->user_data3 = GINT_TO_POINTER(0);
+
+ return TRUE;
+}
+
+static gboolean
+image_list_model_iter_has_child (
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter )
+{
+ g_debug("%s", __FUNCTION__);
+ return FALSE;
+}
+
+static gboolean
+image_list_model_iter_parent (
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ GtkTreeIter *child )
+{
+ g_debug("%s", __FUNCTION__);
+ return FALSE;
+}
+
+static gint
+image_list_model_iter_n_children (
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter )
+{
+ g_debug("%s", __FUNCTION__);
+ return FALSE;
+}
+
+static gboolean
+image_list_model_iter_nth_child (
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ GtkTreeIter *parent,
+ gint n )
+{
+ g_debug("%s", __FUNCTION__);
+ return FALSE;
+}
+
+static gboolean
+image_list_model_iter_next (
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter )
+{
+ RsttoImageList *image_list;
+ RsttoFile *file = NULL;
+ gint pos = 0;
+
+ g_debug("%s", __FUNCTION__);
+ g_return_val_if_fail(RSTTO_IS_IMAGE_LIST(tree_model), FALSE);
+
+ image_list = RSTTO_IMAGE_LIST (tree_model);
+
+ file = iter->user_data;
+ pos = GPOINTER_TO_INT(iter->user_data3);
+ pos++;
+
+ file = g_list_nth_data (image_list->priv->images, pos);
+
+ if (NULL == file)
+ {
+ return FALSE;
+ }
+
+ iter->stamp = image_list->priv->stamp;
+ iter->user_data = file;
+ iter->user_data3 = GINT_TO_POINTER(pos);
+
+ return TRUE;
+}
+
+static void
+image_list_model_get_value (
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ gint column,
+ GValue *value )
+{
+ RsttoFile *file = RSTTO_FILE(iter->user_data);
+ const gchar *uri = NULL;
+ gchar *checksum = NULL;
+ gchar *thumbnail_path = NULL;
+ gchar *filename = NULL;
+
+ switch (column)
+ {
+ case 0:
+ g_value_init (value, G_TYPE_STRING);
+ g_value_set_string (value, rstto_file_get_display_name (file));
+ break;
+ case 1:
+ uri = rstto_file_get_uri (file);
+ checksum = g_compute_checksum_for_string (G_CHECKSUM_MD5, uri, strlen (uri));
+ filename = g_strconcat (checksum, ".png", NULL);
+ thumbnail_path = g_build_path ("/", g_get_home_dir(), ".thumbnails", "normal", filename, NULL);
+
+ g_value_init (value, GDK_TYPE_PIXBUF);
+ g_value_take_object (value, gdk_pixbuf_new_from_file_at_scale (thumbnail_path, 64, 64, TRUE, NULL));
+
+ g_free (checksum);
+ g_free (filename);
+ g_free (thumbnail_path);
+ break;
+ }
+}
diff --git a/src/main_window.c b/src/main_window.c
index 2e26e14..0a135d6 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -40,7 +40,6 @@
#include "image_viewer.h"
#include "main_window.h"
#include "main_window_ui.h"
-#include "thumbnail_bar.h"
#include "wallpaper_manager.h"
#include "xfce_wallpaper_manager.h"
@@ -95,6 +94,7 @@ struct _RsttoMainWindowPriv
GtkWidget *hpaned_right;
GtkWidget *vpaned_top;
GtkWidget *vpaned_bottom;
+ GtkWidget *t_bar_s_window;
GtkWidget *thumbnailbar;
GtkWidget *statusbar;
guint statusbar_context_id;
@@ -616,7 +616,14 @@ rstto_main_window_init (RsttoMainWindow *window)
RSTTO_IMAGE_VIEWER(window->priv->image_viewer),
GTK_MENU(window->priv->image_viewer_menu));
- window->priv->thumbnailbar = rstto_thumbnail_bar_new (NULL);
+ window->priv->thumbnailbar = exo_icon_bar_new();
+
+ window->priv->t_bar_s_window = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (window->priv->t_bar_s_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_container_add (GTK_CONTAINER (window->priv->t_bar_s_window), window->priv->thumbnailbar);
+
+ exo_icon_bar_set_text_column (EXO_ICON_BAR (window->priv->thumbnailbar), 0);
+ exo_icon_bar_set_pixbuf_column (EXO_ICON_BAR (window->priv->thumbnailbar), 1);
window->priv->hpaned_left = gtk_hpaned_new();
window->priv->hpaned_right = gtk_hpaned_new();
@@ -629,7 +636,7 @@ rstto_main_window_init (RsttoMainWindow *window)
gtk_paned_pack2 (GTK_PANED (window->priv->vpaned_top), window->priv->vpaned_bottom, TRUE, FALSE);
gtk_paned_pack1 (GTK_PANED (window->priv->vpaned_bottom), window->priv->p_viewer_s_window, TRUE, FALSE);
- gtk_paned_pack2 (GTK_PANED (window->priv->hpaned_right), window->priv->thumbnailbar, FALSE, FALSE);
+ gtk_paned_pack2 (GTK_PANED (window->priv->hpaned_right), window->priv->t_bar_s_window, FALSE, FALSE);
window->priv->statusbar = gtk_statusbar_new();
@@ -930,12 +937,18 @@ rstto_main_window_new (RsttoImageList *image_list, gboolean fullscreen)
"changed",
G_CALLBACK (cb_rstto_main_window_image_list_iter_changed),
window);
+
+ exo_icon_bar_set_model (
+ EXO_ICON_BAR (window->priv->thumbnailbar),
+ GTK_TREE_MODEL (window->priv->image_list));
+ /*
rstto_thumbnail_bar_set_image_list (
RSTTO_THUMBNAIL_BAR (window->priv->thumbnailbar),
window->priv->image_list);
rstto_thumbnail_bar_set_iter (
RSTTO_THUMBNAIL_BAR (window->priv->thumbnailbar),
window->priv->iter);
+ */
rstto_main_window_update_buttons (window);
if (fullscreen == TRUE)
@@ -1767,66 +1780,66 @@ rstto_main_window_set_navigationbar_position (RsttoMainWindow *window, guint ori
{
case 0: /* Left */
g_object_ref (window->priv->image_list_toolbar);
- g_object_ref (window->priv->thumbnailbar);
+ g_object_ref (window->priv->t_bar_s_window);
gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON(window->priv->back), GTK_STOCK_GO_UP);
gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON(window->priv->forward), GTK_STOCK_GO_DOWN);
- gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (window->priv->thumbnailbar)), window->priv->thumbnailbar);
- gtk_paned_pack1 (GTK_PANED (window->priv->hpaned_left), window->priv->thumbnailbar, FALSE, FALSE);
+ gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (window->priv->t_bar_s_window)), window->priv->t_bar_s_window);
+ gtk_paned_pack1 (GTK_PANED (window->priv->hpaned_left), window->priv->t_bar_s_window, FALSE, FALSE);
gtk_container_remove (GTK_CONTAINER (window->priv->table), window->priv->image_list_toolbar);
gtk_table_attach (GTK_TABLE (window->priv->table), window->priv->image_list_toolbar, 0, 1, 0, 3, GTK_FILL, GTK_EXPAND|GTK_FILL, 0, 0);
gtk_orientable_set_orientation (GTK_ORIENTABLE(window->priv->image_list_toolbar), GTK_ORIENTATION_VERTICAL);
- rstto_thumbnail_bar_set_orientation (RSTTO_THUMBNAIL_BAR(window->priv->thumbnailbar), GTK_ORIENTATION_VERTICAL);
+ exo_icon_bar_set_orientation (EXO_ICON_BAR(window->priv->thumbnailbar), GTK_ORIENTATION_VERTICAL);
break;
case 1: /* Right */
g_object_ref (window->priv->image_list_toolbar);
- g_object_ref (window->priv->thumbnailbar);
+ g_object_ref (window->priv->t_bar_s_window);
gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON(window->priv->back), GTK_STOCK_GO_UP);
gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON(window->priv->forward), GTK_STOCK_GO_DOWN);
- gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (window->priv->thumbnailbar)), window->priv->thumbnailbar);
- gtk_paned_pack2 (GTK_PANED (window->priv->hpaned_right), window->priv->thumbnailbar, FALSE, FALSE);
+ gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (window->priv->t_bar_s_window)), window->priv->t_bar_s_window);
+ gtk_paned_pack2 (GTK_PANED (window->priv->hpaned_right), window->priv->t_bar_s_window, FALSE, FALSE);
gtk_container_remove (GTK_CONTAINER (window->priv->table), window->priv->image_list_toolbar);
gtk_table_attach (GTK_TABLE (window->priv->table), window->priv->image_list_toolbar, 2, 3, 0, 3, GTK_FILL,GTK_EXPAND|GTK_FILL, 0, 0);
gtk_orientable_set_orientation (GTK_ORIENTABLE (window->priv->image_list_toolbar), GTK_ORIENTATION_VERTICAL);
- rstto_thumbnail_bar_set_orientation (RSTTO_THUMBNAIL_BAR(window->priv->thumbnailbar), GTK_ORIENTATION_VERTICAL);
+ exo_icon_bar_set_orientation (EXO_ICON_BAR(window->priv->thumbnailbar), GTK_ORIENTATION_VERTICAL);
break;
case 2: /* Top */
g_object_ref (window->priv->image_list_toolbar);
- g_object_ref (window->priv->thumbnailbar);
+ g_object_ref (window->priv->t_bar_s_window);
gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON(window->priv->back), GTK_STOCK_GO_BACK);
gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON(window->priv->forward), GTK_STOCK_GO_FORWARD);
- gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (window->priv->thumbnailbar)), window->priv->thumbnailbar);
- gtk_paned_pack1 (GTK_PANED (window->priv->vpaned_top), window->priv->thumbnailbar, FALSE, FALSE);
+ gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (window->priv->t_bar_s_window)), window->priv->t_bar_s_window);
+ gtk_paned_pack1 (GTK_PANED (window->priv->vpaned_top), window->priv->t_bar_s_window, FALSE, FALSE);
gtk_container_remove (GTK_CONTAINER (window->priv->table), window->priv->image_list_toolbar);
gtk_table_attach (GTK_TABLE (window->priv->table), window->priv->image_list_toolbar, 0, 3, 0, 1, GTK_EXPAND|GTK_FILL,GTK_FILL, 0, 0);
gtk_orientable_set_orientation (GTK_ORIENTABLE (window->priv->image_list_toolbar), GTK_ORIENTATION_HORIZONTAL);
- rstto_thumbnail_bar_set_orientation (RSTTO_THUMBNAIL_BAR(window->priv->thumbnailbar), GTK_ORIENTATION_HORIZONTAL);
+ exo_icon_bar_set_orientation (EXO_ICON_BAR(window->priv->thumbnailbar), GTK_ORIENTATION_HORIZONTAL);
break;
case 3: /* Bottom */
g_object_ref (window->priv->image_list_toolbar);
- g_object_ref (window->priv->thumbnailbar);
+ g_object_ref (window->priv->t_bar_s_window);
gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON(window->priv->back), GTK_STOCK_GO_BACK);
gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON(window->priv->forward), GTK_STOCK_GO_FORWARD);
- gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (window->priv->thumbnailbar)), window->priv->thumbnailbar);
- gtk_paned_pack2 (GTK_PANED (window->priv->vpaned_bottom), window->priv->thumbnailbar, FALSE, FALSE);
+ gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (window->priv->t_bar_s_window)), window->priv->t_bar_s_window);
+ gtk_paned_pack2 (GTK_PANED (window->priv->vpaned_bottom), window->priv->t_bar_s_window, FALSE, FALSE);
gtk_container_remove (GTK_CONTAINER (window->priv->table), window->priv->image_list_toolbar);
gtk_table_attach (GTK_TABLE (window->priv->table), window->priv->image_list_toolbar, 0, 3, 2, 3, GTK_EXPAND|GTK_FILL,GTK_FILL, 0, 0);
gtk_orientable_set_orientation (GTK_ORIENTABLE(window->priv->image_list_toolbar), GTK_ORIENTATION_HORIZONTAL);
- rstto_thumbnail_bar_set_orientation (RSTTO_THUMBNAIL_BAR(window->priv->thumbnailbar), GTK_ORIENTATION_HORIZONTAL);
+ exo_icon_bar_set_orientation (EXO_ICON_BAR(window->priv->thumbnailbar), GTK_ORIENTATION_HORIZONTAL);
break;
default:
break;
diff --git a/src/thumbnail.c b/src/thumbnail.c
deleted file mode 100644
index 67876fc..0000000
--- a/src/thumbnail.c
+++ /dev/null
@@ -1,388 +0,0 @@
-/*
- * Copyright (C) Stephan Arts 2006-2010 <stephan at xfce.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Library General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <config.h>
-#include <gtk/gtk.h>
-#include <gtk/gtkmarshal.h>
-#include <string.h>
-
-#include <libexif/exif-data.h>
-
-#include "util.h"
-#include "file.h"
-#include "image_list.h"
-#include "thumbnail.h"
-
-struct _RsttoThumbnailPriv
-{
- RsttoFile *file;
- GdkPixbuf *pixbuf;
- GdkPixbuf *thumb_pixbuf;
- gchar *thumbnail_path;
-};
-
-static GtkWidgetClass *parent_class = NULL;
-static GdkPixbuf *thumbnail_missing_icon = NULL;
-
-static void
-rstto_thumbnail_init(RsttoThumbnail *);
-static void
-rstto_thumbnail_class_init(RsttoThumbnailClass *);
-static void
-rstto_thumbnail_finalize(GObject *object);
-
-static void
-rstto_thumbnail_size_request(GtkWidget *, GtkRequisition *);
-static void
-rstto_thumbnail_size_allocate(GtkWidget *, GtkAllocation *);
-static gboolean
-rstto_thumbnail_expose(GtkWidget *, GdkEventExpose *);
-
-static void
-rstto_thumbnail_paint(RsttoThumbnail *thumb);
-
-static void
-rstto_thumbnail_clicked (GtkButton *);
-static void
-rstto_thumbnail_enter (GtkButton *);
-static void
-rstto_thumbnail_leave (GtkButton *);
-
-GType
-rstto_thumbnail_get_type (void)
-{
- static GType rstto_thumbnail_type = 0;
-
- if (!rstto_thumbnail_type)
- {
- static const GTypeInfo rstto_thumbnail_info =
- {
- sizeof (RsttoThumbnailClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) rstto_thumbnail_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof (RsttoThumbnail),
- 0,
- (GInstanceInitFunc) rstto_thumbnail_init,
- NULL
- };
-
- rstto_thumbnail_type = g_type_register_static (GTK_TYPE_BUTTON, "RsttoThumbnail", &rstto_thumbnail_info, 0);
- }
- return rstto_thumbnail_type;
-}
-
-static void
-rstto_thumbnail_init(RsttoThumbnail *thumb)
-{
- thumb->priv = g_new0(RsttoThumbnailPriv, 1);
-
- if (thumbnail_missing_icon == NULL)
- {
- thumbnail_missing_icon = gtk_icon_theme_load_icon (gtk_icon_theme_get_default(),
- "image-missing",
- 128,
- 0,
- NULL);
- }
-
-
- gtk_widget_set_redraw_on_allocate(GTK_WIDGET(thumb), TRUE);
- gtk_widget_set_events (GTK_WIDGET(thumb),
- GDK_POINTER_MOTION_MASK);
-}
-
-static void
-rstto_thumbnail_class_init(RsttoThumbnailClass *thumb_class)
-{
- GtkWidgetClass *widget_class;
- GObjectClass *object_class;
- GtkButtonClass *button_class;
-
- widget_class = (GtkWidgetClass*)thumb_class;
- object_class = (GObjectClass*)thumb_class;
- button_class = (GtkButtonClass*)thumb_class;
-
- parent_class = g_type_class_peek_parent(thumb_class);
-
- widget_class->expose_event = rstto_thumbnail_expose;
-
- widget_class->size_request = rstto_thumbnail_size_request;
- widget_class->size_allocate = rstto_thumbnail_size_allocate;
-
- button_class->clicked = rstto_thumbnail_clicked;
- button_class->enter = rstto_thumbnail_enter;
- button_class->leave = rstto_thumbnail_leave;
-
- object_class->finalize = rstto_thumbnail_finalize;
-}
-
-static void
-rstto_thumbnail_finalize(GObject *object)
-{
- RsttoThumbnail *thumb = RSTTO_THUMBNAIL(object);
- if (thumb->priv->file)
- {
- g_object_unref (thumb->priv->file);
- thumb->priv->file = NULL;
- }
-
- if (thumb->priv->pixbuf)
- {
- g_object_unref (thumb->priv->pixbuf);
- thumb->priv->pixbuf = NULL;
- }
-
- if (thumb->priv->thumbnail_path)
- {
- g_free (thumb->priv->thumbnail_path);
- thumb->priv->thumbnail_path = NULL;
- }
-
- if (thumb->priv->thumb_pixbuf)
- {
- g_object_unref (thumb->priv->thumb_pixbuf);
- thumb->priv->thumb_pixbuf = NULL;
- }
-
-}
-
-
-static void
-rstto_thumbnail_size_request(GtkWidget *widget, GtkRequisition *requisition)
-{
- requisition->height = 70;
- requisition->width = 70;
-}
-
-static void
-rstto_thumbnail_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
-{
- RsttoThumbnail *thumb = RSTTO_THUMBNAIL(widget);
- widget->allocation = *allocation;
- parent_class->size_allocate(widget, allocation);
-
- if (thumb->priv->pixbuf)
- {
- g_object_unref (thumb->priv->pixbuf);
- thumb->priv->pixbuf = NULL;
- }
-
- thumb->priv->pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
- TRUE,
- 8,
- allocation->width,
- allocation->height);
-}
-
-static gboolean
-rstto_thumbnail_expose(GtkWidget *widget, GdkEventExpose *event)
-{
- RsttoThumbnail *thumb = RSTTO_THUMBNAIL(widget);
- GdkPixbuf *thumb_pixbuf = NULL;
- GdkPixbuf *tmp_pixbuf = NULL;
-
- if (GTK_WIDGET_REALIZED (widget))
- {
- if (NULL == thumb->priv->thumb_pixbuf)
- {
- thumb->priv->thumb_pixbuf = gdk_pixbuf_new_from_file_at_scale (thumb->priv->thumbnail_path, 128, 128, TRUE, NULL);
- }
- if (NULL != thumb->priv->thumb_pixbuf)
- {
- thumb_pixbuf = thumb->priv->thumb_pixbuf;
- g_object_ref (thumb_pixbuf);
- }
- /* TODO: perform a check if we can open the real thumbnail */
- if (thumb_pixbuf == NULL)
- {
- thumb_pixbuf = thumbnail_missing_icon;
- g_object_ref (thumb_pixbuf);
- }
-
- if (thumb_pixbuf)
- {
- gint height = gdk_pixbuf_get_height (thumb->priv->pixbuf) - 10;
- gint width = gdk_pixbuf_get_width (thumb->priv->pixbuf) - 10;
- GdkPixbuf *dst_thumb_pixbuf = NULL;
-
- switch (rstto_file_get_orientation (thumb->priv->file))
- {
- case RSTTO_IMAGE_ORIENT_90:
- tmp_pixbuf = gdk_pixbuf_rotate_simple (
- thumb_pixbuf,
- GDK_PIXBUF_ROTATE_CLOCKWISE);
- break;
- case RSTTO_IMAGE_ORIENT_180:
- tmp_pixbuf = gdk_pixbuf_rotate_simple (
- thumb_pixbuf,
- GDK_PIXBUF_ROTATE_UPSIDEDOWN);
- break;
- case RSTTO_IMAGE_ORIENT_270:
- tmp_pixbuf = gdk_pixbuf_rotate_simple (
- thumb_pixbuf,
- GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE);
- break;
- default:
- tmp_pixbuf = thumb_pixbuf;
- g_object_ref (tmp_pixbuf);
- break;
- }
-
- if (gdk_pixbuf_get_width (tmp_pixbuf) > gdk_pixbuf_get_height (tmp_pixbuf))
- {
- height = (gint)(((gdouble)gdk_pixbuf_get_height (tmp_pixbuf) / (gdouble)gdk_pixbuf_get_width (tmp_pixbuf)) * width);
- }
- else
- {
- width = (gint)(((gdouble)gdk_pixbuf_get_width (tmp_pixbuf) / (gdouble)gdk_pixbuf_get_height (tmp_pixbuf)) * height);
- }
-
- gdk_pixbuf_fill (thumb->priv->pixbuf, 0x00000000);
-
- dst_thumb_pixbuf = gdk_pixbuf_scale_simple (tmp_pixbuf, width, height, GDK_INTERP_BILINEAR);
-
- g_object_unref (tmp_pixbuf);
- tmp_pixbuf = NULL;
-
- gdk_pixbuf_copy_area (dst_thumb_pixbuf,
- 0, 0,
- width, height,
- thumb->priv->pixbuf,
- (gint)((gdouble)(gdk_pixbuf_get_width (thumb->priv->pixbuf) - width))/2,
- (gint)((gdouble)(gdk_pixbuf_get_height (thumb->priv->pixbuf) - height))/2
- );
-
- g_object_unref (dst_thumb_pixbuf);
- g_object_unref (thumb_pixbuf);
- }
-
-
- gdk_window_begin_paint_region(widget->window, event->region);
- rstto_thumbnail_paint(thumb);
- gdk_window_end_paint(widget->window);
- }
-
- return FALSE;
-}
-
-static void
-rstto_thumbnail_paint(RsttoThumbnail *thumb)
-{
- GtkWidget *widget = GTK_WIDGET(thumb);
-
- GtkStateType state = GTK_WIDGET_STATE(widget);
-
- if (GTK_WIDGET_STATE(widget) != GTK_STATE_PRELIGHT)
- {
- }
-
- gtk_paint_box(widget->style,
- widget->window,
- state,
- GTK_SHADOW_ETCHED_IN,
- NULL,
- widget,
- NULL,
- widget->allocation.x, widget->allocation.y,
- widget->allocation.width, widget->allocation.height);
-
- if (thumb->priv->pixbuf)
- {
- gdk_draw_pixbuf(GDK_DRAWABLE(widget->window),
- NULL,
- thumb->priv->pixbuf,
- 0, 0,
- (0.5 * (widget->allocation.width - gdk_pixbuf_get_width(thumb->priv->pixbuf))) + widget->allocation.x,
- (0.5 * (widget->allocation.height - gdk_pixbuf_get_height(thumb->priv->pixbuf))) + widget->allocation.y,
- -1, -1,
- GDK_RGB_DITHER_NORMAL,
- 0, 0);
- }
-}
-
-GtkWidget *
-rstto_thumbnail_new (RsttoFile *file)
-{
- const gchar *file_uri;
- gchar *file_uri_checksum;
- gchar *filename;
-
- RsttoThumbnail *thumb;
-
- g_return_val_if_fail (file != NULL, NULL);
-
- thumb = g_object_new(RSTTO_TYPE_THUMBNAIL, NULL);
-
- thumb->priv->file = file ;
- g_object_ref (file);
-
- file_uri = rstto_file_get_uri (file);
- file_uri_checksum = g_compute_checksum_for_string (G_CHECKSUM_MD5, file_uri, strlen (file_uri));
- filename = g_strconcat (file_uri_checksum, ".png", NULL);
-
- thumb->priv->thumbnail_path = g_build_path ("/", g_get_home_dir(), ".thumbnails", "normal", filename, NULL);
-
- gtk_widget_set_tooltip_text(GTK_WIDGET(thumb), rstto_file_get_display_name (file));
-
- g_free (file_uri_checksum);
- g_free (filename);
- return GTK_WIDGET(thumb);
-}
-
-RsttoFile *
-rstto_thumbnail_get_file (RsttoThumbnail *thumb)
-{
- return thumb->priv->file;
-}
-
-/* CALLBACKS */
-/*************/
-
-static void
-rstto_thumbnail_clicked (GtkButton *button)
-{
- gtk_widget_queue_draw (GTK_WIDGET (button));
-}
-
-static void
-rstto_thumbnail_enter (GtkButton *button)
-{
- gtk_widget_set_state (GTK_WIDGET (button), GTK_STATE_PRELIGHT);
- gtk_widget_queue_draw (GTK_WIDGET (button));
-}
-
-static void
-rstto_thumbnail_leave (GtkButton *button)
-{
- gtk_widget_set_state (GTK_WIDGET (button), GTK_STATE_NORMAL);
- gtk_widget_queue_draw (GTK_WIDGET (button));
-}
-
-void
-rstto_thumbnail_update (RsttoThumbnail *thumb)
-{
- if (thumb->priv->thumb_pixbuf)
- {
- g_object_unref (thumb->priv->thumb_pixbuf);
- }
- thumb->priv->thumb_pixbuf = gdk_pixbuf_new_from_file_at_scale (thumb->priv->thumbnail_path, 128, 128, TRUE, NULL);
- gtk_widget_queue_draw (GTK_WIDGET (thumb));
-}
diff --git a/src/thumbnail.h b/src/thumbnail.h
deleted file mode 100644
index cd07599..0000000
--- a/src/thumbnail.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) Stephan Arts 2006-2010 <stephan at xfce.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Library General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef __RISTRETTO_THUMBNAIL_H__
-#define __RISTRETTO_THUMBNAIL_H__
-
-G_BEGIN_DECLS
-
-#define RSTTO_TYPE_THUMBNAIL rstto_thumbnail_get_type()
-
-#define RSTTO_THUMBNAIL(obj)( \
- G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- RSTTO_TYPE_THUMBNAIL, \
- RsttoThumbnail))
-
-#define RSTTO_IS_THUMBNAIL(obj)( \
- G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- RSTTO_TYPE_THUMBNAIL))
-
-#define RSTTO_THUMBNAIL_CLASS(klass)( \
- G_TYPE_CHECK_CLASS_CAST ((klass), \
- RSTTO_TYPE_THUMBNAIL, \
- RsttoThumbnailClass))
-
-#define RSTTO_IS_THUMBNAIL_CLASS(klass)( \
- G_TYPE_CHECK_CLASS_TYPE ((klass), \
- RSTTO_TYPE_THUMBNAIL()))
-
-typedef struct _RsttoThumbnailPriv RsttoThumbnailPriv;
-
-typedef struct _RsttoThumbnail RsttoThumbnail;
-
-struct _RsttoThumbnail
-{
- GtkButton parent;
- RsttoThumbnailPriv *priv;
- gboolean selected;
-};
-
-typedef struct _RsttoThumbnailClass RsttoThumbnailClass;
-
-struct _RsttoThumbnailClass
-{
- GtkButtonClass parent_class;
-};
-
-GType rstto_thumbnail_get_type();
-
-GtkWidget *rstto_thumbnail_new ( RsttoFile * );
-
-RsttoFile *
-rstto_thumbnail_get_file (RsttoThumbnail *thumb);
-
-
-void rstto_thumbnail_update (RsttoThumbnail *thumb);
-
-G_END_DECLS
-
-#endif /* __RISTRETTO_THUMBNAIL_H__ */
diff --git a/src/thumbnail_bar.c b/src/thumbnail_bar.c
deleted file mode 100644
index 1051bba..0000000
--- a/src/thumbnail_bar.c
+++ /dev/null
@@ -1,991 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Library General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <config.h>
-#include <gtk/gtk.h>
-#include <gtk/gtkmarshal.h>
-#include <string.h>
-
-#include <gio/gio.h>
-
-#include <libxfce4ui/libxfce4ui.h>
-#include <libexif/exif-data.h>
-
-#include "util.h"
-#include "file.h"
-#include "image_list.h"
-#include "thumbnail.h"
-#include "thumbnail_bar.h"
-#include "thumbnailer.h"
-
-struct _RsttoThumbnailBarPriv
-{
- GtkOrientation orientation;
- gint dimension;
- gint offset;
- gboolean auto_center;
- gint begin;
- gint end;
-
- RsttoImageList *image_list;
- RsttoImageListIter *iter;
- RsttoImageListIter *internal_iter;
- GList *thumbs;
- gint scroll_speed;
- struct
- {
- gdouble current_x;
- gdouble current_y;
- gint offset;
- gboolean motion;
- } motion;
-
- RsttoThumbnailer *thumbnailer;
-};
-
-static void
-rstto_thumbnail_bar_init(RsttoThumbnailBar *);
-static void
-rstto_thumbnail_bar_class_init(RsttoThumbnailBarClass *);
-
-static void
-rstto_thumbnail_bar_dispose (GObject *object);
-
-static void
-rstto_thumbnail_bar_size_request(GtkWidget *, GtkRequisition *);
-static void
-rstto_thumbnail_bar_size_allocate(GtkWidget *, GtkAllocation *);
-static gboolean
-rstto_thumbnail_bar_expose(GtkWidget *, GdkEventExpose *);
-static void
-rstto_thumbnail_bar_realize(GtkWidget *widget);
-static void
-rstto_thumbnail_bar_unrealize(GtkWidget *widget);
-
-static void
-cb_rstto_thumbnail_bar_image_list_new_file (
- RsttoImageList *image_list,
- RsttoFile *file,
- gpointer user_data);
-static void
-cb_rstto_thumbnail_bar_image_list_remove_file (
- RsttoImageList *image_list,
- RsttoFile *file,
- gpointer user_data);
-static void
-cb_rstto_thumbnail_bar_image_list_remove_all (RsttoImageList *image_list, gpointer user_data);
-void
-cb_rstto_thumbnail_bar_image_list_iter_changed (RsttoImageListIter *iter, gpointer user_data);
-
-static gboolean
-cb_rstto_thumbnail_bar_thumbnail_button_press_event (GtkWidget *thumb, GdkEventButton *event);
-static gboolean
-cb_rstto_thumbnail_bar_thumbnail_button_release_event (GtkWidget *thumb, GdkEventButton *event);
-static gboolean
-cb_rstto_thumbnail_bar_thumbnail_motion_notify_event (GtkWidget *thumb,
- GdkEventMotion *event,
- gpointer user_data);
-
-static gboolean
-cb_rstto_thumbnail_bar_scroll_event (RsttoThumbnailBar *bar,
- GdkEventScroll *event,
- gpointer *user_data);
-
-static void
-rstto_thumbnail_bar_add(GtkContainer *container, GtkWidget *child);
-static void
-rstto_thumbnail_bar_remove(GtkContainer *container, GtkWidget *child);
-static void
-rstto_thumbnail_bar_forall(GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data);
-static GType
-rstto_thumbnail_bar_child_type(GtkContainer *container);
-
-static GtkWidgetClass *parent_class = NULL;
-
-static void
-cb_rstto_thumbnail_bar_thumbnail_clicked (GtkWidget *thumb, RsttoThumbnailBar *bar);
-
-static gint
-cb_rstto_thumbnail_bar_compare (GtkWidget *a, GtkWidget *b, gpointer);
-
-GType
-rstto_thumbnail_bar_get_type (void)
-{
- static GType rstto_thumbnail_bar_type = 0;
-
- if (!rstto_thumbnail_bar_type)
- {
- static const GTypeInfo rstto_thumbnail_bar_info =
- {
- sizeof (RsttoThumbnailBarClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) rstto_thumbnail_bar_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof (RsttoThumbnailBar),
- 0,
- (GInstanceInitFunc) rstto_thumbnail_bar_init,
- NULL
- };
-
- rstto_thumbnail_bar_type = g_type_register_static (GTK_TYPE_CONTAINER, "RsttoThumbnailBar", &rstto_thumbnail_bar_info, 0);
- }
- return rstto_thumbnail_bar_type;
-}
-
-
-static void
-rstto_thumbnail_bar_init(RsttoThumbnailBar *bar)
-{
- RsttoThumbnailBarPriv *priv;
-
- priv = G_TYPE_INSTANCE_GET_PRIVATE (
- bar,
- RSTTO_TYPE_THUMBNAIL_BAR,
- RsttoThumbnailBarPriv);
-
- bar->priv = priv;
-
- bar->priv->auto_center = TRUE;
- bar->priv->thumbnailer = rstto_thumbnailer_new();
-
- GTK_WIDGET_UNSET_FLAGS(bar, GTK_NO_WINDOW);
- gtk_widget_set_redraw_on_allocate(GTK_WIDGET(bar), TRUE);
- gtk_widget_set_events (GTK_WIDGET(bar),
- GDK_SCROLL_MASK);
-
- bar->priv->orientation = GTK_ORIENTATION_VERTICAL;
- bar->priv->offset = 0;
- bar->priv->scroll_speed = 20;
-
-
- g_signal_connect(G_OBJECT(bar), "scroll_event", G_CALLBACK(cb_rstto_thumbnail_bar_scroll_event), NULL);
-
-}
-
-static void
-rstto_thumbnail_bar_class_init(RsttoThumbnailBarClass *bar_class)
-{
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
-
- GObjectClass *object_class = (GObjectClass*)bar_class;
-
- widget_class = (GtkWidgetClass*)bar_class;
- container_class = (GtkContainerClass*)bar_class;
-
- parent_class = g_type_class_peek_parent(bar_class);
-
- object_class->dispose = rstto_thumbnail_bar_dispose;
-
- widget_class->size_request = rstto_thumbnail_bar_size_request;
- widget_class->size_allocate = rstto_thumbnail_bar_size_allocate;
- widget_class->expose_event = rstto_thumbnail_bar_expose;
- widget_class->realize = rstto_thumbnail_bar_realize;
- widget_class->unrealize = rstto_thumbnail_bar_unrealize;
-
- container_class->add = rstto_thumbnail_bar_add;
- container_class->remove = rstto_thumbnail_bar_remove;
- container_class->forall = rstto_thumbnail_bar_forall;
- container_class->child_type = rstto_thumbnail_bar_child_type;
-
- gtk_widget_class_install_style_property (widget_class,
- g_param_spec_int ("spacing",
- _("Spacing"),
- _("The amount of space between the thumbnails"),
- 0, G_MAXINT, 3,
- G_PARAM_READABLE));
-
- gtk_widget_class_install_style_property (widget_class,
- g_param_spec_int ("border-width",
- _("border width"),
- _("the border width of the thumbnail bar"),
- 0, G_MAXINT, 0,
- G_PARAM_READABLE));
-
- g_type_class_add_private (bar_class, sizeof (RsttoThumbnailBarPriv));
-}
-
-
-static void
-rstto_thumbnail_bar_dispose (GObject *object)
-{
- RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR (object);
-
- if (bar->priv)
- {
- if (bar->priv->image_list)
- {
- g_object_unref (bar->priv->image_list);
- bar->priv->image_list = NULL;
- }
-
- if (bar->priv->thumbnailer)
- {
- g_object_unref (bar->priv->thumbnailer);
- bar->priv->thumbnailer = NULL;
- }
- }
-
- G_OBJECT_CLASS (parent_class)->dispose(object);
-}
-
-static void
-rstto_thumbnail_bar_size_request(GtkWidget *widget, GtkRequisition *requisition)
-{
- RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR(widget);
- gint border_width;
- GList *iter;
- GtkRequisition child_requisition;
-
- gtk_widget_style_get (widget, "border-width", &border_width, NULL);
-
- requisition->height = 70;
- requisition->width = 70;
-
- for(iter = bar->priv->thumbs; iter; iter = g_list_next(iter))
- {
- gtk_widget_size_request(GTK_WIDGET(iter->data), &child_requisition);
- requisition->width = MAX(child_requisition.width, requisition->width);
- requisition->height = MAX(child_requisition.height, requisition->height);
- }
-
- switch (bar->priv->orientation)
- {
- case GTK_ORIENTATION_HORIZONTAL:
- requisition->height += (border_width * 2);
- requisition->width += (border_width * 2);
- break;
- case GTK_ORIENTATION_VERTICAL:
- requisition->height += (border_width * 2);
- requisition->width += (border_width * 2);
- break;
- }
-
- widget->requisition = *requisition;
- GTK_CONTAINER(bar)->border_width = border_width;
-}
-
-static void
-rstto_thumbnail_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
-{
- RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR(widget);
- gint border_width = GTK_CONTAINER(bar)->border_width;
- gint spacing = 0;
- GtkAllocation child_allocation;
- GtkRequisition child_requisition;
- GList *iter = bar->priv->thumbs;
-
- gtk_widget_style_get(widget, "spacing", &spacing, NULL);
- widget->allocation = *allocation;
-
- child_allocation.x = border_width;
- child_allocation.y = border_width;
- child_allocation.height = border_width * 2;
- child_allocation.width = border_width * 2;
-
-
- if (GTK_WIDGET_REALIZED(widget))
- {
- gdk_window_move_resize (widget->window,
- allocation->x,
- allocation->y,
- allocation->width,
- allocation->height);
- }
-
-
- switch(bar->priv->orientation)
- {
- case GTK_ORIENTATION_HORIZONTAL:
- if (bar->priv->auto_center == TRUE)
- {
- bar->priv->offset = 0 - (allocation->width / 2);
- }
- while(iter)
- {
- gtk_widget_get_child_requisition(GTK_WIDGET(iter->data), &child_requisition);
- allocation->height = MAX(child_requisition.height + (border_width * 2), allocation->height);
-
- if (bar->priv->auto_center == TRUE)
- {
- if (g_list_position (bar->priv->thumbs, iter) < rstto_image_list_iter_get_position (bar->priv->iter))
- {
- bar->priv->offset += allocation->height + spacing;
- }
- if (g_list_position (bar->priv->thumbs, iter) == rstto_image_list_iter_get_position (bar->priv->iter))
- {
- bar->priv->offset += 0.5 * allocation->height;
- }
- }
-
- iter = g_list_next(iter);
- }
-
- child_allocation.x -= bar->priv->offset;
-
- iter = bar->priv->thumbs;
-
- while(iter)
- {
- gtk_widget_get_child_requisition(GTK_WIDGET(iter->data), &child_requisition);
- child_allocation.height = allocation->height - (border_width * 2);
- child_allocation.width = child_allocation.height;
-
- if ((child_allocation.x < (allocation->x + allocation->width)) &&
- ((child_allocation.x + child_allocation.width) > allocation->x + border_width))
- {
- gtk_widget_set_child_visible(GTK_WIDGET(iter->data), TRUE);
- gtk_widget_size_allocate(GTK_WIDGET(iter->data), &child_allocation);
-
- /* Do thumbnailing stuff */
- rstto_thumbnailer_queue_thumbnail (bar->priv->thumbnailer, iter->data);
- }
- else
- {
- gtk_widget_set_child_visible(GTK_WIDGET(iter->data), FALSE);
-
- rstto_thumbnailer_dequeue_thumbnail (bar->priv->thumbnailer, iter->data);
- }
-
- child_allocation.x += child_allocation.width + spacing;
- iter = g_list_next(iter);
- }
- break;
- case GTK_ORIENTATION_VERTICAL:
- if (bar->priv->auto_center == TRUE)
- {
- bar->priv->offset = 0 - (allocation->height / 2);
- }
- while(iter)
- {
- gtk_widget_get_child_requisition(GTK_WIDGET(iter->data), &child_requisition);
- allocation->width = MAX(child_requisition.width + (border_width * 2), allocation->width);
-
- if (bar->priv->auto_center == TRUE)
- {
- if (g_list_position (bar->priv->thumbs, iter) < rstto_image_list_iter_get_position (bar->priv->iter))
- {
- bar->priv->offset += allocation->width + spacing;
- }
- if (g_list_position (bar->priv->thumbs, iter) == rstto_image_list_iter_get_position (bar->priv->iter))
- {
- bar->priv->offset += 0.5 * allocation->width;
- }
- }
-
- iter = g_list_next(iter);
- }
-
- child_allocation.y -= bar->priv->offset;
-
- iter = bar->priv->thumbs;
-
- while(iter)
- {
-
- gtk_widget_get_child_requisition(GTK_WIDGET(iter->data), &child_requisition);
- child_allocation.width = allocation->width - (border_width * 2);
- child_allocation.height = child_allocation.width;
-
- if (child_allocation.y < (allocation->y + allocation->height))
- {
- gtk_widget_set_child_visible(GTK_WIDGET(iter->data), TRUE);
- gtk_widget_size_allocate(GTK_WIDGET(iter->data), &child_allocation);
-
- /* Do thumbnailing stuff */
- rstto_thumbnailer_queue_thumbnail (bar->priv->thumbnailer, iter->data);
- }
- else
- {
- gtk_widget_set_child_visible(GTK_WIDGET(iter->data), FALSE);
- rstto_thumbnailer_dequeue_thumbnail (bar->priv->thumbnailer, iter->data);
- }
-
- gtk_widget_size_allocate(GTK_WIDGET(iter->data), &child_allocation);
- child_allocation.y += child_allocation.height + spacing;
- iter = g_list_next(iter);
- }
- break;
- }
-}
-
-static gboolean
-rstto_thumbnail_bar_expose(GtkWidget *widget, GdkEventExpose *ex)
-{
- RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR(widget);
-
- GList *iter = bar->priv->thumbs;
-
- GdkEventExpose *n_ex = g_new0(GdkEventExpose, 1);
-
- GdkGC *gc = gdk_gc_new(GDK_DRAWABLE(widget->window));
- gint border_width = GTK_CONTAINER(bar)->border_width;
- GdkColor color, dot_color, bar_color;
- color.red= 0;
- color.green= 0;
- color.blue= 0;
- dot_color.red = 0xffff;
- dot_color.green = 0xffff;
- dot_color.blue = 0xffff;
- bar_color.red = 0x4444;
- bar_color.green = 0x4444;
- bar_color.blue = 0x4444;
-
- n_ex->type = ex->type;
- n_ex->window = ex->window;
- n_ex->send_event = ex->send_event;
- n_ex->area.x = border_width;
- n_ex->area.y = border_width;
- n_ex->area.width = ex->area.width;
- n_ex->area.height = ex->area.height;
- n_ex->count = ex->count;
-
- gdk_colormap_alloc_color (gdk_gc_get_colormap (gc), &color, FALSE, TRUE);
- gdk_colormap_alloc_color (gdk_gc_get_colormap (gc), &dot_color, FALSE, TRUE);
- gdk_colormap_alloc_color (gdk_gc_get_colormap (gc), &bar_color, FALSE, TRUE);
- gdk_gc_set_rgb_fg_color (gc, &color);
-
- while(iter)
- {
-
- if (GTK_WIDGET_VISIBLE(iter->data) == TRUE)
- {
- switch (bar->priv->orientation)
- {
- case GTK_ORIENTATION_HORIZONTAL:
- /* why are these widgets not filtered out with the GTK_WIDGET_VISIBLE macro?*/
- if (GTK_WIDGET(iter->data)->allocation.x > GTK_WIDGET(bar)->allocation.width)
- break;
- if ((GTK_WIDGET(iter->data)->allocation.x + GTK_WIDGET(iter->data)->allocation.width) < 0)
- break;
-
- /* first (partially) visible thumbnail */
- if (GTK_WIDGET(iter->data)->allocation.x < 0)
- {
- n_ex->area.x = 0;
- n_ex->area.width = GTK_WIDGET(iter->data)->allocation.width;
- }
- else
- {
- /* last (partially) visible thumbnail */
- if ((GTK_WIDGET(bar)->allocation.x + (GTK_WIDGET(bar)->allocation.width)) <
- (GTK_WIDGET(iter->data)->allocation.x + GTK_WIDGET(iter->data)->allocation.width))
- {
- n_ex->area.x = GTK_WIDGET(iter->data)->allocation.x;
- n_ex->area.width = GTK_WIDGET(bar)->allocation.x + GTK_WIDGET(bar)->allocation.width - n_ex->area.x;
- }
- else
- {
- /* everything in between */
- n_ex->area.x = GTK_WIDGET(iter->data)->allocation.x;
- n_ex->area.width = GTK_WIDGET(bar)->allocation.width - n_ex->area.x;
- }
-
- }
- if (n_ex->region)
- gdk_region_destroy(n_ex->region);
- n_ex->region = gdk_region_rectangle(&(n_ex->area));
- gtk_container_propagate_expose(GTK_CONTAINER(widget), GTK_WIDGET(iter->data), n_ex);
- break;
- case GTK_ORIENTATION_VERTICAL:
- /* why are these widgets not filtered out with the GTK_WIDGET_VISIBLE macro?*/
- if (GTK_WIDGET(iter->data)->allocation.y > GTK_WIDGET(bar)->allocation.height)
- break;
- if ((GTK_WIDGET(iter->data)->allocation.y + GTK_WIDGET(iter->data)->allocation.height) < 0 )
- break;
-
- /* first (partially) visible thumbnail */
- if (GTK_WIDGET(iter->data)->allocation.y < 0)
- {
- n_ex->area.y = 0;
- n_ex->area.height = GTK_WIDGET(iter->data)->allocation.height;
- }
- else
- {
- /* last (partially) visible thumbnail */
- if ((GTK_WIDGET(bar)->allocation.y + (GTK_WIDGET(bar)->allocation.height)) <
- (GTK_WIDGET(iter->data)->allocation.y + GTK_WIDGET(iter->data)->allocation.height))
- {
- n_ex->area.y = GTK_WIDGET(iter->data)->allocation.y;
- n_ex->area.height = GTK_WIDGET(bar)->allocation.y + GTK_WIDGET(bar)->allocation.height - n_ex->area.y;
- }
- else
- {
- /* everything in between */
- n_ex->area.y = GTK_WIDGET(iter->data)->allocation.y;
- n_ex->area.height = GTK_WIDGET(bar)->allocation.height - n_ex->area.y;
- }
-
- }
- if (n_ex->region)
- gdk_region_destroy(n_ex->region);
- n_ex->region = gdk_region_rectangle(&(n_ex->area));
- gtk_container_propagate_expose(GTK_CONTAINER(widget), GTK_WIDGET(iter->data), n_ex);
- break;
- }
- }
- iter = g_list_next(iter);
- }
-
- return FALSE;
-}
-
-static void
-rstto_thumbnail_bar_realize(GtkWidget *widget)
-{
- RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR(widget);
-
- GdkWindowAttr attributes;
- gint attributes_mask;
- gint border_width = 0;
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
-
- attributes.x = widget->allocation.x + border_width;
- attributes.y = widget->allocation.y + border_width;
- attributes.width = widget->allocation.width - border_width * 2;
- attributes.height = widget->allocation.height - border_width * 2;
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
- attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK;
-
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, bar);
-
- attributes.x = 0;
- attributes.y = 0;
- widget->style = gtk_style_attach (widget->style, widget->window);
- gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
-}
-
-static void
-rstto_thumbnail_bar_unrealize(GtkWidget *widget)
-{
-
- if (GTK_WIDGET_CLASS (parent_class)->unrealize)
- (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
-
-}
-
-GtkWidget *
-rstto_thumbnail_bar_new (RsttoImageList *nav)
-{
- RsttoThumbnailBar *bar;
-
- bar = g_object_new(RSTTO_TYPE_THUMBNAIL_BAR, NULL);
-
- rstto_thumbnail_bar_set_image_list (bar, nav);
-
- return (GtkWidget *)bar;
-}
-
-void
-rstto_thumbnail_bar_set_image_list (RsttoThumbnailBar *bar, RsttoImageList *nav)
-{
- if (bar->priv->image_list)
- {
- g_object_unref (bar->priv->image_list);
- bar->priv->image_list = NULL;
- }
-
- bar->priv->image_list = nav;
-
- if (bar->priv->image_list)
- {
- g_signal_connect (G_OBJECT (bar->priv->image_list), "new-image", G_CALLBACK (cb_rstto_thumbnail_bar_image_list_new_file), bar);
- g_signal_connect (G_OBJECT (bar->priv->image_list), "remove-image", G_CALLBACK (cb_rstto_thumbnail_bar_image_list_remove_file), bar);
- g_signal_connect (G_OBJECT (bar->priv->image_list), "remove-all", G_CALLBACK (cb_rstto_thumbnail_bar_image_list_remove_all), bar);
- g_object_ref (nav);
- }
-}
-/*
- * rstto_thumbnail_bar_set_orientation:
- *
- * @bar : ThumbnailBar
- * @orientation :
- *
- */
-void
-rstto_thumbnail_bar_set_orientation (RsttoThumbnailBar *bar, GtkOrientation orientation)
-{
- bar->priv->orientation = orientation;
-}
-
-/*
- * rstto_thumbnail_bar_get_orientation:
- *
- * @bar : ThumbnailBar
- *
- * Return value : GtkOrientation
- *
- */
-GtkOrientation
-rstto_thumbnail_bar_get_orientation (RsttoThumbnailBar *bar)
-{
- return bar->priv->orientation;
-}
-
-static void
-rstto_thumbnail_bar_add(GtkContainer *container, GtkWidget *child)
-{
- RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR(container);
- g_return_if_fail(GTK_IS_WIDGET(child));
-
- gtk_widget_set_parent(child, GTK_WIDGET(container));
-
- bar->priv->thumbs = g_list_insert_sorted_with_data (bar->priv->thumbs, child, (GCompareDataFunc)cb_rstto_thumbnail_bar_compare, bar);
-}
-
-static void
-rstto_thumbnail_bar_remove(GtkContainer *container, GtkWidget *child)
-{
- RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR(container);
- gboolean widget_was_visible;
-
- g_return_if_fail(GTK_IS_WIDGET(child));
-
-
- widget_was_visible = GTK_WIDGET_VISIBLE(child);
-
- /* Check if there still is a thumbnailer present */
- if (NULL != bar->priv->thumbnailer)
- {
- rstto_thumbnailer_dequeue_thumbnail (bar->priv->thumbnailer, RSTTO_THUMBNAIL(child));
- }
-
- bar->priv->thumbs = g_list_remove(bar->priv->thumbs, child);
-
- gtk_widget_unparent(child);
-
- /* remove from list is somewhere else */
- if(widget_was_visible)
- gtk_widget_queue_resize(GTK_WIDGET(container));
-}
-
-static void
-rstto_thumbnail_bar_forall (
- GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data )
-{
- RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR(container);
-
- g_return_if_fail(callback != NULL);
-
- g_list_foreach(bar->priv->thumbs, (GFunc)callback, callback_data);
-}
-
-static GType
-rstto_thumbnail_bar_child_type(GtkContainer *container)
-{
- return GTK_TYPE_WIDGET;
-}
-
-
-static gint
-cb_rstto_thumbnail_bar_compare (GtkWidget *a, GtkWidget *b, gpointer user_data)
-{
- RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR (user_data);
- RsttoFile *a_i = rstto_thumbnail_get_file (RSTTO_THUMBNAIL (a));
- RsttoFile *b_i = rstto_thumbnail_get_file (RSTTO_THUMBNAIL (b));
-
- return rstto_image_list_get_compare_func (bar->priv->image_list) (a_i, b_i);
-}
-
-static gboolean
-cb_rstto_thumbnail_bar_thumbnail_button_press_event (GtkWidget *thumb, GdkEventButton *event)
-{
- if(event->button == 1)
- {
- RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR(gtk_widget_get_parent(GTK_WIDGET(thumb)));
-
- bar->priv->motion.offset = bar->priv->offset;
- if (bar->priv->orientation == GTK_ORIENTATION_HORIZONTAL)
- {
- gdouble x = event->x + GTK_WIDGET(thumb)->allocation.x;
- bar->priv->motion.current_x = x;
- }
- else
- {
- gdouble y = event->y + GTK_WIDGET(thumb)->allocation.y;
- bar->priv->motion.current_y = y;
- }
- }
-
- return FALSE;
-}
-
-static gboolean
-cb_rstto_thumbnail_bar_thumbnail_button_release_event (GtkWidget *thumb, GdkEventButton *event)
-{
- RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR(gtk_widget_get_parent(GTK_WIDGET(thumb)));
- if(event->button == 1)
- {
- GtkWidget *widget = GTK_WIDGET(thumb);
- gdk_window_set_cursor(widget->window, NULL);
- if (bar->priv->motion.motion == TRUE)
- {
- bar->priv->motion.motion = FALSE;
- return TRUE;
- }
- }
- return FALSE;
-}
-
-static gboolean
-cb_rstto_thumbnail_bar_thumbnail_motion_notify_event (GtkWidget *thumb,
- GdkEventMotion *event,
- gpointer user_data)
-{
- RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR(gtk_widget_get_parent(GTK_WIDGET(thumb)));
- gdouble x = event->x + GTK_WIDGET(thumb)->allocation.x;
- gdouble y = event->y + GTK_WIDGET(thumb)->allocation.y;
- gint thumb_size = GTK_WIDGET(bar->priv->thumbs->data)->allocation.width;
- gint border_width = 0;
- gint spacing;
- gint size = 0;
-
- gtk_widget_style_get(GTK_WIDGET (bar), "spacing", &spacing, NULL);
- size = thumb_size * g_list_length (bar->priv->thumbs) + spacing * (g_list_length (bar->priv->thumbs) - 1);
-
- if (event->state & GDK_BUTTON1_MASK)
- {
- GtkWidget *widget = GTK_WIDGET(thumb);
- GdkCursor *cursor = gdk_cursor_new(GDK_FLEUR);
- gdk_window_set_cursor(widget->window, cursor);
- gdk_cursor_unref(cursor);
-
- bar->priv->motion.motion = TRUE;
- bar->priv->auto_center = FALSE;
- if (bar->priv->orientation == GTK_ORIENTATION_HORIZONTAL)
- {
- bar->priv->offset = bar->priv->motion.offset + (bar->priv->motion.current_x - x);
- if ((thumb_size - GTK_WIDGET(bar)->allocation.width) >= bar->priv->offset)
- bar->priv->offset = thumb_size - GTK_WIDGET(bar)->allocation.width + border_width;
- if ((size - thumb_size) <= bar->priv->offset)
- bar->priv->offset = size - thumb_size;
- }
- else
- {
- bar->priv->offset = bar->priv->motion.offset + (bar->priv->motion.current_y - y);
- if ((thumb_size - GTK_WIDGET(bar)->allocation.height) >= bar->priv->offset)
- bar->priv->offset = thumb_size - GTK_WIDGET(bar)->allocation.height + border_width;
- if ((size - thumb_size) <= bar->priv->offset)
- bar->priv->offset = size - thumb_size;
- }
-
-
- bar->priv->motion.offset = bar->priv->offset;
- bar->priv->motion.current_x = x;
- bar->priv->motion.current_y = y;
- gtk_widget_queue_resize(GTK_WIDGET(bar));
- }
- return FALSE;
-}
-
-static gboolean
-cb_rstto_thumbnail_bar_scroll_event (RsttoThumbnailBar *bar,
- GdkEventScroll *event,
- gpointer *user_data)
-{
- gint thumb_size;
- GList *thumb;
- gint border_width = GTK_CONTAINER(bar)->border_width;
- gint spacing = 0;
- GtkWidget *widget = GTK_WIDGET (bar);
-
- gtk_widget_style_get(widget, "spacing", &spacing, NULL);
-
- switch(event->direction)
- {
- case GDK_SCROLL_UP:
- case GDK_SCROLL_LEFT:
- if (bar->priv->thumbs)
- {
- bar->priv->auto_center = FALSE;
- bar->priv->offset -= bar->priv->scroll_speed;
- switch(bar->priv->orientation)
- {
- case GTK_ORIENTATION_HORIZONTAL:
- thumb_size = GTK_WIDGET(bar->priv->thumbs->data)->allocation.width;
- if ((thumb_size - GTK_WIDGET(bar)->allocation.width) >= bar->priv->offset)
- bar->priv->offset = thumb_size - GTK_WIDGET(bar)->allocation.width + border_width;
- break;
- case GTK_ORIENTATION_VERTICAL:
- thumb_size = GTK_WIDGET(bar->priv->thumbs->data)->allocation.height;
- if ((thumb_size - GTK_WIDGET(bar)->allocation.height) >= bar->priv->offset)
- bar->priv->offset = thumb_size - GTK_WIDGET(bar)->allocation.height + border_width;
- break;
- }
- }
- break;
- case GDK_SCROLL_DOWN:
- case GDK_SCROLL_RIGHT:
- if (bar->priv->thumbs)
- {
- gint size = 0;
- bar->priv->auto_center = FALSE;
- bar->priv->offset += bar->priv->scroll_speed;
- switch(bar->priv->orientation)
- {
- case GTK_ORIENTATION_HORIZONTAL:
- thumb_size = GTK_WIDGET(bar->priv->thumbs->data)->allocation.width;
- for (thumb = bar->priv->thumbs; thumb != NULL; thumb = g_list_next(thumb))
- {
- size += GTK_WIDGET(thumb->data)->allocation.width;
- if (g_list_next (thumb))
- size += spacing;
- }
- if ((size - thumb_size) <= bar->priv->offset)
- bar->priv->offset = size - thumb_size;
- break;
- case GTK_ORIENTATION_VERTICAL:
- thumb_size = GTK_WIDGET(bar->priv->thumbs->data)->allocation.height;
- for (thumb = bar->priv->thumbs; thumb != NULL; thumb = g_list_next(thumb))
- {
- size += GTK_WIDGET(thumb->data)->allocation.height;
- if (g_list_next (thumb))
- size += spacing;
- }
- if ((size - thumb_size) <= bar->priv->offset)
- bar->priv->offset = size - thumb_size;
- break;
- }
- }
- break;
- }
- gtk_widget_queue_resize(GTK_WIDGET(bar));
- return FALSE;
-
-}
-
-void
-rstto_thumbnail_bar_set_iter (RsttoThumbnailBar *bar, RsttoImageListIter *iter)
-{
- if (bar->priv->iter)
- {
- g_signal_handlers_disconnect_by_func (bar->priv->iter, cb_rstto_thumbnail_bar_image_list_iter_changed, bar);
-
- g_object_unref (bar->priv->iter);
- g_object_unref (bar->priv->internal_iter);
- bar->priv->internal_iter = NULL;
- }
-
- bar->priv->iter = iter;
-
- if (bar->priv->iter)
- {
- g_object_ref (bar->priv->iter);
- bar->priv->internal_iter = rstto_image_list_iter_clone (bar->priv->iter);
- g_signal_connect (bar->priv->iter, "changed", G_CALLBACK (cb_rstto_thumbnail_bar_image_list_iter_changed), bar);
- }
-}
-
-void
-cb_rstto_thumbnail_bar_image_list_iter_changed (RsttoImageListIter *iter, gpointer user_data)
-{
- RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR (user_data);
-
- bar->priv->thumbs = g_list_sort_with_data (bar->priv->thumbs, (GCompareDataFunc)cb_rstto_thumbnail_bar_compare, bar);
- bar->priv->auto_center = TRUE;
-
- gtk_widget_queue_resize(GTK_WIDGET(bar));
- /* useless, but keepsthe compiler silent */
- bar->priv->begin=0;
-}
-
-static void
-cb_rstto_thumbnail_bar_image_list_new_file (
- RsttoImageList *image_list,
- RsttoFile *file,
- gpointer user_data)
-{
- RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR (user_data);
- GtkWidget *thumb;
- GList *iter;
-
- g_return_if_fail (rstto_image_list_iter_find_file (bar->priv->internal_iter, file));
-
- for (iter = bar->priv->thumbs; iter != NULL; iter = g_list_next (iter))
- {
- if (rstto_file_equal(file,rstto_thumbnail_get_file (iter->data)))
- return;
- }
-
- thumb = rstto_thumbnail_new (file);
-
- gtk_container_add (GTK_CONTAINER (bar), thumb);
- gtk_widget_show_all (thumb);
-
- g_signal_connect (thumb, "clicked", G_CALLBACK (cb_rstto_thumbnail_bar_thumbnail_clicked), bar);
- g_signal_connect (thumb, "button_press_event", G_CALLBACK (cb_rstto_thumbnail_bar_thumbnail_button_press_event), bar);
- g_signal_connect (thumb, "button_release_event", G_CALLBACK (cb_rstto_thumbnail_bar_thumbnail_button_release_event), bar);
- g_signal_connect (thumb, "motion_notify_event", G_CALLBACK (cb_rstto_thumbnail_bar_thumbnail_motion_notify_event), bar);
-}
-
-static void
-cb_rstto_thumbnail_bar_image_list_remove_file (
- RsttoImageList *image_list,
- RsttoFile *file,
- gpointer user_data )
-{
- RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR (user_data);
- GList *iter = bar->priv->thumbs;
-
- while (iter)
- {
- if (rstto_file_equal(rstto_thumbnail_get_file(iter->data), file))
- {
- GtkWidget *widget = iter->data;
- gtk_container_remove (GTK_CONTAINER (bar), widget);
- break;
- }
- iter = g_list_next (iter);
- }
-}
-
-static void
-cb_rstto_thumbnail_bar_image_list_remove_all (RsttoImageList *image_list, gpointer user_data)
-{
- RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR (user_data);
- if (bar->priv->thumbs)
- {
- g_list_foreach (bar->priv->thumbs, (GFunc)(gtk_widget_destroy), NULL);
- g_list_free (bar->priv->thumbs);
- bar->priv->thumbs = NULL;
- }
-}
-
-
-
-static void
-cb_rstto_thumbnail_bar_thumbnail_clicked (GtkWidget *thumb, RsttoThumbnailBar *bar)
-{
- RsttoFile *file;
-
- g_return_if_fail (bar->priv->iter);
-
- file = rstto_thumbnail_get_file (RSTTO_THUMBNAIL(thumb));
- rstto_image_list_iter_find_file (bar->priv->iter, file);
-}
diff --git a/src/thumbnail_bar.h b/src/thumbnail_bar.h
deleted file mode 100644
index 11e847b..0000000
--- a/src/thumbnail_bar.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Library General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef __RISTRETTO_THUMBNAIL_BAR_H__
-#define __RISTRETTO_THUMBNAIL_BAR_H__
-
-G_BEGIN_DECLS
-
-#define RSTTO_TYPE_THUMBNAIL_BAR rstto_thumbnail_bar_get_type()
-
-#define RSTTO_THUMBNAIL_BAR(obj)( \
- G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- RSTTO_TYPE_THUMBNAIL_BAR, \
- RsttoThumbnailBar))
-
-#define RSTTO_IS_THUMBNAIL_BAR(obj)( \
- G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- RSTTO_TYPE_THUMBNAIL_BAR))
-
-#define RSTTO_THUMBNAIL_BAR_CLASS(klass)( \
- G_TYPE_CHECK_CLASS_CAST ((klass), \
- RSTTO_TYPE_THUMBNAIL_BAR, \
- RsttoThumbnailBarClass))
-
-#define RSTTO_IS_THUMBNAIL_BAR_CLASS(klass)( \
- G_TYPE_CHECK_CLASS_TYPE ((klass), \
- RSTTO_TYPE_THUMBNAIL_BAR()))
-
-typedef struct _RsttoThumbnailBarPriv RsttoThumbnailBarPriv;
-
-typedef struct _RsttoThumbnailBar RsttoThumbnailBar;
-
-struct _RsttoThumbnailBar
-{
- GtkContainer parent;
- RsttoThumbnailBarPriv *priv;
- gint film_border_width;
-};
-
-typedef struct _RsttoThumbnailBarClass RsttoThumbnailBarClass;
-
-struct _RsttoThumbnailBarClass
-{
- GtkContainerClass parent_class;
-};
-
-GType rstto_thumbnail_bar_get_type();
-
-GtkWidget *rstto_thumbnail_bar_new();
-
-void rstto_thumbnail_bar_set_orientation (RsttoThumbnailBar *, GtkOrientation);
-GtkOrientation rstto_thumbnail_bar_get_orientation (RsttoThumbnailBar *);
-
-void rstto_thumbnail_bar_set_image_list (RsttoThumbnailBar *bar, RsttoImageList *nav);
-void rstto_thumbnail_bar_set_iter (RsttoThumbnailBar *bar, RsttoImageListIter *iter);
-
-G_END_DECLS
-
-#endif /* __RISTRETTO_THUMBNAIL_BAR_H__ */
diff --git a/src/thumbnailer.c b/src/thumbnailer.c
index bbb37ce..a6a1a11 100644
--- a/src/thumbnailer.c
+++ b/src/thumbnailer.c
@@ -32,7 +32,6 @@
#include "util.h"
#include "file.h"
#include "settings.h"
-#include "thumbnail.h"
#include "thumbnailer.h"
#include "marshal.h"
@@ -286,13 +285,13 @@ rstto_thumbnailer_get_property (
}
void
-rstto_thumbnailer_queue_thumbnail (
+rstto_thumbnailer_queue_file (
RsttoThumbnailer *thumbnailer,
- RsttoThumbnail *thumb)
+ RsttoFile *file )
{
g_return_if_fail ( RSTTO_IS_THUMBNAILER (thumbnailer) );
- g_return_if_fail ( RSTTO_IS_THUMBNAIL (thumb) );
+ g_return_if_fail ( RSTTO_IS_FILE (file) );
if (thumbnailer->priv->request_timer_id)
{
@@ -310,12 +309,12 @@ rstto_thumbnailer_queue_thumbnail (
}
}
- if (g_slist_find (thumbnailer->priv->queue, thumb) == NULL)
+ if (g_slist_find (thumbnailer->priv->queue, file) == NULL)
{
- g_object_ref (thumb);
+ g_object_ref (file);
thumbnailer->priv->queue = g_slist_prepend (
thumbnailer->priv->queue,
- thumb);
+ file);
}
thumbnailer->priv->request_timer_id = g_timeout_add_full (
@@ -327,13 +326,13 @@ rstto_thumbnailer_queue_thumbnail (
}
void
-rstto_thumbnailer_dequeue_thumbnail (
+rstto_thumbnailer_dequeue_file (
RsttoThumbnailer *thumbnailer,
- RsttoThumbnail *thumb)
+ RsttoFile *file)
{
g_return_if_fail ( RSTTO_IS_THUMBNAILER (thumbnailer) );
- g_return_if_fail ( RSTTO_IS_THUMBNAIL (thumb) );
+ g_return_if_fail ( RSTTO_IS_FILE (file) );
if (thumbnailer->priv->request_timer_id)
{
@@ -351,12 +350,12 @@ rstto_thumbnailer_dequeue_thumbnail (
}
}
- if (g_slist_find (thumbnailer->priv->queue, thumb) != NULL)
+ if (g_slist_find (thumbnailer->priv->queue, file) != NULL)
{
thumbnailer->priv->queue = g_slist_remove_all (
thumbnailer->priv->queue,
- thumb);
- g_object_unref (thumb);
+ file);
+ g_object_unref (file);
}
thumbnailer->priv->request_timer_id = g_timeout_add_full (
@@ -394,7 +393,7 @@ rstto_thumbnailer_queue_request_timer (
{
if (iter->data)
{
- file = rstto_thumbnail_get_file (RSTTO_THUMBNAIL(iter->data));
+ file = RSTTO_FILE(iter->data);
uris[i] = rstto_file_get_uri (file);
mimetypes[i] = rstto_file_get_content_type (file);
}
@@ -491,7 +490,6 @@ cb_rstto_thumbnailer_thumbnail_ready (
gpointer data)
{
RsttoThumbnailer *thumbnailer = RSTTO_THUMBNAILER (data);
- RsttoThumbnail *thumbnail;
RsttoFile *file;
GSList *iter = thumbnailer->priv->queue;
gint x = 0;
@@ -506,16 +504,14 @@ cb_rstto_thumbnailer_thumbnail_ready (
break;
}
- thumbnail = iter->data;
- file = rstto_thumbnail_get_file (thumbnail);
+ file = RSTTO_FILE (iter->data);
f_uri = rstto_file_get_uri (file);
if (strcmp (uri[x], f_uri) == 0)
{
- rstto_thumbnail_update (thumbnail);
thumbnailer->priv->queue = g_slist_remove (
thumbnailer->priv->queue,
- iter->data);
- g_object_unref (thumbnail);
+ file);
+ g_object_unref (file);
iter = thumbnailer->priv->queue;
x++;
diff --git a/src/thumbnailer.h b/src/thumbnailer.h
index 35d8d58..3cc91c4 100644
--- a/src/thumbnailer.h
+++ b/src/thumbnailer.h
@@ -66,13 +66,14 @@ GType
rstto_thumbnailer_get_type (void);
void
-rstto_thumbnailer_queue_thumbnail (
+rstto_thumbnailer_queue_file (
RsttoThumbnailer *thumbnailer,
- RsttoThumbnail *thumb);
+ RsttoFile *file);
void
-rstto_thumbnailer_dequeue_thumbnail (
+rstto_thumbnailer_dequeue_file (
RsttoThumbnailer *thumbnailer,
- RsttoThumbnail *thumb);
+ RsttoFile *file );
+
G_END_DECLS
#endif /* __RISTRETTO_THUMBNAILER_H__ */
More information about the Xfce4-commits
mailing list