[Xfce4-commits] <ristretto:ristretto-0.0> Rename Navigator to ImageList, makes more sense
Stephan Arts
noreply at xfce.org
Sun Oct 23 19:16:06 CEST 2011
Updating branch refs/heads/ristretto-0.0
to c6b2411bd4c96a227b8b46b80012e98639a417a1 (commit)
from 61955d3c7a4e42a5de0e19ef738a9db9faa52b82 (commit)
commit c6b2411bd4c96a227b8b46b80012e98639a417a1
Author: Stephan Arts <stephan at xfce.org>
Date: Sun May 31 23:52:38 2009 +0200
Rename Navigator to ImageList, makes more sense
src/Makefile.am | 4 +-
src/image_list.c | 456 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/image_list.h | 119 +++++++++++++
src/main.c | 12 +-
src/main_window.c | 216 +++++++++++-------------
src/main_window.h | 2 +-
src/navigator.c | 453 -------------------------------------------------
src/navigator.h | 119 -------------
src/picture_viewer.c | 52 +++++--
src/picture_viewer.h | 2 +-
src/save_dialog.c | 6 +-
src/thumbnail.c | 85 +++-------
src/thumbnail.h | 5 +-
src/thumbnail_bar.c | 128 +++++++++-----
src/thumbnail_bar.h | 4 +-
15 files changed, 831 insertions(+), 832 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 98a414e..b2c5db9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,7 +1,7 @@
bin_PROGRAMS = ristretto
ristretto_SOURCES = \
- navigator.c navigator.h \
+ image_list.c image_list.h \
image.c image.h \
image_cache.c image_cache.h \
picture_viewer.c picture_viewer.h \
@@ -10,9 +10,9 @@ ristretto_SOURCES = \
main_window_ui.h \
main_window.c main_window.h \
thumbnail_bar.c thumbnail_bar.h \
+ thumbnail.c thumbnail.h \
main.c
# save_dialog.h save_dialog.c
-# thumbnail.c thumbnail.h
ristretto_CFLAGS = \
$(GTK_CFLAGS) \
diff --git a/src/image_list.c b/src/image_list.c
new file mode 100644
index 0000000..7703a46
--- /dev/null
+++ b/src/image_list.c
@@ -0,0 +1,456 @@
+/*
+ * Copyright (c) 2009 Stephan Arts <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 "image.h"
+#include "image_list.h"
+
+static void
+rstto_image_list_init(RsttoImageList *);
+static void
+rstto_image_list_class_init(RsttoImageListClass *);
+static void
+rstto_image_list_dispose(GObject *object);
+
+static void
+rstto_image_list_iter_init(RsttoImageListIter *);
+static void
+rstto_image_list_iter_class_init(RsttoImageListIterClass *);
+static void
+rstto_image_list_iter_dispose(GObject *object);
+
+static RsttoImageListIter * rstto_image_list_iter_new ();
+
+static gint
+cb_rstto_image_list_image_name_compare_func (RsttoImage *a, RsttoImage *b);
+
+static GObjectClass *parent_class = NULL;
+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_ALL,
+ RSTTO_IMAGE_LIST_SIGNAL_COUNT
+};
+
+enum
+{
+ RSTTO_IMAGE_LIST_ITER_SIGNAL_CHANGED = 0,
+ RSTTO_IMAGE_LIST_ITER_SIGNAL_COUNT
+};
+
+struct _RsttoImageListIterPriv
+{
+ RsttoImageList *image_list;
+ RsttoImage *image;
+ gint position;
+};
+
+struct _RsttoImageListPriv
+{
+ GList *images;
+ gint n_images;
+};
+
+static gint rstto_image_list_signals[RSTTO_IMAGE_LIST_SIGNAL_COUNT];
+static gint rstto_image_list_iter_signals[RSTTO_IMAGE_LIST_ITER_SIGNAL_COUNT];
+
+GType
+rstto_image_list_get_type ()
+{
+ static GType rstto_image_list_type = 0;
+
+ if (!rstto_image_list_type)
+ {
+ static const GTypeInfo rstto_image_list_info =
+ {
+ sizeof (RsttoImageListClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) rstto_image_list_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (RsttoImageList),
+ 0,
+ (GInstanceInitFunc) rstto_image_list_init,
+ NULL
+ };
+
+ rstto_image_list_type = g_type_register_static (G_TYPE_OBJECT, "RsttoImageList", &rstto_image_list_info, 0);
+ }
+ return rstto_image_list_type;
+}
+
+static void
+rstto_image_list_init(RsttoImageList *image_list)
+{
+ image_list->priv = g_new0 (RsttoImageListPriv, 1);
+}
+
+static void
+rstto_image_list_class_init(RsttoImageListClass *nav_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(nav_class);
+
+ parent_class = g_type_class_peek_parent(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,
+ 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_ALL] = g_signal_new("remove-all",
+ G_TYPE_FROM_CLASS(nav_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0,
+ NULL);
+}
+
+static void
+rstto_image_list_dispose(GObject *object)
+{
+ /*RsttoImageList *image_list = RSTTO_IMAGE_LIST(object);*/
+}
+
+RsttoImageList *
+rstto_image_list_new ()
+{
+ RsttoImageList *image_list;
+
+ image_list = g_object_new(RSTTO_TYPE_IMAGE_LIST, NULL);
+
+ return image_list;
+}
+
+gboolean
+rstto_image_list_add_file (RsttoImageList *image_list, GFile *file, GError **error)
+{
+ RsttoImage *image = rstto_image_new (file);
+ if (image)
+ {
+ image_list->priv->images = g_list_insert_sorted (image_list->priv->images, image, (GCompareFunc)cb_rstto_image_list_image_name_compare_func);
+ image_list->priv->n_images++;
+
+ g_signal_emit (G_OBJECT (image_list), rstto_image_list_signals[RSTTO_IMAGE_LIST_SIGNAL_NEW_IMAGE], 0, image, NULL);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+gint
+rstto_image_list_get_n_images (RsttoImageList *image_list)
+{
+ return g_list_length (image_list->priv->images);
+}
+
+RsttoImageListIter *
+rstto_image_list_get_iter (RsttoImageList *image_list)
+{
+ RsttoImage *image = NULL;
+ if (image_list->priv->images)
+ image = image_list->priv->images->data;
+
+ RsttoImageListIter *iter = rstto_image_list_iter_new (image_list, image);
+
+ return iter;
+}
+
+
+void
+rstto_image_list_remove_image (RsttoImageList *image_list, RsttoImage *image)
+{
+ if (g_list_find (image_list->priv->images, image))
+ {
+ image_list->priv->images = g_list_remove (image_list->priv->images, image);
+ g_signal_emit (G_OBJECT (image_list), rstto_image_list_signals[RSTTO_IMAGE_LIST_SIGNAL_REMOVE_IMAGE], 0, image, NULL);
+ g_object_unref (image);
+ }
+}
+
+void
+rstto_image_list_remove_all (RsttoImageList *image_list)
+{
+ g_list_foreach (image_list->priv->images, (GFunc)g_object_unref, NULL);
+ g_list_free (image_list->priv->images);
+ g_signal_emit (G_OBJECT (image_list), rstto_image_list_signals[RSTTO_IMAGE_LIST_SIGNAL_REMOVE_ALL], 0, NULL);
+ image_list->priv->images = NULL;
+}
+
+
+/**
+ * cb_rstto_image_list_image_name_compare_func:
+ * @a:
+ * @b:
+ *
+ *
+ * Return value: (see strcmp)
+ */
+static gint
+cb_rstto_image_list_image_name_compare_func (RsttoImage *a, RsttoImage *b)
+{
+ gchar *a_base = g_file_get_basename (rstto_image_get_file (a));
+ gchar *b_base = g_file_get_basename (rstto_image_get_file (b));
+ gint result = 0;
+
+ result = g_strcasecmp (a_base, b_base);
+
+ g_free (a_base);
+ g_free (b_base);
+ return result;
+}
+
+GType
+rstto_image_list_iter_get_type ()
+{
+ static GType rstto_image_list_iter_type = 0;
+
+ if (!rstto_image_list_iter_type)
+ {
+ static const GTypeInfo rstto_image_list_iter_info =
+ {
+ sizeof (RsttoImageListIterClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) rstto_image_list_iter_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (RsttoImageListIter),
+ 0,
+ (GInstanceInitFunc) rstto_image_list_iter_init,
+ NULL
+ };
+
+ rstto_image_list_iter_type = g_type_register_static (G_TYPE_OBJECT, "RsttoImageListIter", &rstto_image_list_iter_info, 0);
+ }
+ return rstto_image_list_iter_type;
+}
+
+static void
+rstto_image_list_iter_init (RsttoImageListIter *iter)
+{
+ iter->priv = g_new0 (RsttoImageListIterPriv, 1);
+}
+
+static void
+rstto_image_list_iter_class_init(RsttoImageListIterClass *iter_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(iter_class);
+
+ iter_parent_class = g_type_class_peek_parent(iter_class);
+
+ object_class->dispose = rstto_image_list_iter_dispose;
+
+ rstto_image_list_iter_signals[RSTTO_IMAGE_LIST_ITER_SIGNAL_CHANGED] = g_signal_new("changed",
+ G_TYPE_FROM_CLASS(iter_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0,
+ NULL);
+
+}
+
+static void
+rstto_image_list_iter_dispose (GObject *object)
+{
+ RsttoImageListIter *iter = RSTTO_IMAGE_LIST_ITER(object);
+ if (iter->priv->image)
+ {
+ g_object_unref (iter->priv->image);
+ iter->priv->image = NULL;
+ }
+}
+
+static RsttoImageListIter *
+rstto_image_list_iter_new (RsttoImageList *nav, RsttoImage *image)
+{
+ RsttoImageListIter *iter;
+
+ iter = g_object_new(RSTTO_TYPE_IMAGE_LIST_ITER, NULL);
+ iter->priv->image = image;
+ iter->priv->image_list = nav;
+ iter->priv->position = -1;
+
+ return iter;
+}
+
+gboolean
+rstto_image_list_iter_find_image (RsttoImageListIter *iter, RsttoImage *image)
+{
+ gint pos = g_list_index (iter->priv->image_list->priv->images, image);
+ if (pos > -1)
+ {
+ if (iter->priv->image)
+ {
+ iter->priv->image = NULL;
+ }
+ iter->priv->image = image;
+
+ g_signal_emit (G_OBJECT (iter), rstto_image_list_iter_signals[RSTTO_IMAGE_LIST_ITER_SIGNAL_CHANGED], 0, NULL);
+
+ return TRUE;
+ }
+ return FALSE;
+}
+
+gint
+rstto_image_list_iter_get_position (RsttoImageListIter *iter)
+{
+ if (iter->priv->image == NULL)
+ {
+ if ((iter->priv->position == -1) && (rstto_image_list_get_n_images (iter->priv->image_list) > 0))
+ {
+ rstto_image_list_iter_set_position (iter, 0);
+ }
+ }
+ return iter->priv->position;
+}
+
+RsttoImage *
+rstto_image_list_iter_get_image (RsttoImageListIter *iter)
+{
+ if (iter->priv->image == NULL)
+ {
+ if ((iter->priv->position == -1) && (rstto_image_list_get_n_images (iter->priv->image_list) > 0))
+ {
+ rstto_image_list_iter_set_position (iter, 0);
+ }
+ }
+ return RSTTO_IMAGE (iter->priv->image);
+}
+
+
+gboolean
+rstto_image_list_iter_set_position (RsttoImageListIter *iter, gint pos)
+{
+ if (iter->priv->image)
+ {
+ iter->priv->image = NULL;
+ }
+
+ iter->priv->image = g_list_nth_data (iter->priv->image_list->priv->images, pos);
+ if (iter->priv->image)
+ {
+ iter->priv->position = pos;
+ }
+ else
+ {
+ iter->priv->position = -1;
+ }
+ g_debug ("w00t: %d", iter->priv->position);
+ g_signal_emit (G_OBJECT (iter), rstto_image_list_iter_signals[RSTTO_IMAGE_LIST_ITER_SIGNAL_CHANGED], 0, NULL);
+}
+
+gboolean
+rstto_image_list_iter_next (RsttoImageListIter *iter)
+{
+ if (iter->priv->image)
+ {
+ iter->priv->image = NULL;
+ }
+
+ iter->priv->image = g_list_nth_data (iter->priv->image_list->priv->images, iter->priv->position+1);
+ if (iter->priv->image)
+ {
+ iter->priv->position++;
+ }
+ else
+ {
+ iter->priv->position = 0;
+ iter->priv->image = g_list_nth_data (iter->priv->image_list->priv->images, 0);
+ if (iter->priv->image == NULL)
+ {
+ iter->priv->position = -1;
+ }
+ }
+
+ g_signal_emit (G_OBJECT (iter), rstto_image_list_iter_signals[RSTTO_IMAGE_LIST_ITER_SIGNAL_CHANGED], 0, NULL);
+}
+
+gboolean
+rstto_image_list_iter_previous (RsttoImageListIter *iter)
+{
+ if (iter->priv->image)
+ {
+ iter->priv->image = NULL;
+ }
+
+ iter->priv->image = g_list_nth_data (iter->priv->image_list->priv->images, iter->priv->position-1);
+ if (iter->priv->image)
+ {
+ iter->priv->position--;
+ }
+ else
+ {
+ iter->priv->position = g_list_length (iter->priv->image_list->priv->images)-1;
+ iter->priv->image = g_list_nth_data (iter->priv->image_list->priv->images, iter->priv->position);
+ if (iter->priv->image == NULL)
+ {
+ iter->priv->position = -1;
+ }
+ }
+ g_signal_emit (G_OBJECT (iter), rstto_image_list_iter_signals[RSTTO_IMAGE_LIST_ITER_SIGNAL_CHANGED], 0, NULL);
+}
+
+RsttoImageListIter *
+rstto_image_list_iter_clone (RsttoImageListIter *iter)
+{
+ RsttoImageListIter *new_iter = rstto_image_list_iter_new (iter->priv->image_list, iter->priv->image);
+ new_iter->priv->position = iter->priv->position;
+
+ return new_iter;
+}
diff --git a/src/image_list.h b/src/image_list.h
new file mode 100644
index 0000000..dfd750b
--- /dev/null
+++ b/src/image_list.h
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2009 Stephan Arts <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_IMAGE_LIST_H__
+#define __RISTRETTO_IMAGE_LIST_H__
+
+G_BEGIN_DECLS
+
+#define RSTTO_TYPE_IMAGE_LIST rstto_image_list_get_type()
+
+#define RSTTO_IMAGE_LIST(obj)( \
+ G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ RSTTO_TYPE_IMAGE_LIST, \
+ RsttoImageList))
+
+#define RSTTO_IS_IMAGE_LIST(obj)( \
+ G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ RSTTO_TYPE_IMAGE_LIST))
+
+#define RSTTO_IMAGE_LIST_CLASS(klass)( \
+ G_TYPE_CHECK_CLASS_CAST ((klass), \
+ RSTTO_TYPE_IMAGE_LIST, \
+ RsttoImageListClass))
+
+#define RSTTO_IS_IMAGE_LIST_CLASS(klass)( \
+ G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ RSTTO_TYPE_IMAGE_LIST()))
+
+typedef struct _RsttoImageListPriv RsttoImageListPriv;
+typedef struct _RsttoImageList RsttoImageList;
+
+struct _RsttoImageList
+{
+ GObject parent;
+ RsttoImageListPriv *priv;
+};
+
+typedef struct _RsttoImageListClass RsttoImageListClass;
+struct _RsttoImageListClass
+{
+ GObjectClass parent_class;
+};
+
+
+#define RSTTO_TYPE_IMAGE_LIST_ITER rstto_image_list_iter_get_type()
+
+#define RSTTO_IMAGE_LIST_ITER(obj)( \
+ G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ RSTTO_TYPE_IMAGE_LIST_ITER, \
+ RsttoImageListIter))
+
+#define RSTTO_IS_IMAGE_LIST_ITER(obj)( \
+ G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ RSTTO_TYPE_IMAGE_LIST_ITER))
+
+#define RSTTO_IMAGE_LIST_ITER_CLASS(klass)( \
+ G_TYPE_CHECK_CLASS_CAST ((klass), \
+ RSTTO_TYPE_IMAGE_LIST_ITER, \
+ RsttoImageListIterClass))
+
+#define RSTTO_IS_IMAGE_LIST_ITER_CLASS(klass)( \
+ G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ RSTTO_TYPE_IMAGE_LIST_ITER()))
+
+typedef struct _RsttoImageListIter RsttoImageListIter;
+typedef struct _RsttoImageListIterPriv RsttoImageListIterPriv;
+struct _RsttoImageListIter
+{
+ GObject parent;
+ RsttoImageListIterPriv *priv;
+};
+
+typedef struct _RsttoImageListIterClass RsttoImageListIterClass;
+struct _RsttoImageListIterClass
+{
+ GObjectClass parent_class;
+};
+
+
+GType rstto_image_list_get_type ();
+RsttoImageList *rstto_image_list_new ();
+
+gint rstto_image_list_get_n_images (RsttoImageList *image_list);
+gboolean rstto_image_list_add_file (RsttoImageList *image_list, GFile *file, GError **);
+
+RsttoImageListIter *rstto_image_list_get_iter (RsttoImageList *image_list);
+
+/** Iter functions */
+GType rstto_image_list_get_type ();
+RsttoImage *rstto_image_list_iter_get_image (RsttoImageListIter *iter);
+gboolean rstto_image_list_iter_previous (RsttoImageListIter *iter);
+gboolean rstto_image_list_iter_next (RsttoImageListIter *iter);
+gint rstto_image_list_iter_get_position (RsttoImageListIter *iter);
+gboolean rstto_image_list_iter_set_position (RsttoImageListIter *iter, gint pos);
+
+void rstto_image_list_remove_all (RsttoImageList *image_list);
+void rstto_image_list_remove_image (RsttoImageList *image_list, RsttoImage *image);
+gboolean rstto_image_list_iter_find_image (RsttoImageListIter *iter, RsttoImage *image);
+RsttoImageListIter *rstto_image_list_iter_clone (RsttoImageListIter *iter);
+
+
+G_END_DECLS
+
+#endif /* __RISTRETTO_IMAGE_LIST_H__ */
diff --git a/src/main.c b/src/main.c
index ef25bca..da7c896 100644
--- a/src/main.c
+++ b/src/main.c
@@ -31,7 +31,7 @@
#include <libexif/exif-data.h>
#include "image.h"
-#include "navigator.h"
+#include "image_list.h"
#include "settings.h"
#include "picture_viewer.h"
#include "main_window.h"
@@ -42,7 +42,7 @@ gboolean start_fullscreen = FALSE;
gboolean start_slideshow = FALSE;
typedef struct {
- RsttoNavigator *navigator;
+ RsttoImageList *image_list;
gint argc;
gchar **argv;
gint iter;
@@ -101,14 +101,14 @@ main(int argc, char **argv)
gtk_window_set_default_icon_name("ristretto");
RsttoSettings *settings = rstto_settings_new();
- RsttoNavigator *navigator = rstto_navigator_new ();
- GtkWidget *window = rstto_main_window_new (navigator, FALSE);
+ RsttoImageList *image_list = rstto_image_list_new ();
+ GtkWidget *window = rstto_main_window_new (image_list, FALSE);
if (argc > 1)
{
RsttoOpenFiles rof;
- rof.navigator = navigator;
+ rof.image_list = image_list;
rof.argc = argc;
rof.argv = argv;
rof.iter = 1;
@@ -147,7 +147,7 @@ cb_rstto_open_files (RsttoOpenFiles *rof)
if (strncmp (content_type, "image/", 6) == 0)
{
- rstto_navigator_add_file (rof->navigator, file, NULL);
+ rstto_image_list_add_file (rof->image_list, file, NULL);
}
}
}
diff --git a/src/main_window.c b/src/main_window.c
index fd95703..949ca4b 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -32,7 +32,7 @@
#include "image.h"
#include "settings.h"
-#include "navigator.h"
+#include "image_list.h"
#include "picture_viewer.h"
#include "main_window.h"
#include "main_window_ui.h"
@@ -54,7 +54,7 @@
struct _RsttoMainWindowPriv
{
struct {
- RsttoNavigator *navigator;
+ RsttoImageList *image_list;
gboolean toolbar_visible;
} props;
@@ -63,7 +63,7 @@ struct _RsttoMainWindowPriv
gboolean fs_toolbar_sticky;
- RsttoNavigatorIter *iter;
+ RsttoImageListIter *iter;
GtkActionGroup *action_group;
GtkUIManager *ui_manager;
@@ -72,8 +72,8 @@ struct _RsttoMainWindowPriv
GtkWidget *menubar;
GtkWidget *toolbar;
- GtkWidget *navigator_toolbar;
- GtkWidget *navigator_toolbar_menu;
+ GtkWidget *image_list_toolbar;
+ GtkWidget *image_list_toolbar_menu;
GtkWidget *picture_viewer;
GtkWidget *p_viewer_s_window;
GtkWidget *hpaned;
@@ -101,7 +101,7 @@ struct _RsttoMainWindowPriv
enum
{
PROP_0,
- PROP_NAVIGATOR,
+ PROP_IMAGE_LIST,
};
static void
@@ -131,21 +131,25 @@ cb_rstto_main_window_state_event(GtkWidget *widget, GdkEventWindowState *event,
static gboolean
cb_rstto_main_window_show_fs_toolbar_timeout (RsttoMainWindow *window);
static gboolean
-cb_rstto_main_window_navigator_toolbar_enter_notify_event (GtkWidget *widget,
+cb_rstto_main_window_image_list_toolbar_enter_notify_event (GtkWidget *widget,
GdkEventCrossing *event,
gpointer user_data);
static gboolean
-cb_rstto_main_window_navigator_toolbar_leave_notify_event (GtkWidget *widget,
+cb_rstto_main_window_image_list_toolbar_leave_notify_event (GtkWidget *widget,
GdkEventCrossing *evet,
gpointer user_data);
+static void
+cb_rstto_main_window_image_list_iter_changed (RsttoImageListIter *iter, RsttoMainWindow *window);
+static void
+rstto_main_window_image_list_iter_changed (RsttoMainWindow *window);
static void
-cb_rstto_main_window_navigator_new_image (RsttoNavigator *navigator, RsttoImage *image, RsttoMainWindow *window);
+cb_rstto_main_window_image_list_new_image (RsttoImageList *image_list, RsttoImage *image, RsttoMainWindow *window);
static void
-cb_rstto_main_window_navigator_remove_image (RsttoNavigator *navigator, RsttoImage *image, RsttoMainWindow *window);
+cb_rstto_main_window_image_list_remove_image (RsttoImageList *image_list, RsttoImage *image, RsttoMainWindow *window);
static gboolean
-cb_rstto_main_window_navigator_toolbar_popup_context_menu (GtkToolbar *toolbar,
+cb_rstto_main_window_image_list_toolbar_popup_context_menu (GtkToolbar *toolbar,
gint x,
gint y,
gint button,
@@ -403,8 +407,8 @@ rstto_main_window_init (RsttoMainWindow *window)
gtk_ui_manager_add_ui_from_string (window->priv->ui_manager,main_window_ui, main_window_ui_length, NULL);
window->priv->menubar = gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu");
window->priv->toolbar = gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-toolbar");
- window->priv->navigator_toolbar = gtk_ui_manager_get_widget (window->priv->ui_manager, "/navigation-toolbar");
- window->priv->navigator_toolbar_menu = gtk_ui_manager_get_widget (window->priv->ui_manager, "/tb-menu");
+ window->priv->image_list_toolbar = gtk_ui_manager_get_widget (window->priv->ui_manager, "/navigation-toolbar");
+ window->priv->image_list_toolbar_menu = gtk_ui_manager_get_widget (window->priv->ui_manager, "/tb-menu");
@@ -440,7 +444,7 @@ rstto_main_window_init (RsttoMainWindow *window)
gtk_box_pack_start(GTK_BOX(main_vbox), window->priv->menubar, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(main_vbox), window->priv->toolbar, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(main_vbox), window->priv->hpaned, TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(main_vbox), window->priv->navigator_toolbar, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(main_vbox), window->priv->image_list_toolbar, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(main_vbox), window->priv->statusbar, FALSE, FALSE, 0);
rstto_main_window_set_sensitive (window, FALSE);
@@ -528,14 +532,14 @@ rstto_main_window_class_init(RsttoMainWindowClass *window_class)
object_class->set_property = rstto_main_window_set_property;
object_class->get_property = rstto_main_window_get_property;
- pspec = g_param_spec_object ("navigator",
+ pspec = g_param_spec_object ("image_list",
"",
"",
- RSTTO_TYPE_NAVIGATOR,
+ RSTTO_TYPE_IMAGE_LIST,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
g_object_class_install_property (object_class,
- PROP_NAVIGATOR,
+ PROP_IMAGE_LIST,
pspec);
}
@@ -560,16 +564,16 @@ rstto_main_window_dispose(GObject *object)
/**
* rstto_main_window_new:
- * @navigator:
+ * @image_list:
*
* Return value:
*/
GtkWidget *
-rstto_main_window_new (RsttoNavigator *navigator, gboolean fullscreen)
+rstto_main_window_new (RsttoImageList *image_list, gboolean fullscreen)
{
GtkWidget *widget;
- widget = g_object_new (RSTTO_TYPE_MAIN_WINDOW, "navigator", navigator, NULL);
+ widget = g_object_new (RSTTO_TYPE_MAIN_WINDOW, "image_list", image_list, NULL);
if (fullscreen == TRUE)
{
@@ -579,25 +583,31 @@ rstto_main_window_new (RsttoNavigator *navigator, gboolean fullscreen)
return widget;
}
+static void
+cb_rstto_main_window_image_list_iter_changed (RsttoImageListIter *iter, RsttoMainWindow *window)
+{
+ rstto_main_window_image_list_iter_changed (window);
+}
+
/**
- * rstto_main_window_navigator_iter_changed:
+ * rstto_main_window_image_list_iter_changed:
* @window:
*
*/
static void
-rstto_main_window_navigator_iter_changed (RsttoMainWindow *window)
+rstto_main_window_image_list_iter_changed (RsttoMainWindow *window)
{
gchar *path, *basename, *title;
GFile *file = NULL;
RsttoImage *cur_image;
gint position, count;
- RsttoNavigator *navigator = window->priv->props.navigator;
+ RsttoImageList *image_list = window->priv->props.image_list;
- if (window->priv->props.navigator)
+ if (window->priv->props.image_list)
{
- position = rstto_navigator_iter_get_position (window->priv->iter);
- count = rstto_navigator_get_n_images (navigator);
- cur_image = rstto_navigator_iter_get_image (window->priv->iter);
+ position = rstto_image_list_iter_get_position (window->priv->iter);
+ count = rstto_image_list_get_n_images (image_list);
+ cur_image = rstto_image_list_iter_get_image (window->priv->iter);
if (cur_image)
{
file = rstto_image_get_file (cur_image);
@@ -618,7 +628,6 @@ rstto_main_window_navigator_iter_changed (RsttoMainWindow *window)
}
gtk_window_set_title (GTK_WINDOW (window), title);
- rstto_picture_viewer_set_image (RSTTO_PICTURE_VIEWER (window->priv->picture_viewer), cur_image);
g_free (title);
}
@@ -722,28 +731,31 @@ rstto_main_window_set_property (GObject *object,
switch (property_id)
{
- case PROP_NAVIGATOR:
- if (window->priv->props.navigator)
+ case PROP_IMAGE_LIST:
+ if (window->priv->props.image_list)
{
- g_signal_handlers_disconnect_by_func (window->priv->props.navigator, cb_rstto_main_window_navigator_new_image, window);
- g_signal_handlers_disconnect_by_func (window->priv->props.navigator, cb_rstto_main_window_navigator_remove_image, window);
- g_object_unref (window->priv->props.navigator);
+ g_signal_handlers_disconnect_by_func (window->priv->props.image_list, cb_rstto_main_window_image_list_new_image, window);
+ g_signal_handlers_disconnect_by_func (window->priv->props.image_list, cb_rstto_main_window_image_list_remove_image, window);
+ g_object_unref (window->priv->props.image_list);
+ g_signal_handlers_disconnect_by_func (window->priv->iter, cb_rstto_main_window_image_list_iter_changed, window);
g_object_unref (window->priv->iter);
window->priv->iter = NULL;
}
- window->priv->props.navigator = g_value_get_object (value);
+ window->priv->props.image_list = g_value_get_object (value);
- if (window->priv->props.navigator)
+ if (window->priv->props.image_list)
{
- g_object_ref (window->priv->props.navigator);
- g_signal_connect (G_OBJECT (window->priv->props.navigator), "new-image", G_CALLBACK (cb_rstto_main_window_navigator_new_image), window);
- g_signal_connect (G_OBJECT (window->priv->props.navigator), "remove-image", G_CALLBACK (cb_rstto_main_window_navigator_remove_image), window);
+ g_object_ref (window->priv->props.image_list);
+ g_signal_connect (G_OBJECT (window->priv->props.image_list), "new-image", G_CALLBACK (cb_rstto_main_window_image_list_new_image), window);
+ g_signal_connect (G_OBJECT (window->priv->props.image_list), "remove-image", G_CALLBACK (cb_rstto_main_window_image_list_remove_image), window);
- window->priv->iter = rstto_navigator_get_iter (window->priv->props.navigator);
- rstto_thumbnail_bar_set_navigator (RSTTO_THUMBNAIL_BAR (window->priv->thumbnail_bar), window->priv->props.navigator);
+ window->priv->iter = rstto_image_list_get_iter (window->priv->props.image_list);
+ g_signal_connect (G_OBJECT (window->priv->iter), "changed", G_CALLBACK (cb_rstto_main_window_image_list_iter_changed), window);
+ rstto_thumbnail_bar_set_image_list (RSTTO_THUMBNAIL_BAR (window->priv->thumbnail_bar), window->priv->props.image_list);
rstto_thumbnail_bar_set_iter (RSTTO_THUMBNAIL_BAR (window->priv->thumbnail_bar), window->priv->iter);
+ rstto_picture_viewer_set_iter (RSTTO_PICTURE_VIEWER (window->priv->picture_viewer), window->priv->iter);
}
break;
default:
@@ -769,8 +781,8 @@ rstto_main_window_get_property (GObject *object,
switch (property_id)
{
- case PROP_NAVIGATOR:
- g_value_set_object (value, window->priv->props.navigator);
+ case PROP_IMAGE_LIST:
+ g_value_set_object (value, window->priv->props.image_list);
break;
default:
break;
@@ -846,7 +858,7 @@ cb_rstto_main_window_rotate_cw (GtkWidget *widget, RsttoMainWindow *window)
RsttoImage *image = NULL;
if (window->priv->iter)
- image = rstto_navigator_iter_get_image (window->priv->iter);
+ image = rstto_image_list_iter_get_image (window->priv->iter);
if (image)
{
@@ -882,7 +894,7 @@ cb_rstto_main_window_rotate_ccw (GtkWidget *widget, RsttoMainWindow *window)
RsttoImage *image = NULL;
if (window->priv->iter)
- image = rstto_navigator_iter_get_image (window->priv->iter);
+ image = rstto_image_list_iter_get_image (window->priv->iter);
if (image)
{
@@ -921,8 +933,7 @@ cb_rstto_main_window_rotate_ccw (GtkWidget *widget, RsttoMainWindow *window)
static void
cb_rstto_main_window_first_image (GtkWidget *widget, RsttoMainWindow *window)
{
- rstto_navigator_iter_set_position (window->priv->iter, 0);
- rstto_main_window_navigator_iter_changed (window);
+ rstto_image_list_iter_set_position (window->priv->iter, 0);
}
@@ -937,9 +948,8 @@ cb_rstto_main_window_first_image (GtkWidget *widget, RsttoMainWindow *window)
static void
cb_rstto_main_window_last_image (GtkWidget *widget, RsttoMainWindow *window)
{
- guint n_images = rstto_navigator_get_n_images (window->priv->props.navigator);
- rstto_navigator_iter_set_position (window->priv->iter, n_images-1);
- rstto_main_window_navigator_iter_changed (window);
+ guint n_images = rstto_image_list_get_n_images (window->priv->props.image_list);
+ rstto_image_list_iter_set_position (window->priv->iter, n_images-1);
}
/**
@@ -953,8 +963,7 @@ cb_rstto_main_window_last_image (GtkWidget *widget, RsttoMainWindow *window)
static void
cb_rstto_main_window_next_image (GtkWidget *widget, RsttoMainWindow *window)
{
- rstto_navigator_iter_next (window->priv->iter);
- rstto_main_window_navigator_iter_changed (window);
+ rstto_image_list_iter_next (window->priv->iter);
}
/**
@@ -968,8 +977,7 @@ cb_rstto_main_window_next_image (GtkWidget *widget, RsttoMainWindow *window)
static void
cb_rstto_main_window_previous_image (GtkWidget *widget, RsttoMainWindow *window)
{
- rstto_navigator_iter_previous (window->priv->iter);
- rstto_main_window_navigator_iter_changed (window);
+ rstto_image_list_iter_previous (window->priv->iter);
}
/**
@@ -1024,7 +1032,7 @@ cb_rstto_main_window_open_image (GtkWidget *widget, RsttoMainWindow *window)
while (_files_iter)
{
file = _files_iter->data;
- if (rstto_navigator_add_file (window->priv->props.navigator, file, NULL) == FALSE)
+ if (rstto_image_list_add_file (window->priv->props.image_list, file, NULL) == FALSE)
{
err_dialog = gtk_message_dialog_new(GTK_WINDOW(window),
GTK_DIALOG_MODAL,
@@ -1046,12 +1054,6 @@ cb_rstto_main_window_open_image (GtkWidget *widget, RsttoMainWindow *window)
g_value_set_string (¤t_uri_val, gtk_file_chooser_get_current_folder_uri (GTK_FILE_CHOOSER (dialog)));
g_object_set_property (G_OBJECT(window->priv->settings_manager), "current-uri", ¤t_uri_val);
- if (window->priv->iter == NULL)
- {
- window->priv->iter = rstto_navigator_get_iter (window->priv->props.navigator);
- rstto_thumbnail_bar_set_iter (RSTTO_THUMBNAIL_BAR (window->priv->thumbnail_bar), window->priv->iter);
- }
- rstto_main_window_navigator_iter_changed (window);
}
gtk_widget_destroy(dialog);
@@ -1111,7 +1113,7 @@ cb_rstto_main_window_open_folder (GtkWidget *widget, RsttoMainWindow *window)
if (strncmp (content_type, "image/", 6) == 0)
{
- rstto_navigator_add_file (window->priv->props.navigator, child_file, NULL);
+ rstto_image_list_add_file (window->priv->props.image_list, child_file, NULL);
}
g_object_unref (child_file);
@@ -1125,13 +1127,6 @@ cb_rstto_main_window_open_folder (GtkWidget *widget, RsttoMainWindow *window)
g_value_set_string (¤t_uri_val, gtk_file_chooser_get_current_folder_uri (GTK_FILE_CHOOSER (dialog)));
g_object_set_property (G_OBJECT(window->priv->settings_manager), "current-uri", ¤t_uri_val);
-
- if (window->priv->iter == NULL)
- {
- window->priv->iter = rstto_navigator_get_iter (window->priv->props.navigator);
- rstto_thumbnail_bar_set_iter (RSTTO_THUMBNAIL_BAR (window->priv->thumbnail_bar), window->priv->iter);
- }
- rstto_main_window_navigator_iter_changed (window);
}
gtk_widget_destroy(dialog);
@@ -1171,7 +1166,7 @@ cb_rstto_main_window_open_recent(GtkRecentChooser *chooser, RsttoMainWindow *win
filename = g_file_info_get_name (child_file_info);
child_file = g_file_get_child (file, filename);
- rstto_navigator_add_file (window->priv->props.navigator, child_file, NULL);
+ rstto_image_list_add_file (window->priv->props.image_list, child_file, NULL);
g_object_unref (child_file);
g_object_unref (child_file_info);
@@ -1180,7 +1175,7 @@ cb_rstto_main_window_open_recent(GtkRecentChooser *chooser, RsttoMainWindow *win
}
else
{
- if (rstto_navigator_add_file (window->priv->props.navigator, file, NULL) == FALSE)
+ if (rstto_image_list_add_file (window->priv->props.image_list, file, NULL) == FALSE)
{
err_dialog = gtk_message_dialog_new(GTK_WINDOW(window),
GTK_DIALOG_MODAL,
@@ -1203,13 +1198,6 @@ cb_rstto_main_window_open_recent(GtkRecentChooser *chooser, RsttoMainWindow *win
gtk_widget_destroy (err_dialog);
}
- if (window->priv->iter == NULL)
- {
- window->priv->iter = rstto_navigator_get_iter (window->priv->props.navigator);
- rstto_thumbnail_bar_set_iter (RSTTO_THUMBNAIL_BAR (window->priv->thumbnail_bar), window->priv->iter);
- }
- rstto_main_window_navigator_iter_changed (window);
-
g_object_unref (file);
g_free (uri);
}
@@ -1233,11 +1221,11 @@ cb_rstto_main_window_save_copy (GtkWidget *widget, RsttoMainWindow *window)
if(response == GTK_RESPONSE_OK)
{
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
- s_file = rstto_image_get_file (rstto_navigator_iter_get_image (window->priv->iter));
+ s_file = rstto_image_get_file (rstto_image_list_iter_get_image (window->priv->iter));
if (g_file_copy (s_file, file, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, NULL))
{
- rstto_navigator_remove_image (window->priv->props.navigator, rstto_navigator_iter_get_image (window->priv->iter));
- rstto_navigator_add_file (window->priv->props.navigator, file, NULL);
+ rstto_image_list_remove_image (window->priv->props.image_list, rstto_image_list_iter_get_image (window->priv->iter));
+ rstto_image_list_add_file (window->priv->props.image_list, file, NULL);
}
}
@@ -1282,7 +1270,7 @@ rstto_main_window_print_draw_page (GtkPrintOperation *operation,
gint page_nr,
RsttoMainWindow *window)
{
- RsttoImage *image = rstto_navigator_iter_get_image (window->priv->iter);
+ RsttoImage *image = rstto_image_list_iter_get_image (window->priv->iter);
GdkPixbuf *pixbuf = rstto_image_get_pixbuf (image);
gdouble w = gdk_pixbuf_get_width (pixbuf);
gdouble w1 = gtk_print_context_get_width (print_context);
@@ -1395,8 +1383,8 @@ cb_rstto_main_window_play_slideshow (RsttoMainWindow *window)
{
if (window->priv->playing)
{
- rstto_navigator_iter_next (window->priv->iter);
- rstto_main_window_navigator_iter_changed (window);
+ rstto_image_list_iter_next (window->priv->iter);
+ rstto_main_window_image_list_iter_changed (window);
}
else
{
@@ -1547,9 +1535,8 @@ cb_rstto_main_window_quit (GtkWidget *widget, RsttoMainWindow *window)
static void
cb_rstto_main_window_close (GtkWidget *widget, RsttoMainWindow *window)
{
- RsttoImage *image = rstto_navigator_iter_get_image (window->priv->iter);
- rstto_picture_viewer_set_image (RSTTO_PICTURE_VIEWER (window->priv->picture_viewer), NULL);
- rstto_navigator_remove_image (window->priv->props.navigator, image);
+ RsttoImage *image = rstto_image_list_iter_get_image (window->priv->iter);
+ rstto_image_list_remove_image (window->priv->props.image_list, image);
}
/**
@@ -1562,8 +1549,8 @@ cb_rstto_main_window_close (GtkWidget *widget, RsttoMainWindow *window)
static void
cb_rstto_main_window_close_all (GtkWidget *widget, RsttoMainWindow *window)
{
- rstto_picture_viewer_set_image (RSTTO_PICTURE_VIEWER (window->priv->picture_viewer), NULL);
- rstto_navigator_remove_all (window->priv->props.navigator);
+ rstto_image_list_remove_all (window->priv->props.image_list);
+ rstto_main_window_image_list_iter_changed (window);
}
/**
@@ -1576,7 +1563,7 @@ cb_rstto_main_window_close_all (GtkWidget *widget, RsttoMainWindow *window)
static void
cb_rstto_main_window_delete (GtkWidget *widget, RsttoMainWindow *window)
{
- RsttoImage *image = rstto_navigator_iter_get_image (window->priv->iter);
+ RsttoImage *image = rstto_image_list_iter_get_image (window->priv->iter);
GFile *file = rstto_image_get_file (image);
gchar *path = g_file_get_path (file);
gchar *basename = g_path_get_basename (path);
@@ -1591,8 +1578,7 @@ cb_rstto_main_window_delete (GtkWidget *widget, RsttoMainWindow *window)
{
if (g_file_trash (file, NULL, NULL) == TRUE)
{
- rstto_picture_viewer_set_image (RSTTO_PICTURE_VIEWER (window->priv->picture_viewer), NULL);
- rstto_navigator_remove_image (window->priv->props.navigator, image);
+ rstto_image_list_remove_image (window->priv->props.image_list, image);
}
else
{
@@ -1632,55 +1618,47 @@ cb_rstto_main_window_toggle_show_toolbar (GtkWidget *widget, RsttoMainWindow *wi
}
/**
- * cb_rstto_main_window_navigator_new_image:
- * @navigator:
+ * cb_rstto_main_window_image_list_new_image:
+ * @image_list:
* @image:
* @window:
*
*/
static void
-cb_rstto_main_window_navigator_new_image (RsttoNavigator *navigator, RsttoImage *image, RsttoMainWindow *window)
+cb_rstto_main_window_image_list_new_image (RsttoImageList *image_list, RsttoImage *image, RsttoMainWindow *window)
{
- if (window->priv->iter == NULL)
- {
- window->priv->iter = rstto_navigator_get_iter (navigator);
- }
- rstto_main_window_navigator_iter_changed (window);
+ if (rstto_image_list_iter_get_position (window->priv->iter) == -1)
+ rstto_image_list_iter_set_position (window->priv->iter, 0);
}
/**
- * cb_rstto_main_window_navigator_remove_image:
- * @navigator:
+ * cb_rstto_main_window_image_list_remove_image:
+ * @image_list:
* @image:
* @window:
*
*/
static void
-cb_rstto_main_window_navigator_remove_image (RsttoNavigator *navigator, RsttoImage *image, RsttoMainWindow *window)
+cb_rstto_main_window_image_list_remove_image (RsttoImageList *image_list, RsttoImage *image, RsttoMainWindow *window)
{
- if (rstto_navigator_get_n_images (navigator) == 0)
+ if (rstto_image_list_get_n_images (image_list) == 0)
{
- if (window->priv->iter)
- {
- g_object_unref (window->priv->iter);
- window->priv->iter = rstto_navigator_get_iter (navigator);
- }
+ rstto_image_list_iter_set_position (window->priv->iter, -1);
}
else
{
- if (rstto_navigator_iter_get_image (window->priv->iter) == image)
+ if (rstto_image_list_iter_get_image (window->priv->iter) == image)
{
- if (rstto_navigator_iter_get_position (window->priv->iter) > 0)
+ if (rstto_image_list_iter_get_position (window->priv->iter) > 0)
{
- rstto_navigator_iter_previous (window->priv->iter);
+ rstto_image_list_iter_previous (window->priv->iter);
}
else
{
- rstto_navigator_iter_set_position (window->priv->iter, 0);
+ rstto_image_list_iter_set_position (window->priv->iter, 0);
}
}
}
- rstto_main_window_navigator_iter_changed (window);
}
@@ -1765,7 +1743,7 @@ cb_rstto_main_window_state_event(GtkWidget *widget, GdkEventWindowState *event,
}
else
{
- gtk_widget_hide (window->priv->navigator_toolbar);
+ gtk_widget_hide (window->priv->image_list_toolbar);
}
rstto_picture_viewer_zoom_fit (RSTTO_PICTURE_VIEWER (window->priv->picture_viewer));
@@ -1796,7 +1774,7 @@ cb_rstto_main_window_state_event(GtkWidget *widget, GdkEventWindowState *event,
g_source_remove (window->priv->show_fs_toolbar_timeout_id);
window->priv->show_fs_toolbar_timeout_id = 0;
}
- gtk_widget_show (window->priv->navigator_toolbar);
+ gtk_widget_show (window->priv->image_list_toolbar);
g_value_init (&show_toolbar_val, G_TYPE_BOOLEAN);
g_object_get_property (G_OBJECT(window->priv->settings_manager), "show-toolbar", &show_toolbar_val);
@@ -1825,7 +1803,7 @@ cb_rstto_main_window_picture_viewer_motion_notify_event (RsttoPictureViewer *vie
{
if (event->state == 0)
{
- gtk_widget_show (window->priv->navigator_toolbar);
+ gtk_widget_show (window->priv->image_list_toolbar);
if (window->priv->fs_toolbar_sticky == FALSE)
{
@@ -1843,7 +1821,7 @@ cb_rstto_main_window_picture_viewer_motion_notify_event (RsttoPictureViewer *vie
static gboolean
cb_rstto_main_window_show_fs_toolbar_timeout (RsttoMainWindow *window)
{
- gtk_widget_hide (window->priv->navigator_toolbar);
+ gtk_widget_hide (window->priv->image_list_toolbar);
return FALSE;
}
@@ -1864,7 +1842,7 @@ cb_rstto_main_window_settings_notify (GObject *settings, GParamSpec *spec, Rstto
/*
static gboolean
-cb_rstto_main_window_navigator_toolbar_popup_context_menu (GtkToolbar *toolbar,
+cb_rstto_main_window_image_list_toolbar_popup_context_menu (GtkToolbar *toolbar,
gint x,
gint y,
gint button,
@@ -1872,7 +1850,7 @@ cb_rstto_main_window_navigator_toolbar_popup_context_menu (GtkToolbar *toolbar,
{
RsttoMainWindow *window = RSTTO_MAIN_WINDOW (user_data);
- gtk_menu_popup (window->priv->navigator_toolbar_menu,
+ gtk_menu_popup (window->priv->image_list_toolbar_menu,
NULL,
NULL,
NULL,
diff --git a/src/main_window.h b/src/main_window.h
index 61350b3..e70768f 100644
--- a/src/main_window.h
+++ b/src/main_window.h
@@ -67,7 +67,7 @@ typedef enum {
GType rstto_main_window_get_type();
-GtkWidget *rstto_main_window_new (RsttoNavigator *, gboolean);
+GtkWidget *rstto_main_window_new (RsttoImageList *, gboolean);
G_END_DECLS
diff --git a/src/navigator.c b/src/navigator.c
deleted file mode 100644
index fec2eea..0000000
--- a/src/navigator.c
+++ /dev/null
@@ -1,453 +0,0 @@
-/*
- * Copyright (c) 2009 Stephan Arts <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 "image.h"
-#include "navigator.h"
-
-static void
-rstto_navigator_init(RsttoNavigator *);
-static void
-rstto_navigator_class_init(RsttoNavigatorClass *);
-static void
-rstto_navigator_dispose(GObject *object);
-
-static void
-rstto_navigator_iter_init(RsttoNavigatorIter *);
-static void
-rstto_navigator_iter_class_init(RsttoNavigatorIterClass *);
-static void
-rstto_navigator_iter_dispose(GObject *object);
-
-static RsttoNavigatorIter * rstto_navigator_iter_new ();
-
-static gint
-cb_rstto_navigator_image_name_compare_func (RsttoImage *a, RsttoImage *b);
-
-static GObjectClass *parent_class = NULL;
-static GObjectClass *iter_parent_class = NULL;
-
-enum
-{
- RSTTO_NAVIGATOR_SIGNAL_NEW_IMAGE = 0,
- RSTTO_NAVIGATOR_SIGNAL_REMOVE_IMAGE,
- RSTTO_NAVIGATOR_SIGNAL_COUNT
-};
-
-enum
-{
- RSTTO_NAVIGATOR_ITER_SIGNAL_CHANGED = 0,
- RSTTO_NAVIGATOR_ITER_SIGNAL_COUNT
-};
-
-struct _RsttoNavigatorIterPriv
-{
- RsttoNavigator *navigator;
- RsttoImage *image;
- gint position;
-};
-
-struct _RsttoNavigatorPriv
-{
- GList *images;
- gint n_images;
-};
-
-static gint rstto_navigator_signals[RSTTO_NAVIGATOR_SIGNAL_COUNT];
-static gint rstto_navigator_iter_signals[RSTTO_NAVIGATOR_ITER_SIGNAL_COUNT];
-
-GType
-rstto_navigator_get_type ()
-{
- static GType rstto_navigator_type = 0;
-
- if (!rstto_navigator_type)
- {
- static const GTypeInfo rstto_navigator_info =
- {
- sizeof (RsttoNavigatorClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) rstto_navigator_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof (RsttoNavigator),
- 0,
- (GInstanceInitFunc) rstto_navigator_init,
- NULL
- };
-
- rstto_navigator_type = g_type_register_static (G_TYPE_OBJECT, "RsttoNavigator", &rstto_navigator_info, 0);
- }
- return rstto_navigator_type;
-}
-
-static void
-rstto_navigator_init(RsttoNavigator *navigator)
-{
- navigator->priv = g_new0 (RsttoNavigatorPriv, 1);
-}
-
-static void
-rstto_navigator_class_init(RsttoNavigatorClass *nav_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS(nav_class);
-
- parent_class = g_type_class_peek_parent(nav_class);
-
- object_class->dispose = rstto_navigator_dispose;
-
- rstto_navigator_signals[RSTTO_NAVIGATOR_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_navigator_signals[RSTTO_NAVIGATOR_SIGNAL_REMOVE_IMAGE] = g_signal_new("remove-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);
-}
-
-static void
-rstto_navigator_dispose(GObject *object)
-{
- /*RsttoNavigator *navigator = RSTTO_NAVIGATOR(object);*/
-}
-
-RsttoNavigator *
-rstto_navigator_new ()
-{
- RsttoNavigator *navigator;
-
- navigator = g_object_new(RSTTO_TYPE_NAVIGATOR, NULL);
-
- return navigator;
-}
-
-gboolean
-rstto_navigator_add_file (RsttoNavigator *navigator, GFile *file, GError **error)
-{
- RsttoImage *image = rstto_image_new (file);
- if (image)
- {
- navigator->priv->images = g_list_insert_sorted (navigator->priv->images, image, (GCompareFunc)cb_rstto_navigator_image_name_compare_func);
- navigator->priv->n_images++;
-
- g_signal_emit (G_OBJECT (navigator), rstto_navigator_signals[RSTTO_NAVIGATOR_SIGNAL_NEW_IMAGE], 0, image, NULL);
- return TRUE;
- }
- return FALSE;
-}
-
-gint
-rstto_navigator_get_n_images (RsttoNavigator *navigator)
-{
- return g_list_length (navigator->priv->images);
-}
-
-RsttoNavigatorIter *
-rstto_navigator_get_iter (RsttoNavigator *navigator)
-{
- RsttoImage *image = NULL;
- if (navigator->priv->images)
- image = navigator->priv->images->data;
-
- RsttoNavigatorIter *iter = rstto_navigator_iter_new (navigator, image);
-
- return iter;
-}
-
-
-void
-rstto_navigator_remove_image (RsttoNavigator *navigator, RsttoImage *image)
-{
- if (g_list_find (navigator->priv->images, image))
- {
- navigator->priv->images = g_list_remove (navigator->priv->images, image);
- g_signal_emit (G_OBJECT (navigator), rstto_navigator_signals[RSTTO_NAVIGATOR_SIGNAL_REMOVE_IMAGE], 0, image, NULL);
-
- g_object_unref (image);
- }
-}
-
-void
-rstto_navigator_remove_all (RsttoNavigator *navigator)
-{
- g_list_foreach (navigator->priv->images, (GFunc)g_object_unref, NULL);
- g_list_free (navigator->priv->images);
- navigator->priv->images = NULL;
-}
-
-
-/**
- * cb_rstto_navigator_image_name_compare_func:
- * @a:
- * @b:
- *
- *
- * Return value: (see strcmp)
- */
-static gint
-cb_rstto_navigator_image_name_compare_func (RsttoImage *a, RsttoImage *b)
-{
- gchar *a_base = g_file_get_basename (rstto_image_get_file (a));
- gchar *b_base = g_file_get_basename (rstto_image_get_file (b));
- gint result = 0;
-
- result = g_strcasecmp (a_base, b_base);
-
- g_free (a_base);
- g_free (b_base);
- return result;
-}
-
-GType
-rstto_navigator_iter_get_type ()
-{
- static GType rstto_navigator_iter_type = 0;
-
- if (!rstto_navigator_iter_type)
- {
- static const GTypeInfo rstto_navigator_iter_info =
- {
- sizeof (RsttoNavigatorIterClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) rstto_navigator_iter_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof (RsttoNavigatorIter),
- 0,
- (GInstanceInitFunc) rstto_navigator_iter_init,
- NULL
- };
-
- rstto_navigator_iter_type = g_type_register_static (G_TYPE_OBJECT, "RsttoNavigatorIter", &rstto_navigator_iter_info, 0);
- }
- return rstto_navigator_iter_type;
-}
-
-static void
-rstto_navigator_iter_init (RsttoNavigatorIter *iter)
-{
- iter->priv = g_new0 (RsttoNavigatorIterPriv, 1);
-}
-
-static void
-rstto_navigator_iter_class_init(RsttoNavigatorIterClass *iter_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS(iter_class);
-
- iter_parent_class = g_type_class_peek_parent(iter_class);
-
- object_class->dispose = rstto_navigator_iter_dispose;
-
- rstto_navigator_iter_signals[RSTTO_NAVIGATOR_ITER_SIGNAL_CHANGED] = g_signal_new("changed",
- G_TYPE_FROM_CLASS(iter_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- 0,
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0,
- NULL);
-
-}
-
-static void
-rstto_navigator_iter_dispose (GObject *object)
-{
- RsttoNavigatorIter *iter = RSTTO_NAVIGATOR_ITER(object);
- if (iter->priv->image)
- {
- g_object_unref (iter->priv->image);
- iter->priv->image = NULL;
- }
-}
-
-static RsttoNavigatorIter *
-rstto_navigator_iter_new (RsttoNavigator *nav, RsttoImage *image)
-{
- RsttoNavigatorIter *iter;
-
- iter = g_object_new(RSTTO_TYPE_NAVIGATOR_ITER, NULL);
- iter->priv->image = image;
- iter->priv->navigator = nav;
- iter->priv->position = -1;
-
- return iter;
-}
-
-gboolean
-rstto_navigator_iter_find_image (RsttoNavigatorIter *iter, RsttoImage *image)
-{
- gint pos = g_list_index (iter->priv->navigator->priv->images, image);
- if (pos > -1)
- {
- if (iter->priv->image)
- {
- g_object_unref (iter->priv->image);
- iter->priv->image = NULL;
- }
- iter->priv->image = image;
- g_object_ref (iter->priv->image);
-
- g_signal_emit (G_OBJECT (iter), rstto_navigator_iter_signals[RSTTO_NAVIGATOR_ITER_SIGNAL_CHANGED], 0, NULL);
-
- return TRUE;
- }
- return FALSE;
-}
-
-gint
-rstto_navigator_iter_get_position (RsttoNavigatorIter *iter)
-{
- if (iter->priv->image == NULL)
- {
- if ((iter->priv->position == -1) && (rstto_navigator_get_n_images (iter->priv->navigator) > 0))
- {
- rstto_navigator_iter_set_position (iter, 0);
- }
- }
- return iter->priv->position;
-}
-
-RsttoImage *
-rstto_navigator_iter_get_image (RsttoNavigatorIter *iter)
-{
- if (iter->priv->image == NULL)
- {
- if ((iter->priv->position == -1) && (rstto_navigator_get_n_images (iter->priv->navigator) > 0))
- {
- rstto_navigator_iter_set_position (iter, 0);
- }
- }
- return RSTTO_IMAGE (iter->priv->image);
-}
-
-
-gboolean
-rstto_navigator_iter_set_position (RsttoNavigatorIter *iter, gint pos)
-{
- if (iter->priv->image)
- {
- g_object_unref (iter->priv->image);
- iter->priv->image = NULL;
- }
-
- iter->priv->image = g_list_nth_data (iter->priv->navigator->priv->images, pos);
- if (iter->priv->image)
- {
- iter->priv->position = pos;
- g_object_ref (iter->priv->image);
- }
- else
- {
- iter->priv->position = -1;
- }
- g_signal_emit (G_OBJECT (iter), rstto_navigator_iter_signals[RSTTO_NAVIGATOR_ITER_SIGNAL_CHANGED], 0, NULL);
-}
-
-gboolean
-rstto_navigator_iter_next (RsttoNavigatorIter *iter)
-{
- if (iter->priv->image)
- {
- g_object_unref (iter->priv->image);
- iter->priv->image = NULL;
- }
-
- iter->priv->image = g_list_nth_data (iter->priv->navigator->priv->images, iter->priv->position+1);
- if (iter->priv->image)
- {
- iter->priv->position++;
- }
- else
- {
- iter->priv->position = 0;
- iter->priv->image = g_list_nth_data (iter->priv->navigator->priv->images, 0);
- if (iter->priv->image == NULL)
- {
- iter->priv->position = -1;
- }
- }
- if (iter->priv->image)
- g_object_ref (iter->priv->image);
-
- g_signal_emit (G_OBJECT (iter), rstto_navigator_iter_signals[RSTTO_NAVIGATOR_ITER_SIGNAL_CHANGED], 0, NULL);
-}
-
-gboolean
-rstto_navigator_iter_previous (RsttoNavigatorIter *iter)
-{
- if (iter->priv->image)
- {
- g_object_unref (iter->priv->image);
- iter->priv->image = NULL;
- }
-
- iter->priv->image = g_list_nth_data (iter->priv->navigator->priv->images, iter->priv->position-1);
- if (iter->priv->image)
- {
- iter->priv->position--;
- }
- else
- {
- iter->priv->position = g_list_length (iter->priv->navigator->priv->images)-1;
- iter->priv->image = g_list_nth_data (iter->priv->navigator->priv->images, iter->priv->position);
- if (iter->priv->image == NULL)
- {
- iter->priv->position = -1;
- }
- }
- if (iter->priv->image)
- g_object_ref (iter->priv->image);
- g_signal_emit (G_OBJECT (iter), rstto_navigator_iter_signals[RSTTO_NAVIGATOR_ITER_SIGNAL_CHANGED], 0, NULL);
-}
-
-RsttoNavigatorIter *
-rstto_navigator_iter_clone (RsttoNavigatorIter *iter)
-{
- RsttoNavigatorIter *new_iter = rstto_navigator_iter_new (iter->priv->navigator, iter->priv->image);
- new_iter->priv->position = iter->priv->position;
-
- return new_iter;
-}
diff --git a/src/navigator.h b/src/navigator.h
deleted file mode 100644
index cc97fdd..0000000
--- a/src/navigator.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (c) 2009 Stephan Arts <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_NAVIGATOR_H__
-#define __RISTRETTO_NAVIGATOR_H__
-
-G_BEGIN_DECLS
-
-#define RSTTO_TYPE_NAVIGATOR rstto_navigator_get_type()
-
-#define RSTTO_NAVIGATOR(obj)( \
- G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- RSTTO_TYPE_NAVIGATOR, \
- RsttoNavigator))
-
-#define RSTTO_IS_NAVIGATOR(obj)( \
- G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- RSTTO_TYPE_NAVIGATOR))
-
-#define RSTTO_NAVIGATOR_CLASS(klass)( \
- G_TYPE_CHECK_CLASS_CAST ((klass), \
- RSTTO_TYPE_NAVIGATOR, \
- RsttoNavigatorClass))
-
-#define RSTTO_IS_NAVIGATOR_CLASS(klass)( \
- G_TYPE_CHECK_CLASS_TYPE ((klass), \
- RSTTO_TYPE_NAVIGATOR()))
-
-typedef struct _RsttoNavigatorPriv RsttoNavigatorPriv;
-typedef struct _RsttoNavigator RsttoNavigator;
-
-struct _RsttoNavigator
-{
- GObject parent;
- RsttoNavigatorPriv *priv;
-};
-
-typedef struct _RsttoNavigatorClass RsttoNavigatorClass;
-struct _RsttoNavigatorClass
-{
- GObjectClass parent_class;
-};
-
-
-#define RSTTO_TYPE_NAVIGATOR_ITER rstto_navigator_iter_get_type()
-
-#define RSTTO_NAVIGATOR_ITER(obj)( \
- G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- RSTTO_TYPE_NAVIGATOR_ITER, \
- RsttoNavigatorIter))
-
-#define RSTTO_IS_NAVIGATOR_ITER(obj)( \
- G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- RSTTO_TYPE_NAVIGATOR_ITER))
-
-#define RSTTO_NAVIGATOR_ITER_CLASS(klass)( \
- G_TYPE_CHECK_CLASS_CAST ((klass), \
- RSTTO_TYPE_NAVIGATOR_ITER, \
- RsttoNavigatorIterClass))
-
-#define RSTTO_IS_NAVIGATOR_ITER_CLASS(klass)( \
- G_TYPE_CHECK_CLASS_TYPE ((klass), \
- RSTTO_TYPE_NAVIGATOR_ITER()))
-
-typedef struct _RsttoNavigatorIter RsttoNavigatorIter;
-typedef struct _RsttoNavigatorIterPriv RsttoNavigatorIterPriv;
-struct _RsttoNavigatorIter
-{
- GObject parent;
- RsttoNavigatorIterPriv *priv;
-};
-
-typedef struct _RsttoNavigatorIterClass RsttoNavigatorIterClass;
-struct _RsttoNavigatorIterClass
-{
- GObjectClass parent_class;
-};
-
-
-GType rstto_navigator_get_type ();
-RsttoNavigator *rstto_navigator_new ();
-
-gint rstto_navigator_get_n_images (RsttoNavigator *navigator);
-gboolean rstto_navigator_add_file (RsttoNavigator *navigator, GFile *file, GError **);
-
-RsttoNavigatorIter *rstto_navigator_get_iter (RsttoNavigator *navigator);
-
-/** Iter functions */
-GType rstto_navigator_get_type ();
-RsttoImage *rstto_navigator_iter_get_image (RsttoNavigatorIter *iter);
-gboolean rstto_navigator_iter_previous (RsttoNavigatorIter *iter);
-gboolean rstto_navigator_iter_next (RsttoNavigatorIter *iter);
-gint rstto_navigator_iter_get_position (RsttoNavigatorIter *iter);
-gboolean rstto_navigator_iter_set_position (RsttoNavigatorIter *iter, gint pos);
-
-void rstto_navigator_remove_all (RsttoNavigator *navigator);
-void rstto_navigator_remove_image (RsttoNavigator *navigator, RsttoImage *image);
-gboolean rstto_navigator_iter_find_image (RsttoNavigatorIter *iter, RsttoImage *image);
-RsttoNavigatorIter *rstto_navigator_iter_clone (RsttoNavigatorIter *iter);
-
-
-G_END_DECLS
-
-#endif /* __RISTRETTO_NAVIGATOR_H__ */
diff --git a/src/picture_viewer.c b/src/picture_viewer.c
index 9552a6f..c554cf6 100644
--- a/src/picture_viewer.c
+++ b/src/picture_viewer.c
@@ -26,6 +26,7 @@
#include <libexif/exif-data.h>
#include "image.h"
+#include "image_list.h"
#include "picture_viewer.h"
#include "settings.h"
@@ -62,6 +63,7 @@ static const GtkTargetEntry drop_targets[] = {
struct _RsttoPictureViewerPriv
{
RsttoImage *image;
+ RsttoImageListIter *iter;
GtkMenu *menu;
RsttoPictureViewerState state;
RsttoZoomMode zoom_mode;
@@ -126,6 +128,8 @@ rstto_picture_viewer_set_scroll_adjustments(RsttoPictureViewer *, GtkAdjustment
static void
cb_rstto_picture_viewer_value_changed(GtkAdjustment *, RsttoPictureViewer *);
+static void
+cb_rstto_picture_viewer_nav_iter_changed (RsttoImageListIter *iter, gpointer user_data);
static void
cb_rstto_picture_viewer_image_updated (RsttoImage *image, RsttoPictureViewer *viewer);
@@ -807,14 +811,14 @@ static void
cb_rstto_picture_viewer_scroll_event (RsttoPictureViewer *viewer, GdkEventScroll *event)
{
/*
- RsttoNavigatorEntry *entry = rstto_navigator_get_file(viewer->priv->navigator);
+ RsttoImageListEntry *entry = rstto_image_list_get_file(viewer->priv->image_list);
if (entry == NULL)
{
return;
}
- gdouble scale = rstto_navigator_entry_get_scale(entry);
+ gdouble scale = rstto_image_list_entry_get_scale(entry);
viewer->priv->zoom_mode = RSTTO_ZOOM_MODE_CUSTOM;
switch(event->direction)
{
@@ -826,8 +830,8 @@ cb_rstto_picture_viewer_scroll_event (RsttoPictureViewer *viewer, GdkEventScroll
{
g_source_remove(viewer->priv->refresh.idle_id);
}
- rstto_navigator_entry_set_scale(entry, scale / 1.1);
- rstto_navigator_entry_set_fit_to_screen (entry, FALSE);
+ rstto_image_list_entry_set_scale(entry, scale / 1.1);
+ rstto_image_list_entry_set_fit_to_screen (entry, FALSE);
viewer->vadjustment->value = ((viewer->vadjustment->value + event->y) / 1.1) - event->y;
viewer->hadjustment->value = ((viewer->hadjustment->value + event->x) / 1.1) - event->x;
@@ -842,8 +846,8 @@ cb_rstto_picture_viewer_scroll_event (RsttoPictureViewer *viewer, GdkEventScroll
{
g_source_remove(viewer->priv->refresh.idle_id);
}
- rstto_navigator_entry_set_scale(entry, scale * 1.1);
- rstto_navigator_entry_set_fit_to_screen (entry, FALSE);
+ rstto_image_list_entry_set_scale(entry, scale * 1.1);
+ rstto_image_list_entry_set_fit_to_screen (entry, FALSE);
viewer->vadjustment->value = ((viewer->vadjustment->value + event->y) * 1.1) - event->y;
@@ -1413,7 +1417,7 @@ rstto_picture_viewer_set_zoom_mode(RsttoPictureViewer *viewer, RsttoZoomMode mod
*
*
*/
-void
+static void
rstto_picture_viewer_set_image (RsttoPictureViewer *viewer, RsttoImage *image)
{
gdouble *scale = NULL;
@@ -1429,14 +1433,15 @@ rstto_picture_viewer_set_image (RsttoPictureViewer *viewer, RsttoImage *image)
{
g_signal_handlers_disconnect_by_func (viewer->priv->image, cb_rstto_picture_viewer_image_updated, viewer);
g_signal_handlers_disconnect_by_func (viewer->priv->image, cb_rstto_picture_viewer_image_prepared, viewer);
- g_object_unref (viewer->priv->image);
+ g_object_remove_weak_pointer (G_OBJECT (viewer->priv->image), (gpointer *)&viewer->priv->image);
}
viewer->priv->image = image;
if (viewer->priv->image)
{
- g_object_ref (viewer->priv->image);
+ g_object_add_weak_pointer (G_OBJECT (viewer->priv->image), (gpointer *)&viewer->priv->image);
+
g_signal_connect (G_OBJECT (viewer->priv->image), "updated", G_CALLBACK (cb_rstto_picture_viewer_image_updated), viewer);
g_signal_connect (G_OBJECT (viewer->priv->image), "prepared", G_CALLBACK (cb_rstto_picture_viewer_image_prepared), viewer);
@@ -1588,14 +1593,14 @@ rstto_picture_viewer_drag_data_received(GtkWidget *widget,
{
if (g_file_test(path, G_FILE_TEST_IS_DIR))
{
- if(rstto_navigator_open_folder(picture_viewer->priv->navigator, path, FALSE, NULL) == TRUE)
+ if(rstto_image_list_open_folder(picture_viewer->priv->image_list, path, FALSE, NULL) == TRUE)
{
- rstto_navigator_jump_first(picture_viewer->priv->navigator);
+ rstto_image_list_jump_first(picture_viewer->priv->image_list);
}
}
else
{
- rstto_navigator_open_file(picture_viewer->priv->navigator, path, FALSE, NULL);
+ rstto_image_list_open_file(picture_viewer->priv->image_list, path, FALSE, NULL);
}
}
@@ -1655,3 +1660,26 @@ rstto_picture_viewer_drag_motion (GtkWidget *widget,
}
+void
+rstto_picture_viewer_set_iter (RsttoPictureViewer *viewer, RsttoImageListIter *iter)
+{
+ if (viewer->priv->iter)
+ {
+ g_signal_handlers_disconnect_by_func (viewer->priv->iter, cb_rstto_picture_viewer_nav_iter_changed, viewer);
+ g_object_unref (viewer->priv->iter);
+ viewer->priv->iter = NULL;
+ }
+ if (iter)
+ {
+ viewer->priv->iter = iter;
+ g_object_ref (viewer->priv->iter);
+ g_signal_connect (G_OBJECT (viewer->priv->iter), "changed", G_CALLBACK (cb_rstto_picture_viewer_nav_iter_changed), viewer);
+ }
+}
+
+static void
+cb_rstto_picture_viewer_nav_iter_changed (RsttoImageListIter *iter, gpointer user_data)
+{
+ RsttoPictureViewer *viewer = RSTTO_PICTURE_VIEWER (user_data);
+ rstto_picture_viewer_set_image (viewer, rstto_image_list_iter_get_image (iter));
+}
diff --git a/src/picture_viewer.h b/src/picture_viewer.h
index c241da8..d17b830 100644
--- a/src/picture_viewer.h
+++ b/src/picture_viewer.h
@@ -68,7 +68,7 @@ struct _RsttoPictureViewerClass
GType rstto_picture_viewer_get_type();
GtkWidget *rstto_picture_viewer_new ();
-void rstto_picture_viewer_set_image (RsttoPictureViewer *, RsttoImage *);
+void rstto_picture_viewer_set_iter (RsttoPictureViewer *, RsttoImageListIter *);
gdouble rstto_picture_viewer_get_scale(RsttoPictureViewer *viewer);
void rstto_picture_viewer_zoom_fit (RsttoPictureViewer *viewer);
diff --git a/src/save_dialog.c b/src/save_dialog.c
index a74910f..5dc3f0e 100644
--- a/src/save_dialog.c
+++ b/src/save_dialog.c
@@ -23,7 +23,7 @@
#include <libexif/exif-data.h>
-#include "navigator.h"
+#include "image_list.h"
#include "save_dialog.h"
static void
@@ -166,8 +166,8 @@ rstto_save_dialog_new (GtkWindow *parent, GList *entries)
while (list_iter)
{
gtk_list_store_append (store, &iter);
- gchar *path = thunar_vfs_path_dup_string (rstto_navigator_entry_get_info(((RsttoNavigatorEntry *)list_iter->data))->path);
- gtk_list_store_set (store, &iter, 0,rstto_navigator_entry_get_thumb (entries->data, 48),1, path, 2, FALSE, -1);
+ gchar *path = thunar_vfs_path_dup_string (rstto_image_list_entry_get_info(((RsttoImageListEntry *)list_iter->data))->path);
+ gtk_list_store_set (store, &iter, 0,rstto_image_list_entry_get_thumb (entries->data, 48),1, path, 2, FALSE, -1);
g_free (path);
list_iter = g_list_next(list_iter);
diff --git a/src/thumbnail.c b/src/thumbnail.c
index 6ba7c4f..28129ef 100644
--- a/src/thumbnail.c
+++ b/src/thumbnail.c
@@ -19,17 +19,15 @@
#include <gtk/gtkmarshal.h>
#include <string.h>
-#include <thunar-vfs/thunar-vfs.h>
#include <libexif/exif-data.h>
-#include "navigator.h"
+#include "image.h"
+#include "image_list.h"
#include "thumbnail.h"
struct _RsttoThumbnailPriv
{
- RsttoNavigatorEntry *entry;
- gboolean selected;
- GSList *group;
+ RsttoImage *image;
};
static GtkWidgetClass *parent_class = NULL;
@@ -149,20 +147,12 @@ static void
rstto_thumbnail_finalize(GObject *object)
{
RsttoThumbnail *thumb = RSTTO_THUMBNAIL(object);
-
- if (thumb->priv->entry)
+ if (thumb->priv->image)
{
- GSList *group = g_slist_remove(thumb->priv->group, thumb);
- GSList *iter = group;
-
- while(iter)
- {
- RsttoThumbnail *thumb_iter = iter->data;
- thumb_iter->priv->group = group;
- iter = g_slist_next(iter);
- }
- thumb->priv->entry = NULL;
+ g_object_unref (thumb->priv->image);
+ thumb->priv->image = NULL;
}
+
}
static void
@@ -172,24 +162,15 @@ rstto_thumbnail_paint(RsttoThumbnail *thumb)
GtkStateType state = GTK_WIDGET_STATE(widget);
- if(thumb->priv->entry)
+ if(thumb->priv->image)
{
if (GTK_WIDGET_STATE(widget) != GTK_STATE_PRELIGHT)
{
- if (rstto_navigator_entry_is_selected(thumb->priv->entry))
- {
- gtk_widget_set_state(widget, GTK_STATE_SELECTED);
- }
- else
- {
- gtk_widget_set_state(widget, GTK_STATE_NORMAL);
- }
}
- GdkPixbuf *pixbuf = rstto_navigator_entry_get_thumb(
- thumb->priv->entry,
- widget->allocation.height - 4);
+ GdkPixbuf *pixbuf = rstto_image_get_thumbnail (
+ thumb->priv->image);
gtk_paint_box(widget->style,
widget->window,
@@ -203,6 +184,7 @@ rstto_thumbnail_paint(RsttoThumbnail *thumb)
if(pixbuf)
{
+ pixbuf = gdk_pixbuf_scale_simple (pixbuf, widget->allocation.width, widget->allocation.height, GDK_INTERP_BILINEAR);
gdk_draw_pixbuf(GDK_DRAWABLE(widget->window),
NULL,
pixbuf,
@@ -217,46 +199,24 @@ rstto_thumbnail_paint(RsttoThumbnail *thumb)
}
GtkWidget *
-rstto_thumbnail_new(RsttoNavigatorEntry *entry, GSList *thumb_list)
+rstto_thumbnail_new (RsttoImage *image)
{
- g_return_val_if_fail(entry != NULL, NULL);
+ g_return_val_if_fail (image != NULL, NULL);
RsttoThumbnail *thumb = g_object_new(RSTTO_TYPE_THUMBNAIL, NULL);
- thumb->priv->entry = entry;
+ thumb->priv->image = image;
+ g_object_ref (image);
-#if GTK_CHECK_VERSION(2,12,0)
- ThunarVfsInfo *info = rstto_navigator_entry_get_info(thumb->priv->entry);
-
- gtk_widget_set_tooltip_text(GTK_WIDGET(thumb), thunar_vfs_path_dup_string(info->path));
-#else
- /* TODO: gtktooltip stuff */
-#endif
-
- {
- thumb->priv->group = g_slist_prepend(thumb_list, thumb);
- GSList *iter = thumb->priv->group;
- while(iter)
- {
- RsttoThumbnail *iter_thumb = iter->data;
- iter_thumb->priv->group = thumb->priv->group;
- iter = iter->next;
- }
- }
+ gtk_widget_set_tooltip_text(GTK_WIDGET(thumb), "AAAAAAAAAAAA");
return GTK_WIDGET(thumb);
}
-GtkWidget *
-rstto_thumbnail_new_from_widget(RsttoNavigatorEntry *entry, RsttoThumbnail *sibling)
+RsttoImage *
+rstto_thumbnail_get_image (RsttoThumbnail *thumb)
{
- return rstto_thumbnail_new(entry, sibling->priv->group);
-}
-
-RsttoNavigatorEntry *
-rstto_thumbnail_get_entry (RsttoThumbnail *thumb)
-{
- return thumb->priv->entry;
+ return thumb->priv->image;
}
/* CALLBACKS */
@@ -265,11 +225,8 @@ rstto_thumbnail_get_entry (RsttoThumbnail *thumb)
static void
rstto_thumbnail_clicked(GtkButton *button)
{
- RsttoThumbnail *thumb = RSTTO_THUMBNAIL(button);
- RsttoNavigatorEntry *entry = rstto_thumbnail_get_entry(thumb);
-
- thumb->selected = TRUE;
- rstto_navigator_entry_select(entry);
+ RsttoThumbnail *thumb = RSTTO_THUMBNAIL (button);
+ RsttoImage *image = rstto_thumbnail_get_image (thumb);
gtk_widget_queue_draw (GTK_WIDGET (button));
}
diff --git a/src/thumbnail.h b/src/thumbnail.h
index 4e71b30..1ca3014 100644
--- a/src/thumbnail.h
+++ b/src/thumbnail.h
@@ -59,9 +59,8 @@ struct _RsttoThumbnailClass
GType rstto_thumbnail_get_type();
-GtkWidget *rstto_thumbnail_new(RsttoNavigatorEntry *entry, GSList *thumb_list);
-GtkWidget *rstto_thumbnail_new_from_widget(RsttoNavigatorEntry *entry, RsttoThumbnail *sibling);
-RsttoNavigatorEntry *rstto_thumbnail_get_entry (RsttoThumbnail *thumb);
+GtkWidget *rstto_thumbnail_new (RsttoImage *image);
+RsttoImage *rstto_thumbnail_get_image (RsttoThumbnail *thumb);
G_END_DECLS
diff --git a/src/thumbnail_bar.c b/src/thumbnail_bar.c
index f003b36..1533497 100644
--- a/src/thumbnail_bar.c
+++ b/src/thumbnail_bar.c
@@ -25,7 +25,8 @@
#include <libexif/exif-data.h>
#include "image.h"
-#include "navigator.h"
+#include "image_list.h"
+#include "thumbnail.h"
#include "thumbnail_bar.h"
struct _RsttoThumbnailBarPriv
@@ -36,10 +37,10 @@ struct _RsttoThumbnailBarPriv
gboolean auto_center;
gint begin;
gint end;
- RsttoNavigator *navigator;
- RsttoNavigatorIter *iter;
- RsttoNavigatorIter *internal_iter;
- GSList *thumbs;
+ RsttoImageList *image_list;
+ RsttoImageListIter *iter;
+ RsttoImageListIter *internal_iter;
+ GList *thumbs;
gint scroll_speed;
struct
{
@@ -67,11 +68,13 @@ static void
rstto_thumbnail_bar_unrealize(GtkWidget *widget);
static void
-cb_rstto_thumbnail_bar_navigator_new_image (RsttoNavigator *navigator, RsttoImage *image, gpointer user_data);
+cb_rstto_thumbnail_bar_image_list_new_image (RsttoImageList *image_list, RsttoImage *image, gpointer user_data);
static void
-cb_rstto_thumbnail_bar_navigator_remove_image (RsttoNavigator *navigator, RsttoImage *image, gpointer user_data);
+cb_rstto_thumbnail_bar_image_list_remove_image (RsttoImageList *image_list, RsttoImage *image, gpointer user_data);
+static void
+cb_rstto_thumbnail_bar_image_list_remove_all (RsttoImageList *image_list, gpointer user_data);
void
-cb_rstto_thumbnail_bar_navigator_iter_changed (RsttoNavigatorIter *iter, gpointer user_data);
+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);
@@ -196,14 +199,14 @@ rstto_thumbnail_bar_size_request(GtkWidget *widget, GtkRequisition *requisition)
gtk_widget_style_get(widget, "border-width", &border_width, NULL);
- GSList *iter;
+ GList *iter;
GtkRequisition child_requisition;
requisition->height = 70;
requisition->width = 70;
- for(iter = bar->priv->thumbs; iter; iter = g_slist_next(iter))
+ 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);
@@ -233,7 +236,7 @@ rstto_thumbnail_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
child_allocation.height = border_width * 2;
child_allocation.width = border_width * 2;
- GSList *iter = bar->priv->thumbs;
+ GList *iter = bar->priv->thumbs;
if (GTK_WIDGET_REALIZED(widget))
{
@@ -261,7 +264,7 @@ rstto_thumbnail_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
{
}
- iter = g_slist_next(iter);
+ iter = g_list_next(iter);
}
child_allocation.x -= bar->priv->offset;
@@ -284,7 +287,7 @@ rstto_thumbnail_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
gtk_widget_set_child_visible(GTK_WIDGET(iter->data), FALSE);
child_allocation.x += child_requisition.width + spacing;
- iter = g_slist_next(iter);
+ iter = g_list_next(iter);
}
break;
case GTK_ORIENTATION_VERTICAL:
@@ -301,7 +304,7 @@ rstto_thumbnail_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
{
}
- iter = g_slist_next(iter);
+ iter = g_list_next(iter);
}
child_allocation.y -= bar->priv->offset;
@@ -322,7 +325,7 @@ rstto_thumbnail_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
gtk_widget_size_allocate(GTK_WIDGET(iter->data), &child_allocation);
child_allocation.y += child_requisition.height + spacing;
- iter = g_slist_next(iter);
+ iter = g_list_next(iter);
}
break;
}
@@ -333,7 +336,7 @@ rstto_thumbnail_bar_expose(GtkWidget *widget, GdkEventExpose *ex)
{
RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR(widget);
- GSList *iter = bar->priv->thumbs;
+ GList *iter = bar->priv->thumbs;
GdkEventExpose *n_ex = g_new0(GdkEventExpose, 1);
@@ -427,7 +430,7 @@ rstto_thumbnail_bar_expose(GtkWidget *widget, GdkEventExpose *ex)
break;
}
}
- iter = g_slist_next(iter);
+ iter = g_list_next(iter);
}
return FALSE;
@@ -477,32 +480,33 @@ rstto_thumbnail_bar_unrealize(GtkWidget *widget)
}
GtkWidget *
-rstto_thumbnail_bar_new (RsttoNavigator *nav)
+rstto_thumbnail_bar_new (RsttoImageList *nav)
{
RsttoThumbnailBar *bar;
bar = g_object_new(RSTTO_TYPE_THUMBNAIL_BAR, NULL);
- rstto_thumbnail_bar_set_navigator (bar, nav);
+ rstto_thumbnail_bar_set_image_list (bar, nav);
return (GtkWidget *)bar;
}
void
-rstto_thumbnail_bar_set_navigator (RsttoThumbnailBar *bar, RsttoNavigator *nav)
+rstto_thumbnail_bar_set_image_list (RsttoThumbnailBar *bar, RsttoImageList *nav)
{
- if (bar->priv->navigator)
+ if (bar->priv->image_list)
{
- g_object_unref (bar->priv->navigator);
- bar->priv->navigator = NULL;
+ g_object_unref (bar->priv->image_list);
+ bar->priv->image_list = NULL;
}
- bar->priv->navigator = nav;
+ bar->priv->image_list = nav;
- if (bar->priv->navigator)
+ if (bar->priv->image_list)
{
- g_signal_connect (G_OBJECT (bar->priv->navigator), "new-image", G_CALLBACK (cb_rstto_thumbnail_bar_navigator_new_image), bar);
- g_signal_connect (G_OBJECT (bar->priv->navigator), "remove-image", G_CALLBACK (cb_rstto_thumbnail_bar_navigator_remove_image), bar);
+ g_signal_connect (G_OBJECT (bar->priv->image_list), "new-image", G_CALLBACK (cb_rstto_thumbnail_bar_image_list_new_image), bar);
+ g_signal_connect (G_OBJECT (bar->priv->image_list), "remove-image", G_CALLBACK (cb_rstto_thumbnail_bar_image_list_remove_image), 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);
}
}
@@ -542,7 +546,7 @@ rstto_thumbnail_bar_add(GtkContainer *container, GtkWidget *child)
gtk_widget_set_parent(child, GTK_WIDGET(container));
- bar->priv->thumbs = g_slist_insert_sorted (bar->priv->thumbs, child, (GCompareFunc)cb_rstto_thumbnail_bar_compare);
+ bar->priv->thumbs = g_list_insert_sorted (bar->priv->thumbs, child, (GCompareFunc)cb_rstto_thumbnail_bar_compare);
}
static void
@@ -555,7 +559,7 @@ rstto_thumbnail_bar_remove(GtkContainer *container, GtkWidget *child)
widget_was_visible = GTK_WIDGET_VISIBLE(child);
- bar->priv->thumbs = g_slist_remove(bar->priv->thumbs, child);
+ bar->priv->thumbs = g_list_remove(bar->priv->thumbs, child);
gtk_widget_unparent(child);
@@ -571,7 +575,7 @@ rstto_thumbnail_bar_forall(GtkContainer *container, gboolean include_internals,
g_return_if_fail(callback != NULL);
- g_slist_foreach(bar->priv->thumbs, (GFunc)callback, callback_data);
+ g_list_foreach(bar->priv->thumbs, (GFunc)callback, callback_data);
}
@@ -664,7 +668,7 @@ cb_rstto_thumbnail_bar_scroll_event (RsttoThumbnailBar *bar,
gpointer *user_data)
{
gint thumb_size;
- GSList *thumb;
+ GList *thumb;
gint border_width = GTK_CONTAINER(bar)->border_width;
switch(event->direction)
@@ -701,10 +705,10 @@ cb_rstto_thumbnail_bar_scroll_event (RsttoThumbnailBar *bar,
{
case GTK_ORIENTATION_HORIZONTAL:
thumb_size = GTK_WIDGET(bar->priv->thumbs->data)->allocation.width;
- for (thumb = bar->priv->thumbs; thumb != NULL; thumb = g_slist_next(thumb))
+ for (thumb = bar->priv->thumbs; thumb != NULL; thumb = g_list_next(thumb))
{
size += GTK_WIDGET(thumb->data)->allocation.width;
- if (g_slist_next(thumb))
+ if (g_list_next(thumb))
size += border_width;
}
if ((size - thumb_size) <= bar->priv->offset)
@@ -712,10 +716,10 @@ cb_rstto_thumbnail_bar_scroll_event (RsttoThumbnailBar *bar,
break;
case GTK_ORIENTATION_VERTICAL:
thumb_size = GTK_WIDGET(bar->priv->thumbs->data)->allocation.height;
- for (thumb = bar->priv->thumbs; thumb != NULL; thumb = g_slist_next(thumb))
+ for (thumb = bar->priv->thumbs; thumb != NULL; thumb = g_list_next(thumb))
{
size += GTK_WIDGET(thumb->data)->allocation.height;
- if (g_slist_next(thumb))
+ if (g_list_next(thumb))
size += border_width;
}
if ((size - thumb_size) <= bar->priv->offset)
@@ -731,11 +735,11 @@ cb_rstto_thumbnail_bar_scroll_event (RsttoThumbnailBar *bar,
}
void
-rstto_thumbnail_bar_set_iter (RsttoThumbnailBar *bar, RsttoNavigatorIter *iter)
+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_navigator_iter_changed, bar);
+ 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);
@@ -747,33 +751,63 @@ rstto_thumbnail_bar_set_iter (RsttoThumbnailBar *bar, RsttoNavigatorIter *iter)
if (bar->priv->iter)
{
g_object_ref (bar->priv->iter);
- bar->priv->internal_iter = rstto_navigator_iter_clone (bar->priv->iter);
- g_signal_connect (bar->priv->iter, "changed", G_CALLBACK (cb_rstto_thumbnail_bar_navigator_iter_changed), bar);
+ 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_navigator_iter_changed (RsttoNavigatorIter *iter, gpointer user_data)
+cb_rstto_thumbnail_bar_image_list_iter_changed (RsttoImageListIter *iter, gpointer user_data)
{
RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR (user_data);
}
static void
-cb_rstto_thumbnail_bar_navigator_new_image (RsttoNavigator *navigator, RsttoImage *image, gpointer user_data)
+cb_rstto_thumbnail_bar_image_list_new_image (RsttoImageList *image_list, RsttoImage *image, gpointer user_data)
{
RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR (user_data);
- g_return_if_fail (rstto_navigator_iter_find_image (bar->priv->internal_iter, image));
+ g_return_if_fail (rstto_image_list_iter_find_image (bar->priv->internal_iter, image));
+
+ GtkWidget *thumb = rstto_thumbnail_new (image);
+ gtk_container_add (GTK_CONTAINER (bar), thumb);
+ gtk_widget_show (thumb);
- GtkWidget *test = gtk_button_new_with_label (_("Test"));
- gtk_container_add (GTK_CONTAINER (bar), test);
- gtk_widget_show (test);
+ 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_image (RsttoImageList *image_list, RsttoImage *image, gpointer user_data)
+{
+ RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR (user_data);
+ GList *iter = bar->priv->thumbs;
+
+ while (iter)
+ {
+ if (rstto_thumbnail_get_image (iter->data) == image)
+ {
+ GtkWidget *widget = iter->data;
+ rstto_thumbnail_bar_remove (bar, widget);
+ break;
+ }
+ iter = g_list_next (iter);
+ }
}
static void
-cb_rstto_thumbnail_bar_navigator_remove_image (RsttoNavigator *navigator, RsttoImage *image, gpointer user_data)
+cb_rstto_thumbnail_bar_image_list_remove_all (RsttoImageList *image_list, gpointer user_data)
{
RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR (user_data);
+}
-
+
+
+static void
+cb_rstto_thumbnail_bar_thumbnail_clicked (GtkWidget *thumb, RsttoThumbnailBar *bar)
+{
+ g_return_if_fail (bar->priv->iter);
+ rstto_image_list_iter_set_position (bar->priv->iter, g_list_index(bar->priv->thumbs, thumb));
}
diff --git a/src/thumbnail_bar.h b/src/thumbnail_bar.h
index 03ca2b3..e5cb3cb 100644
--- a/src/thumbnail_bar.h
+++ b/src/thumbnail_bar.h
@@ -63,8 +63,8 @@ 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_navigator (RsttoThumbnailBar *bar, RsttoNavigator *nav);
-void rstto_thumbnail_bar_set_iter (RsttoThumbnailBar *bar, RsttoNavigatorIter *iter);
+void rstto_thumbnail_bar_set_image_list (RsttoThumbnailBar *bar, RsttoImageList *nav);
+void rstto_thumbnail_bar_set_iter (RsttoThumbnailBar *bar, RsttoImageListIter *iter);
G_END_DECLS
More information about the Xfce4-commits
mailing list