image_list.c 17.3 KB
Newer Older
1 2 3 4 5 6 7
/*
 *  Copyright (c) 2009 Stephan Arts <stephan@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.
Stephan Arts's avatar
Stephan Arts committed
8 9
 *
 *  This program is distributed in the hope that it will be useful,
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
 *  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"
30
#include "settings.h"
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49

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);
Stephan Arts's avatar
Stephan Arts committed
50 51
static gint
cb_rstto_image_list_exif_date_compare_func (RsttoImage *a, RsttoImage *b);
Stephan Arts's avatar
Stephan Arts committed
52 53
static gint
cb_rstto_image_list_file_compare_func (RsttoImage *a, GFile *file);
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68

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,
69
    RSTTO_IMAGE_LIST_ITER_SIGNAL_PREPARE_CHANGE,
70 71 72 73 74 75 76 77 78 79 80 81 82
    RSTTO_IMAGE_LIST_ITER_SIGNAL_COUNT
};

struct _RsttoImageListIterPriv
{
    RsttoImageList *image_list;
    RsttoImage *image;
};

struct _RsttoImageListPriv
{
    GList *images;
    gint n_images;
Stephan Arts's avatar
Stephan Arts committed
83 84

    GSList *iterators;
Stephan Arts's avatar
Stephan Arts committed
85
    GCompareFunc cb_rstto_image_list_compare_func;
86 87

    gboolean wrap_images;
88 89 90 91 92 93
};

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
Stephan Arts's avatar
Stephan Arts committed
94
rstto_image_list_get_type (void)
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
{
    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)
{
122 123
    RsttoSettings *settings = rstto_settings_new();

124
    image_list->priv = g_new0 (RsttoImageListPriv, 1);
Stephan Arts's avatar
Stephan Arts committed
125
    image_list->priv->cb_rstto_image_list_compare_func = (GCompareFunc)cb_rstto_image_list_image_name_compare_func;
126 127 128

    image_list->priv->wrap_images = rstto_settings_get_boolean_property (settings, "wrap-images");
    g_object_unref (settings);
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
}

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 *
Stephan Arts's avatar
Stephan Arts committed
183
rstto_image_list_new (void)
184 185 186 187 188 189 190 191 192 193 194
{
    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)
{
Stephan Arts's avatar
Stephan Arts committed
195 196 197
    RsttoImage *image = NULL;

    GList *image_iter = g_list_find_custom (image_list->priv->images, file, (GCompareFunc)cb_rstto_image_list_file_compare_func);
198

Stephan Arts's avatar
Stephan Arts committed
199 200 201 202
    if (!image_iter)
    {
        image = rstto_image_new (file);
        if (image)
Stephan Arts's avatar
Stephan Arts committed
203
        {
Stephan Arts's avatar
Stephan Arts committed
204 205 206 207 208
            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)
Stephan Arts's avatar
Stephan Arts committed
209
            {
Stephan Arts's avatar
Stephan Arts committed
210 211 212 213 214 215 216
                /** 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);
                }
Stephan Arts's avatar
Stephan Arts committed
217
            }
Stephan Arts's avatar
Stephan Arts committed
218
            return TRUE;
Stephan Arts's avatar
Stephan Arts committed
219
        }
Stephan Arts's avatar
Stephan Arts committed
220
        return FALSE;
221
    }
Stephan Arts's avatar
Stephan Arts committed
222 223 224
    g_signal_emit (G_OBJECT (image_list), rstto_image_list_signals[RSTTO_IMAGE_LIST_SIGNAL_NEW_IMAGE], 0, image_iter->data, NULL);

    return TRUE;
225 226 227 228 229 230 231 232
}

gint
rstto_image_list_get_n_images (RsttoImageList *image_list)
{
    return g_list_length (image_list->priv->images);
}

Stephan Arts's avatar
Stephan Arts committed
233 234 235 236 237 238 239 240
/**
 * rstto_image_list_get_iter:
 * @image_list:
 *
 * TODO: track iterators
 *
 * return iter;
 */
241 242 243 244
RsttoImageListIter *
rstto_image_list_get_iter (RsttoImageList *image_list)
{
    RsttoImage *image = NULL;
Stephan Arts's avatar
Stephan Arts committed
245
    RsttoImageListIter *iter = NULL;
246 247 248
    if (image_list->priv->images)
        image = image_list->priv->images->data;

Stephan Arts's avatar
Stephan Arts committed
249
    iter = rstto_image_list_iter_new (image_list, image);
250

Stephan Arts's avatar
Stephan Arts committed
251 252
    image_list->priv->iterators = g_slist_prepend (image_list->priv->iterators, iter);

253 254 255 256 257 258 259
    return iter;
}


void
rstto_image_list_remove_image (RsttoImageList *image_list, RsttoImage *image)
{
Stephan Arts's avatar
Stephan Arts committed
260 261
    GSList *iter = NULL;

262 263
    if (g_list_find (image_list->priv->images, image))
    {
Stephan Arts's avatar
Stephan Arts committed
264

Stephan Arts's avatar
Stephan Arts committed
265
        iter = image_list->priv->iterators;
Stephan Arts's avatar
Stephan Arts committed
266 267 268 269 270 271 272 273
        while (iter)
        {
            if (rstto_image_list_iter_get_image (iter->data) == image)
            {
                rstto_image_list_iter_previous (iter->data);
            }
            iter = g_slist_next (iter);
        }
274 275 276 277 278 279 280 281 282 283 284 285

        image_list->priv->images = g_list_remove (image_list->priv->images, image);
        iter = image_list->priv->iterators;
        while (iter)
        {
            if (rstto_image_list_iter_get_image (iter->data) == image)
            {
                rstto_image_list_iter_previous (iter->data);
            }
            iter = g_slist_next (iter);
        }

286 287 288 289 290 291 292 293
        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)
{
Stephan Arts's avatar
Stephan Arts committed
294
    GSList *iter = NULL;
295 296 297
    g_list_foreach (image_list->priv->images, (GFunc)g_object_unref, NULL);
    g_list_free (image_list->priv->images);
    image_list->priv->images = NULL;
Stephan Arts's avatar
Stephan Arts committed
298

Stephan Arts's avatar
Stephan Arts committed
299
    iter = image_list->priv->iterators;
Stephan Arts's avatar
Stephan Arts committed
300 301 302 303 304 305
    while (iter)
    {
        rstto_image_list_iter_set_position (iter->data, 0);
        iter = g_slist_next (iter);
    }
    g_signal_emit (G_OBJECT (image_list), rstto_image_list_signals[RSTTO_IMAGE_LIST_SIGNAL_REMOVE_ALL], 0, NULL);
306 307 308 309 310
}



GType
Stephan Arts's avatar
Stephan Arts committed
311
rstto_image_list_iter_get_type (void)
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350
{
    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;

351 352 353 354 355 356 357 358 359 360 361
    rstto_image_list_iter_signals[RSTTO_IMAGE_LIST_ITER_SIGNAL_PREPARE_CHANGE] = g_signal_new("prepare-change",
            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);

362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383
    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;
    }
Stephan Arts's avatar
Stephan Arts committed
384 385 386 387 388 389

    if (iter->priv->image_list)
    {
        iter->priv->image_list->priv->iterators = g_slist_remove (iter->priv->image_list->priv->iterators, iter);
        iter->priv->image_list= NULL;
    }
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409
}

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;

    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)
    {
410 411
        g_signal_emit (G_OBJECT (iter), rstto_image_list_iter_signals[RSTTO_IMAGE_LIST_ITER_SIGNAL_PREPARE_CHANGE], 0, NULL);

412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429
        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)
    {
430
        return -1;
431
    }
432
    return g_list_index (iter->priv->image_list->priv->images, iter->priv->image);
433 434 435 436 437 438 439 440 441
}

RsttoImage *
rstto_image_list_iter_get_image (RsttoImageListIter *iter)
{
    return RSTTO_IMAGE (iter->priv->image);
}


Stephan Arts's avatar
Stephan Arts committed
442
void
443 444
rstto_image_list_iter_set_position (RsttoImageListIter *iter, gint pos)
{
445 446
    g_signal_emit (G_OBJECT (iter), rstto_image_list_iter_signals[RSTTO_IMAGE_LIST_ITER_SIGNAL_PREPARE_CHANGE], 0, NULL);

447 448 449 450 451 452
    if (iter->priv->image)
    {
        iter->priv->image = NULL;
    }

    iter->priv->image = g_list_nth_data (iter->priv->image_list->priv->images, pos); 
453

454 455 456
    g_signal_emit (G_OBJECT (iter), rstto_image_list_iter_signals[RSTTO_IMAGE_LIST_ITER_SIGNAL_CHANGED], 0, NULL);
}

Stephan Arts's avatar
Stephan Arts committed
457
void
458 459
rstto_image_list_iter_next (RsttoImageListIter *iter)
{
460
    GList *position = NULL;
461 462 463

    g_signal_emit (G_OBJECT (iter), rstto_image_list_iter_signals[RSTTO_IMAGE_LIST_ITER_SIGNAL_PREPARE_CHANGE], 0, NULL);

464 465
    if (iter->priv->image)
    {
466
        position = g_list_find (iter->priv->image_list->priv->images, iter->priv->image);
467 468 469
        iter->priv->image = NULL;
    }

470 471 472
    position = g_list_next (position);
    if (position)
        iter->priv->image = position->data; 
473 474
    else
    {
475 476 477 478 479
        if (rstto_image_list_get_wrap_images (iter->priv->image_list))
            position = g_list_first (iter->priv->image_list->priv->images);
        else
            position = g_list_last (iter->priv->image_list->priv->images);

480 481 482 483
        if (position)
            iter->priv->image = position->data; 
        else
            iter->priv->image = NULL;
484 485 486 487 488
    }

    g_signal_emit (G_OBJECT (iter), rstto_image_list_iter_signals[RSTTO_IMAGE_LIST_ITER_SIGNAL_CHANGED], 0, NULL);
}

Stephan Arts's avatar
Stephan Arts committed
489
void
490 491
rstto_image_list_iter_previous (RsttoImageListIter *iter)
{
492
    GList *position = NULL;
493 494 495

    g_signal_emit (G_OBJECT (iter), rstto_image_list_iter_signals[RSTTO_IMAGE_LIST_ITER_SIGNAL_PREPARE_CHANGE], 0, NULL);

496 497
    if (iter->priv->image)
    {
498
        position = g_list_find (iter->priv->image_list->priv->images, iter->priv->image);
499 500 501
        iter->priv->image = NULL;
    }

502 503 504
    position = g_list_previous (position);
    if (position)
        iter->priv->image = position->data; 
505 506
    else
    {
507 508 509 510 511
        if (rstto_image_list_get_wrap_images (iter->priv->image_list))
            position = g_list_last (iter->priv->image_list->priv->images);
        else
            position = g_list_first (iter->priv->image_list->priv->images);

512 513 514 515
        if (position)
            iter->priv->image = position->data; 
        else
            iter->priv->image = NULL;
516
    }
517

518 519 520 521 522 523 524 525 526 527
    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);

    return new_iter;
}
528 529 530 531

GCompareFunc
rstto_image_list_get_compare_func (RsttoImageList *image_list)
{
Stephan Arts's avatar
Stephan Arts committed
532 533 534
    return (GCompareFunc)image_list->priv->cb_rstto_image_list_compare_func;
}

535 536 537
void
rstto_image_list_set_compare_func (RsttoImageList *image_list, GCompareFunc func)
{
538
    GSList *iter = NULL;
539
    image_list->priv->cb_rstto_image_list_compare_func = func;
540
    image_list->priv->images = g_list_sort (image_list->priv->images,  func);
541 542 543 544
    for (iter = image_list->priv->iterators; iter != NULL; iter = g_slist_next (iter))
    {
        g_signal_emit (G_OBJECT (iter->data), rstto_image_list_iter_signals[RSTTO_IMAGE_LIST_ITER_SIGNAL_CHANGED], 0, NULL);
    }
545 546
}

Stephan Arts's avatar
Stephan Arts committed
547 548 549 550
/***********************/
/*  Compare Functions  */
/***********************/

551 552 553
void
rstto_image_list_set_sort_by_name (RsttoImageList *image_list)
{
554
    rstto_image_list_set_compare_func (image_list, (GCompareFunc)cb_rstto_image_list_image_name_compare_func);
555 556 557 558 559
}

void
rstto_image_list_set_sort_by_date (RsttoImageList *image_list)
{
560
    rstto_image_list_set_compare_func (image_list, (GCompareFunc)cb_rstto_image_list_exif_date_compare_func);
561 562
}

Stephan Arts's avatar
Stephan Arts committed
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589
/**
 * 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;
}

/**
 * cb_rstto_image_list_exif_date_compare_func:
 * @a:
 * @b:
 *
590
 * TODO: Use EXIF data if available, not the last-modification-time.
Stephan Arts's avatar
Stephan Arts committed
591 592 593 594 595 596 597
 *
 * Return value: (see strcmp)
 */
static gint
cb_rstto_image_list_exif_date_compare_func (RsttoImage *a, RsttoImage *b)
{
    gint result = 0;
598 599 600 601 602 603 604 605 606 607 608 609 610
    
    GFileInfo *file_info_a = g_file_query_info (rstto_image_get_file (a), "time::modified", 0, NULL, NULL);
    GFileInfo *file_info_b = g_file_query_info (rstto_image_get_file (b), "time::modified", 0, NULL, NULL);

    guint64 a_i = g_file_info_get_attribute_uint64(file_info_a, "time::modified");
    guint64 b_i = g_file_info_get_attribute_uint64(file_info_b, "time::modified");
    if (a_i > b_i)
        result = 1;
    else
        result = 0;

    g_object_unref (file_info_a);
    g_object_unref (file_info_b);
Stephan Arts's avatar
Stephan Arts committed
611
    return result;
612
}
Stephan Arts's avatar
Stephan Arts committed
613 614 615 616 617 618 619 620 621 622 623 624 625 626

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;
}
627 628 629 630 631 632

gboolean
rstto_image_list_get_wrap_images (RsttoImageList *image_list)
{
    return image_list->priv->wrap_images;
}