[Xfce4-commits] <ristretto:master> Add basic thumbnail-bar with test-items
Stephan Arts
stephan at xfce.org
Wed Aug 12 12:19:51 CEST 2009
Updating branch refs/heads/master
to 61955d3c7a4e42a5de0e19ef738a9db9faa52b82 (commit)
from 23bec501b47a85cc805b93ee63c8afe5bbb36d7b (commit)
commit 61955d3c7a4e42a5de0e19ef738a9db9faa52b82
Author: Stephan Arts <stephan at xfce.org>
Date: Thu May 28 16:04:18 2009 +0200
Add basic thumbnail-bar with test-items
src/Makefile.am | 4 +-
src/image_cache.c | 4 +-
src/main_window.c | 27 +++-
src/main_window_ui.xml | 8 +-
src/navigator.c | 323 +++++++++++++++++++++++++++++++-----------------
src/navigator.h | 39 ++++++-
src/picture_viewer.c | 2 +-
src/thumbnail_bar.c | 305 +++++++++++++--------------------------------
src/thumbnail_bar.h | 3 +
9 files changed, 371 insertions(+), 344 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 0f31f46..98a414e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,10 +9,10 @@ ristretto_SOURCES = \
preferences_dialog.h preferences_dialog.c \
main_window_ui.h \
main_window.c main_window.h \
+ thumbnail_bar.c thumbnail_bar.h \
main.c
# save_dialog.h save_dialog.c
-# thumbnail.c thumbnail.h \
-# thumbnail_bar.c thumbnail_bar.h
+# thumbnail.c thumbnail.h
ristretto_CFLAGS = \
$(GTK_CFLAGS) \
diff --git a/src/image_cache.c b/src/image_cache.c
index ce6a1fc..9055f6b 100644
--- a/src/image_cache.c
+++ b/src/image_cache.c
@@ -123,12 +123,12 @@ rstto_image_cache_push_image (RsttoImageCache *cache, RsttoImage *image, gboolea
*/
if (cache_enabled == FALSE)
{
- g_debug ("cache disable");
while (g_list_length (cache->cache_list) > 1)
{
c_image = g_list_last (cache->cache_list)->data;
rstto_image_unload (c_image);
cache->cache_list = g_list_remove (cache->cache_list, c_image);
+ g_object_unref (c_image);
retval = TRUE;
}
}
@@ -144,6 +144,7 @@ rstto_image_cache_push_image (RsttoImageCache *cache, RsttoImage *image, gboolea
{
rstto_image_unload (c_image);
cache->cache_list = g_list_remove (cache->cache_list, c_image);
+ g_object_unref (c_image);
iter = g_list_previous(iter);
retval = TRUE;
}
@@ -154,6 +155,7 @@ rstto_image_cache_push_image (RsttoImageCache *cache, RsttoImage *image, gboolea
{
rstto_image_unload (c_image);
cache->cache_list = g_list_remove (cache->cache_list, c_image);
+ g_object_unref (c_image);
iter = g_list_previous(iter);
}
}
diff --git a/src/main_window.c b/src/main_window.c
index 22559d0..fd95703 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -77,6 +77,7 @@ struct _RsttoMainWindowPriv
GtkWidget *picture_viewer;
GtkWidget *p_viewer_s_window;
GtkWidget *hpaned;
+ GtkWidget *thumbnail_bar;
GtkWidget *statusbar;
guint t_open_merge_id;
@@ -263,8 +264,8 @@ static GtkActionEntry action_entries[] =
{ "zoom-100", GTK_STOCK_ZOOM_100, N_ ("_Normal Size"), "<control>0", NULL, G_CALLBACK (cb_rstto_main_window_zoom_100), },
/* Rotation submenu */
{ "rotation-menu", NULL, N_ ("_Rotation"), NULL, },
- { "rotate-cw", NULL, N_ ("Rotate _Right"), "<control>bracketright", NULL, G_CALLBACK (cb_rstto_main_window_rotate_cw), },
- { "rotate-ccw", NULL, N_ ("Rotate _Left"), "<contron>bracketleft", NULL, G_CALLBACK (cb_rstto_main_window_rotate_ccw), },
+ { "rotate-cw", "object-rotate-right", N_ ("Rotate _Right"), "<control>bracketright", NULL, G_CALLBACK (cb_rstto_main_window_rotate_cw), },
+ { "rotate-ccw", "object-rotate-left", N_ ("Rotate _Left"), "<contron>bracketleft", NULL, G_CALLBACK (cb_rstto_main_window_rotate_ccw), },
/* Go Menu */
{ "go-menu", NULL, N_ ("_Go"), NULL, },
{ "forward", GTK_STOCK_GO_FORWARD, N_ ("_Forward"), "space", NULL, G_CALLBACK (cb_rstto_main_window_next_image), },
@@ -427,9 +428,10 @@ rstto_main_window_init (RsttoMainWindow *window)
window->priv->p_viewer_s_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (window->priv->p_viewer_s_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER (window->priv->p_viewer_s_window), window->priv->picture_viewer);
+ window->priv->thumbnail_bar = rstto_thumbnail_bar_new (NULL);
window->priv->hpaned = gtk_hpaned_new();
- gtk_paned_pack1 (GTK_PANED (window->priv->hpaned), window->priv->p_viewer_s_window, FALSE, FALSE);
- gtk_paned_add2 (GTK_PANED (window->priv->hpaned), rstto_thumbnail_bar_new());
+ gtk_paned_pack1 (GTK_PANED (window->priv->hpaned), window->priv->p_viewer_s_window, TRUE, FALSE);
+ gtk_paned_pack2 (GTK_PANED (window->priv->hpaned), window->priv->thumbnail_bar, FALSE, FALSE);
window->priv->statusbar = gtk_statusbar_new();
@@ -727,7 +729,7 @@ rstto_main_window_set_property (GObject *object,
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);
- rstto_navigator_iter_free (window->priv->iter);
+ g_object_unref (window->priv->iter);
window->priv->iter = NULL;
}
@@ -740,6 +742,8 @@ rstto_main_window_set_property (GObject *object,
g_signal_connect (G_OBJECT (window->priv->props.navigator), "remove-image", G_CALLBACK (cb_rstto_main_window_navigator_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);
+ rstto_thumbnail_bar_set_iter (RSTTO_THUMBNAIL_BAR (window->priv->thumbnail_bar), window->priv->iter);
}
break;
default:
@@ -1043,7 +1047,10 @@ cb_rstto_main_window_open_image (GtkWidget *widget, RsttoMainWindow *window)
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);
}
@@ -1120,7 +1127,10 @@ cb_rstto_main_window_open_folder (GtkWidget *widget, RsttoMainWindow *window)
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);
}
@@ -1194,7 +1204,10 @@ cb_rstto_main_window_open_recent(GtkRecentChooser *chooser, RsttoMainWindow *win
}
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);
@@ -1631,8 +1644,8 @@ cb_rstto_main_window_navigator_new_image (RsttoNavigator *navigator, RsttoImage
if (window->priv->iter == NULL)
{
window->priv->iter = rstto_navigator_get_iter (navigator);
- rstto_main_window_navigator_iter_changed (window);
}
+ rstto_main_window_navigator_iter_changed (window);
}
/**
@@ -1649,7 +1662,7 @@ cb_rstto_main_window_navigator_remove_image (RsttoNavigator *navigator, RsttoIma
{
if (window->priv->iter)
{
- rstto_navigator_iter_free (window->priv->iter);
+ g_object_unref (window->priv->iter);
window->priv->iter = rstto_navigator_get_iter (navigator);
}
}
diff --git a/src/main_window_ui.xml b/src/main_window_ui.xml
index b55ac10..517726f 100644
--- a/src/main_window_ui.xml
+++ b/src/main_window_ui.xml
@@ -70,6 +70,9 @@
<toolitem action="open-folder"/>
<separator />
<toolitem action="save-copy"/>
+ <toolitem action="close"/>
+ <toolitem action="delete"/>
+ <separator />
</toolbar>
<!--
@@ -80,11 +83,14 @@
<placeholder name="placeholder-slideshow" />
<toolitem action="forward"/>
<separator name="separator-1"/>
+ <toolitem action="rotate-ccw"/>
+ <toolitem action="rotate-cw"/>
+ <separator />
<toolitem action="zoom-in"/>
<toolitem action="zoom-out"/>
<toolitem action="zoom-100"/>
<toolitem action="zoom-fit"/>
- <separator name="separator-1"/>
+ <separator />
<placeholder name="placeholder-fullscreen" />
</toolbar>
diff --git a/src/navigator.c b/src/navigator.c
index 665e754..fec2eea 100644
--- a/src/navigator.c
+++ b/src/navigator.c
@@ -35,10 +35,20 @@ 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
{
@@ -47,7 +57,13 @@ enum
RSTTO_NAVIGATOR_SIGNAL_COUNT
};
-struct _RsttoNavigatorIter
+enum
+{
+ RSTTO_NAVIGATOR_ITER_SIGNAL_CHANGED = 0,
+ RSTTO_NAVIGATOR_ITER_SIGNAL_COUNT
+};
+
+struct _RsttoNavigatorIterPriv
{
RsttoNavigator *navigator;
RsttoImage *image;
@@ -61,6 +77,7 @@ struct _RsttoNavigatorPriv
};
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 ()
@@ -168,189 +185,269 @@ rstto_navigator_get_n_images (RsttoNavigator *navigator)
RsttoNavigatorIter *
rstto_navigator_get_iter (RsttoNavigator *navigator)
{
- RsttoNavigatorIter *iter = g_new0 (RsttoNavigatorIter, 1);
- iter->navigator = navigator;
+ RsttoImage *image = NULL;
if (navigator->priv->images)
- iter->image = navigator->priv->images->data;
+ image = navigator->priv->images->data;
- if (iter->image)
- g_object_ref (iter->image);
- else
- iter->position = -1;
+ 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->image == NULL)
+ if (iter->priv->image == NULL)
{
- if ((iter->position == -1) && (rstto_navigator_get_n_images (iter->navigator) > 0))
+ if ((iter->priv->position == -1) && (rstto_navigator_get_n_images (iter->priv->navigator) > 0))
{
rstto_navigator_iter_set_position (iter, 0);
}
}
- return iter->position;
+ return iter->priv->position;
}
RsttoImage *
rstto_navigator_iter_get_image (RsttoNavigatorIter *iter)
{
- if (iter->image == NULL)
+ if (iter->priv->image == NULL)
{
- if ((iter->position == -1) && (rstto_navigator_get_n_images (iter->navigator) > 0))
+ 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->image);
+ return RSTTO_IMAGE (iter->priv->image);
}
gboolean
rstto_navigator_iter_set_position (RsttoNavigatorIter *iter, gint pos)
{
- if (iter->image)
+ if (iter->priv->image)
{
- g_object_unref (iter->image);
- iter->image = NULL;
+ g_object_unref (iter->priv->image);
+ iter->priv->image = NULL;
}
- iter->image = g_list_nth_data (iter->navigator->priv->images, pos);
- if (iter->image)
+ iter->priv->image = g_list_nth_data (iter->priv->navigator->priv->images, pos);
+ if (iter->priv->image)
{
- iter->position = pos;
- g_object_ref (iter->image);
+ iter->priv->position = pos;
+ g_object_ref (iter->priv->image);
}
else
{
- iter->position = -1;
+ 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->image)
+ if (iter->priv->image)
{
- g_object_unref (iter->image);
- iter->image = NULL;
+ g_object_unref (iter->priv->image);
+ iter->priv->image = NULL;
}
- iter->image = g_list_nth_data (iter->navigator->priv->images, iter->position+1);
- if (iter->image)
+ iter->priv->image = g_list_nth_data (iter->priv->navigator->priv->images, iter->priv->position+1);
+ if (iter->priv->image)
{
- iter->position++;
+ iter->priv->position++;
}
else
{
- iter->position = 0;
- iter->image = g_list_nth_data (iter->navigator->priv->images, 0);
- if (iter->image == NULL)
+ iter->priv->position = 0;
+ iter->priv->image = g_list_nth_data (iter->priv->navigator->priv->images, 0);
+ if (iter->priv->image == NULL)
{
- iter->position = -1;
+ iter->priv->position = -1;
}
}
- if (iter->image)
- g_object_ref (iter->image);
+ 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->image)
+ if (iter->priv->image)
{
- g_object_unref (iter->image);
- iter->image = NULL;
+ g_object_unref (iter->priv->image);
+ iter->priv->image = NULL;
}
- iter->image = g_list_nth_data (iter->navigator->priv->images, iter->position-1);
- if (iter->image)
+ iter->priv->image = g_list_nth_data (iter->priv->navigator->priv->images, iter->priv->position-1);
+ if (iter->priv->image)
{
- iter->position--;
+ iter->priv->position--;
}
else
{
- iter->position = g_list_length (iter->navigator->priv->images)-1;
- iter->image = g_list_nth_data (iter->navigator->priv->images, iter->position);
- if (iter->image == NULL)
- {
- iter->position = -1;
- }
- }
- if (iter->image)
- g_object_ref (iter->image);
-}
-
-void
-rstto_navigator_iter_free (RsttoNavigatorIter *iter)
-{
- if (iter->image)
- {
- g_object_unref (iter->image);
- iter->image = NULL;
- }
- g_free (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;
-}
-
-gboolean
-rstto_navigator_iter_find_image (RsttoNavigatorIter *iter, RsttoImage *image)
-{
- gint pos = g_list_index (iter->navigator->priv->images, image);
- if (pos > -1)
- {
- if (iter->image)
+ 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)
{
- g_object_unref (iter->image);
- iter->image = NULL;
+ iter->priv->position = -1;
}
- iter->image = image;
- g_object_ref (iter->image);
- return TRUE;
}
- return FALSE;
+ 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);
}
-/**
- * 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)
+RsttoNavigatorIter *
+rstto_navigator_iter_clone (RsttoNavigatorIter *iter)
{
- 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;
+ RsttoNavigatorIter *new_iter = rstto_navigator_iter_new (iter->priv->navigator, iter->priv->image);
+ new_iter->priv->position = iter->priv->position;
- result = g_strcasecmp (a_base, b_base);
-
- g_free (a_base);
- g_free (b_base);
- return result;
+ return new_iter;
}
diff --git a/src/navigator.h b/src/navigator.h
index 07fdc5c..cc97fdd 100644
--- a/src/navigator.h
+++ b/src/navigator.h
@@ -56,7 +56,40 @@ 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 ();
@@ -67,19 +100,19 @@ gboolean rstto_navigator_add_file (RsttoNavigator *navigator, GFile *file, GErro
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_iter_free (RsttoNavigatorIter *iter);
-
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
diff --git a/src/picture_viewer.c b/src/picture_viewer.c
index 7a1f7b0..9552a6f 100644
--- a/src/picture_viewer.c
+++ b/src/picture_viewer.c
@@ -595,7 +595,7 @@ rstto_picture_viewer_paint (GtkWidget *widget)
(size*0.8),
GTK_ICON_LOOKUP_FORCE_SIZE, NULL);
gdk_pixbuf_saturate_and_pixelate (pixbuf, pixbuf, 0, TRUE);
- pixbuf = gdk_pixbuf_composite_color_simple (pixbuf, (size*0.8), (size*0.8), GDK_INTERP_BILINEAR, 50, 50, bg_color->pixel, bg_color->pixel);
+ pixbuf = gdk_pixbuf_composite_color_simple (pixbuf, (size*0.8), (size*0.8), GDK_INTERP_BILINEAR, 40, 40, bg_color->pixel, bg_color->pixel);
gint x1 = (widget->allocation.width-gdk_pixbuf_get_width(pixbuf))<0?0:(widget->allocation.width-gdk_pixbuf_get_width(pixbuf))/2;
gint y1 = (widget->allocation.height-gdk_pixbuf_get_height(pixbuf))<0?0:(widget->allocation.height-gdk_pixbuf_get_height(pixbuf))/2;
diff --git a/src/thumbnail_bar.c b/src/thumbnail_bar.c
index 2ef0514..f003b36 100644
--- a/src/thumbnail_bar.c
+++ b/src/thumbnail_bar.c
@@ -19,22 +19,26 @@
#include <gtk/gtkmarshal.h>
#include <string.h>
-#include <thunar-vfs/thunar-vfs.h>
+#include <gio/gio.h>
+
+#include <libxfcegui4/libxfcegui4.h>
#include <libexif/exif-data.h>
+#include "image.h"
#include "navigator.h"
-#include "thumbnail.h"
#include "thumbnail_bar.h"
struct _RsttoThumbnailBarPriv
{
GtkOrientation orientation;
- RsttoNavigator *navigator;
gint dimension;
gint offset;
gboolean auto_center;
gint begin;
gint end;
+ RsttoNavigator *navigator;
+ RsttoNavigatorIter *iter;
+ RsttoNavigatorIter *internal_iter;
GSList *thumbs;
gint scroll_speed;
struct
@@ -62,12 +66,19 @@ rstto_thumbnail_bar_realize(GtkWidget *widget);
static void
rstto_thumbnail_bar_unrealize(GtkWidget *widget);
+static void
+cb_rstto_thumbnail_bar_navigator_new_image (RsttoNavigator *navigator, RsttoImage *image, gpointer user_data);
+static void
+cb_rstto_thumbnail_bar_navigator_remove_image (RsttoNavigator *navigator, RsttoImage *image, gpointer user_data);
+void
+cb_rstto_thumbnail_bar_navigator_iter_changed (RsttoNavigatorIter *iter, gpointer user_data);
+
static gboolean
-cb_rstto_thumbnail_bar_thumbnail_button_press_event (RsttoThumbnail *thumb, GdkEventButton *event);
+cb_rstto_thumbnail_bar_thumbnail_button_press_event (GtkWidget *thumb, GdkEventButton *event);
static gboolean
-cb_rstto_thumbnail_bar_thumbnail_button_release_event (RsttoThumbnail *thumb, GdkEventButton *event);
+cb_rstto_thumbnail_bar_thumbnail_button_release_event (GtkWidget *thumb, GdkEventButton *event);
static gboolean
-cb_rstto_thumbnail_bar_thumbnail_motion_notify_event (RsttoThumbnail *thumb,
+cb_rstto_thumbnail_bar_thumbnail_motion_notify_event (GtkWidget *thumb,
GdkEventMotion *event,
gpointer user_data);
@@ -88,28 +99,10 @@ rstto_thumbnail_bar_child_type(GtkContainer *container);
static GtkWidgetClass *parent_class = NULL;
static void
-cb_rstto_thumbnail_bar_nav_new_entry (RsttoNavigator *nav,
- gint nr,
- RsttoNavigatorEntry *entry,
- RsttoThumbnailBar *bar);
-static void
-cb_rstto_thumbnail_bar_nav_iter_changed (RsttoNavigator *nav,
- gint nr,
- RsttoNavigatorEntry *entry,
- RsttoThumbnailBar *bar);
-static void
-cb_rstto_thumbnail_bar_nav_reordered (RsttoNavigator *nav,
- RsttoThumbnailBar *bar);
-static void
-cb_rstto_thumbnail_bar_nav_entry_removed(RsttoNavigator *nav,
- RsttoNavigatorEntry *entry,
- RsttoThumbnailBar *bar);
-
-static void
-cb_rstto_thumbnail_bar_thumbnail_clicked (RsttoThumbnail *thumb, RsttoThumbnailBar *bar);
+cb_rstto_thumbnail_bar_thumbnail_clicked (GtkWidget *thumb, RsttoThumbnailBar *bar);
static gint
-cb_rstto_thumbnail_bar_compare (RsttoThumbnail *a, RsttoThumbnail *b);
+cb_rstto_thumbnail_bar_compare (GtkWidget *a, GtkWidget *b);
GType
rstto_thumbnail_bar_get_type ()
@@ -150,7 +143,7 @@ rstto_thumbnail_bar_init(RsttoThumbnailBar *bar)
gtk_widget_set_events (GTK_WIDGET(bar),
GDK_SCROLL_MASK);
- bar->priv->orientation = GTK_ORIENTATION_HORIZONTAL;
+ bar->priv->orientation = GTK_ORIENTATION_VERTICAL;
bar->priv->offset = 0;
bar->priv->scroll_speed = 20;
@@ -266,14 +259,6 @@ rstto_thumbnail_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
if (bar->priv->auto_center == TRUE)
{
- if (g_slist_position(bar->priv->thumbs, iter) < rstto_navigator_get_position(bar->priv->navigator))
- {
- bar->priv->offset += child_requisition.width + spacing;
- }
- if (g_slist_position(bar->priv->thumbs, iter) == rstto_navigator_get_position(bar->priv->navigator))
- {
- bar->priv->offset += (0.5 * child_requisition.width);
- }
}
iter = g_slist_next(iter);
@@ -314,14 +299,6 @@ rstto_thumbnail_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
if (bar->priv->auto_center == TRUE)
{
- if (g_slist_position(bar->priv->thumbs, iter) < rstto_navigator_get_position(bar->priv->navigator))
- {
- bar->priv->offset += child_requisition.height + spacing;
- }
- if (g_slist_position(bar->priv->thumbs, iter) == rstto_navigator_get_position(bar->priv->navigator))
- {
- bar->priv->offset += (0.5 * child_requisition.height);
- }
}
iter = g_slist_next(iter);
@@ -500,22 +477,36 @@ rstto_thumbnail_bar_unrealize(GtkWidget *widget)
}
GtkWidget *
-rstto_thumbnail_bar_new(RsttoNavigator *navigator)
+rstto_thumbnail_bar_new (RsttoNavigator *nav)
{
RsttoThumbnailBar *bar;
bar = g_object_new(RSTTO_TYPE_THUMBNAIL_BAR, NULL);
- bar->priv->navigator = navigator;
-
- g_signal_connect(G_OBJECT(navigator), "new-entry", G_CALLBACK(cb_rstto_thumbnail_bar_nav_new_entry), bar);
- g_signal_connect(G_OBJECT(navigator), "iter-changed", G_CALLBACK(cb_rstto_thumbnail_bar_nav_iter_changed), bar);
- g_signal_connect(G_OBJECT(navigator), "reordered", G_CALLBACK(cb_rstto_thumbnail_bar_nav_reordered), bar);
- g_signal_connect(G_OBJECT(navigator), "entry-removed", G_CALLBACK(cb_rstto_thumbnail_bar_nav_entry_removed), bar);
+ rstto_thumbnail_bar_set_navigator (bar, nav);
return (GtkWidget *)bar;
}
+void
+rstto_thumbnail_bar_set_navigator (RsttoThumbnailBar *bar, RsttoNavigator *nav)
+{
+ if (bar->priv->navigator)
+ {
+ g_object_unref (bar->priv->navigator);
+ bar->priv->navigator = NULL;
+ }
+
+ bar->priv->navigator = nav;
+
+ if (bar->priv->navigator)
+ {
+ 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_object_ref (nav);
+ }
+}
+
/*
* rstto_thumbnail_bar_set_orientation:
*
@@ -551,7 +542,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_slist_insert_sorted (bar->priv->thumbs, child, (GCompareFunc)cb_rstto_thumbnail_bar_compare);
}
static void
@@ -590,163 +581,14 @@ rstto_thumbnail_bar_child_type(GtkContainer *container)
return GTK_TYPE_WIDGET;
}
-/*
- * cb_rstto_thumbnail_bar_nav_new_entry :
- *
- * @nav : RsttoNavigator
- * @nr : nr
- * @entry :
- * @bar :
- *
- */
-static void
-cb_rstto_thumbnail_bar_nav_new_entry(RsttoNavigator *nav, gint nr, RsttoNavigatorEntry *entry, RsttoThumbnailBar *bar)
-{
- GtkWidget *thumb;
- if (g_slist_length(bar->priv->thumbs) > 0)
- {
- thumb = rstto_thumbnail_new_from_widget(entry, bar->priv->thumbs->data);
- }
- else
- {
- thumb = rstto_thumbnail_new(entry, NULL);
- }
- g_signal_connect(G_OBJECT(thumb), "clicked", G_CALLBACK(cb_rstto_thumbnail_bar_thumbnail_clicked), bar);
- g_signal_connect(G_OBJECT(thumb), "button_press_event", G_CALLBACK(cb_rstto_thumbnail_bar_thumbnail_button_press_event), NULL);
- g_signal_connect(G_OBJECT(thumb), "button_release_event", G_CALLBACK(cb_rstto_thumbnail_bar_thumbnail_button_release_event), NULL);
- g_signal_connect(G_OBJECT(thumb), "motion_notify_event", G_CALLBACK(cb_rstto_thumbnail_bar_thumbnail_motion_notify_event), NULL);
- gtk_container_add(GTK_CONTAINER(bar), thumb);
- gtk_widget_show(thumb);
-}
-
-/*
- * cb_rstto_thumbnail_bar_nav_iter_changed :
- *
- * @nav : RsttoNavigator
- * @nr : nr
- * @entry :
- * @bar :
- *
- */
-static void
-cb_rstto_thumbnail_bar_nav_iter_changed(RsttoNavigator *nav, gint nr, RsttoNavigatorEntry *entry, RsttoThumbnailBar *bar)
-{
- if (nr == -1)
- {
- gtk_container_foreach(GTK_CONTAINER(bar), (GtkCallback)gtk_widget_destroy, NULL);
- }
- GSList *iter = bar->priv->thumbs;
-
-
- int i = 0;
-
- while (iter != NULL)
- {
- if (entry == rstto_thumbnail_get_entry(RSTTO_THUMBNAIL(iter->data)))
- {
- //gtk_button_clicked(GTK_BUTTON(iter->data));
- break;
- }
- i++;
- iter = g_slist_next(iter);
- }
-
- /* If the children should be autocentered... resize */
- /*
- * if (bar->priv->auto_center == TRUE)
- * gtk_widget_queue_resize(GTK_WIDGET(bar));
- */
-
- gtk_widget_queue_resize(GTK_WIDGET(bar));
-}
-
-/*
- * cb_rstto_thumbnail_bar_nav_reordered :
- *
- * @nav : RsttoNavigator
- * @bar :
- *
- */
-static void
-cb_rstto_thumbnail_bar_nav_reordered (RsttoNavigator *nav, RsttoThumbnailBar *bar)
-{
- gtk_container_foreach(GTK_CONTAINER(bar), (GtkCallback)gtk_widget_destroy, NULL);
- if (bar->priv->thumbs)
- {
- g_slist_free(bar->priv->thumbs);
- bar->priv->thumbs = NULL;
- }
-
- GtkWidget *thumb;
- gint i;
- gint n_files = rstto_navigator_get_n_files(bar->priv->navigator);
-
- for (i = 0; i < n_files; ++i)
- {
- RsttoNavigatorEntry *entry = rstto_navigator_get_nth_file(bar->priv->navigator, i);
- if (g_slist_length(bar->priv->thumbs) > 0)
- {
- thumb = rstto_thumbnail_new_from_widget(entry, bar->priv->thumbs->data);
- }
- else
- {
- thumb = rstto_thumbnail_new(entry, NULL);
- }
-
-
- g_signal_connect(G_OBJECT(thumb), "clicked", G_CALLBACK(cb_rstto_thumbnail_bar_thumbnail_clicked), bar);
- g_signal_connect(G_OBJECT(thumb), "button_press_event", G_CALLBACK(cb_rstto_thumbnail_bar_thumbnail_button_press_event), NULL);
- g_signal_connect(G_OBJECT(thumb), "button_release_event", G_CALLBACK(cb_rstto_thumbnail_bar_thumbnail_button_release_event), NULL);
- g_signal_connect(G_OBJECT(thumb), "motion_notify_event", G_CALLBACK(cb_rstto_thumbnail_bar_thumbnail_motion_notify_event), NULL);
- gtk_container_add(GTK_CONTAINER(bar), thumb);
-
- if (rstto_navigator_entry_is_selected(entry))
- {
- RSTTO_THUMBNAIL(thumb)->selected = TRUE;
- }
- }
-
- gtk_container_foreach(GTK_CONTAINER(bar), (GtkCallback)gtk_widget_show, NULL);
-
-
-
- /* If the children should be autocentered... resize */
- /*
- * if (bar->priv->auto_center == TRUE)
- * gtk_widget_queue_resize(GTK_WIDGET(bar));
- */
-
- gtk_widget_queue_resize(GTK_WIDGET(bar));
-}
-
-static void
-cb_rstto_thumbnail_bar_thumbnail_clicked (RsttoThumbnail *thumb, RsttoThumbnailBar *bar)
-{
- if (thumb->selected == TRUE)
- {
- bar->priv->auto_center = TRUE;
- rstto_navigator_entry_select (rstto_thumbnail_get_entry(thumb));
- }
-}
-
static gint
-cb_rstto_thumbnail_bar_compare (RsttoThumbnail *a, RsttoThumbnail *b)
+cb_rstto_thumbnail_bar_compare (GtkWidget *a, GtkWidget *b)
{
- RsttoNavigatorEntry *_a = rstto_thumbnail_get_entry(a);
- RsttoNavigatorEntry *_b = rstto_thumbnail_get_entry(b);
-
- if (rstto_navigator_entry_get_position(_a) < rstto_navigator_entry_get_position(_b))
- {
- return -1;
- }
- else
- {
- return 1;
- }
+ return -1;
}
static gboolean
-cb_rstto_thumbnail_bar_thumbnail_button_press_event (RsttoThumbnail *thumb, GdkEventButton *event)
+cb_rstto_thumbnail_bar_thumbnail_button_press_event (GtkWidget *thumb, GdkEventButton *event)
{
if(event->button == 1)
{
@@ -769,7 +611,7 @@ cb_rstto_thumbnail_bar_thumbnail_button_press_event (RsttoThumbnail *thumb, GdkE
}
static gboolean
-cb_rstto_thumbnail_bar_thumbnail_button_release_event (RsttoThumbnail *thumb, GdkEventButton *event)
+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)
@@ -786,7 +628,7 @@ cb_rstto_thumbnail_bar_thumbnail_button_release_event (RsttoThumbnail *thumb, Gd
}
static gboolean
-cb_rstto_thumbnail_bar_thumbnail_motion_notify_event (RsttoThumbnail *thumb,
+cb_rstto_thumbnail_bar_thumbnail_motion_notify_event (GtkWidget *thumb,
GdkEventMotion *event,
gpointer user_data)
{
@@ -888,19 +730,50 @@ cb_rstto_thumbnail_bar_scroll_event (RsttoThumbnailBar *bar,
}
-static void
-cb_rstto_thumbnail_bar_nav_entry_removed(RsttoNavigator *nav, RsttoNavigatorEntry *entry, RsttoThumbnailBar *bar)
+void
+rstto_thumbnail_bar_set_iter (RsttoThumbnailBar *bar, RsttoNavigatorIter *iter)
{
- GSList *iter = bar->priv->thumbs;
+ if (bar->priv->iter)
+ {
+ g_signal_handlers_disconnect_by_func (bar->priv->iter, cb_rstto_thumbnail_bar_navigator_iter_changed, bar);
+
+ g_object_unref (bar->priv->iter);
+ g_object_unref (bar->priv->internal_iter);
+ bar->priv->internal_iter = NULL;
+ }
- while (iter != NULL)
+ bar->priv->iter = iter;
+
+ if (bar->priv->iter)
{
- if (entry == rstto_thumbnail_get_entry(RSTTO_THUMBNAIL(iter->data)))
- {
- g_signal_handlers_disconnect_by_func(G_OBJECT(iter->data), G_CALLBACK(cb_rstto_thumbnail_bar_thumbnail_clicked), bar);
- gtk_widget_destroy(GTK_WIDGET(iter->data));
- break;
- }
- iter = g_slist_next(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);
}
}
+
+void
+cb_rstto_thumbnail_bar_navigator_iter_changed (RsttoNavigatorIter *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)
+{
+ RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR (user_data);
+
+ g_return_if_fail (rstto_navigator_iter_find_image (bar->priv->internal_iter, image));
+
+ GtkWidget *test = gtk_button_new_with_label (_("Test"));
+ gtk_container_add (GTK_CONTAINER (bar), test);
+ gtk_widget_show (test);
+}
+
+static void
+cb_rstto_thumbnail_bar_navigator_remove_image (RsttoNavigator *navigator, RsttoImage *image, gpointer user_data)
+{
+ RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR (user_data);
+
+
+}
diff --git a/src/thumbnail_bar.h b/src/thumbnail_bar.h
index bb4c687..03ca2b3 100644
--- a/src/thumbnail_bar.h
+++ b/src/thumbnail_bar.h
@@ -63,6 +63,9 @@ 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);
+
G_END_DECLS
#endif /* __RISTRETTO_THUMBNAIL_BAR_H__ */
More information about the Xfce4-commits
mailing list