Commit 062b0f1f authored by Stephan Arts's avatar Stephan Arts

Images can only be opened once

parent 2366de5b
2009-09-26 Stephan Arts <stephan@xfce.org>
* src/main_window.c,
src/image_list.c,
src/thumbnailbar.c: Images can only be opened once
2009-09-26 Stephan Arts <stephan@xfce.org>
* src/wallpaper_manager.h,
......
......@@ -5,7 +5,8 @@
* 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,
*
* 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.
......@@ -47,6 +48,8 @@ static gint
cb_rstto_image_list_image_name_compare_func (RsttoImage *a, RsttoImage *b);
static gint
cb_rstto_image_list_exif_date_compare_func (RsttoImage *a, RsttoImage *b);
static gint
cb_rstto_image_list_file_compare_func (RsttoImage *a, GFile *file);
static GObjectClass *parent_class = NULL;
static GObjectClass *iter_parent_class = NULL;
......@@ -181,26 +184,36 @@ rstto_image_list_new (void)
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, rstto_image_list_get_compare_func (image_list));
image_list->priv->n_images++;
RsttoImage *image = NULL;
GList *image_iter = g_list_find_custom (image_list->priv->images, file, (GCompareFunc)cb_rstto_image_list_file_compare_func);
g_signal_emit (G_OBJECT (image_list), rstto_image_list_signals[RSTTO_IMAGE_LIST_SIGNAL_NEW_IMAGE], 0, image, NULL);
if (image_list->priv->n_images == 1)
if (!image_iter)
{
image = rstto_image_new (file);
if (image)
{
/** TODO: update all iterators */
GSList *iter = image_list->priv->iterators;
while (iter)
image_list->priv->images = g_list_insert_sorted (image_list->priv->images, image, rstto_image_list_get_compare_func (image_list));
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);
if (image_list->priv->n_images == 1)
{
g_signal_emit (G_OBJECT (iter->data), rstto_image_list_iter_signals[RSTTO_IMAGE_LIST_ITER_SIGNAL_CHANGED], 0, NULL);
iter = g_slist_next (iter);
/** TODO: update all iterators */
GSList *iter = image_list->priv->iterators;
while (iter)
{
g_signal_emit (G_OBJECT (iter->data), rstto_image_list_iter_signals[RSTTO_IMAGE_LIST_ITER_SIGNAL_CHANGED], 0, NULL);
iter = g_slist_next (iter);
}
}
return TRUE;
}
return TRUE;
return FALSE;
}
return FALSE;
g_signal_emit (G_OBJECT (image_list), rstto_image_list_signals[RSTTO_IMAGE_LIST_SIGNAL_NEW_IMAGE], 0, image_iter->data, NULL);
return TRUE;
}
gint
......@@ -570,3 +583,17 @@ cb_rstto_image_list_exif_date_compare_func (RsttoImage *a, RsttoImage *b)
g_object_unref (file_info_b);
return result;
}
static gint
cb_rstto_image_list_file_compare_func (RsttoImage *a, GFile *file)
{
gchar *a_base = g_file_get_uri (rstto_image_get_file (a));
gchar *b_base = g_file_get_uri (file);
gint result = 0;
result = g_strcasecmp (a_base, b_base);
g_free (a_base);
g_free (b_base);
return result;
}
......@@ -64,6 +64,7 @@ struct _RsttoMainWindowPriv
guint show_fs_toolbar_timeout_id;
gint window_save_geometry_timer_id;
gint open_image_timer_id;
gboolean fs_toolbar_sticky;
......@@ -138,6 +139,8 @@ rstto_main_window_get_property (GObject *object,
static gboolean
rstto_window_save_geometry_timer (gpointer user_data);
static gboolean
rstto_window_open_image_timer(gpointer user_data);
static void
rstto_main_window_image_list_iter_changed (RsttoMainWindow *window);
......@@ -1075,6 +1078,14 @@ rstto_window_save_geometry_timer (gpointer user_data)
return FALSE;
}
static gboolean
rstto_window_open_image_timer (gpointer user_data)
{
RsttoMainWindow *window = RSTTO_MAIN_WINDOW (user_data);
window->priv->open_image_timer_id = 0;
return FALSE;
}
static void
rstto_main_window_set_navigationbar_position (RsttoMainWindow *window, guint orientation)
{
......@@ -1601,6 +1612,16 @@ cb_rstto_main_window_image_list_new_image (RsttoImageList *image_list, RsttoImag
{
if (rstto_image_list_iter_get_position (window->priv->iter) == -1)
rstto_image_list_iter_set_position (window->priv->iter, 0);
if (window->priv->open_image_timer_id > 0)
{
g_source_remove (window->priv->open_image_timer_id);
}
else
{
rstto_image_list_iter_find_image (window->priv->iter, image);
}
window->priv->open_image_timer_id = g_timeout_add (
1000, rstto_window_open_image_timer, window);
rstto_main_window_image_list_iter_changed (window);
}
......
......@@ -777,9 +777,16 @@ cb_rstto_thumbnail_bar_image_list_new_image (RsttoImageList *image_list, RsttoIm
{
RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR (user_data);
GtkWidget *thumb;
GList *iter;
g_return_if_fail (rstto_image_list_iter_find_image (bar->priv->internal_iter, image));
for (iter = bar->priv->thumbs; iter != NULL; iter = g_list_next (iter))
{
if (image == rstto_thumbnail_get_image (iter->data))
return;
}
thumb = rstto_thumbnail_new (image);
gtk_container_add (GTK_CONTAINER (bar), thumb);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment