~ubuntu-branches/ubuntu/precise/rhythmbox/precise-201203091205

« back to all changes in this revision

Viewing changes to rhythmdb/rhythmdb-property-model.c

Tags: upstream-0.9.2cvs20060102
ImportĀ upstreamĀ versionĀ 0.9.2cvs20060102

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* 
 
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
 
2
 * 
2
3
 *  arch-tag: Implementation of RhythmDB property GtkTreeModel
3
4
 *
4
5
 *  Copyright (C) 2003 Colin Walters <walters@gnome.org>
24
25
#include <stdlib.h>
25
26
#include <string.h>
26
27
 
27
 
#include <libgnome/gnome-i18n.h>
 
28
#include <glib/gi18n.h>
28
29
#include "rhythmdb-property-model.h"
29
30
#include "rb-debug.h"
30
31
#include "gsequence.h"
147
148
        GPtrArray *query;
148
149
 
149
150
        GSequence *properties;
150
 
        GMemChunk *property_memchunk;
151
151
        GHashTable *reverse_map;
152
152
 
153
153
        RhythmDBPropertyModelEntry *all;
156
156
        guint syncing_id;
157
157
};
158
158
 
 
159
#define RHYTHMDB_PROPERTY_MODEL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RHYTHMDB_TYPE_PROPERTY_MODEL, RhythmDBPropertyModelPrivate))
 
160
 
159
161
enum
160
162
{
161
163
        PRE_ROW_DELETION,
237
239
                                                              RHYTHMDB_TYPE_QUERY_MODEL,
238
240
                                                              G_PARAM_READWRITE));
239
241
 
 
242
        g_type_class_add_private (klass, sizeof (RhythmDBPropertyModelPrivate));
240
243
}
241
244
 
242
245
static void
380
383
static void
381
384
rhythmdb_property_model_init (RhythmDBPropertyModel *model)
382
385
{
383
 
        model->priv = g_new0 (RhythmDBPropertyModelPrivate, 1);
384
 
 
385
 
        model->priv->property_memchunk = g_mem_chunk_new ("RhythmDBPropertyModel property memchunk",
386
 
                                                          sizeof (RhythmDBPropertyModelEntry),
387
 
                                                          1024, G_ALLOC_AND_FREE);
 
386
        model->priv = RHYTHMDB_PROPERTY_MODEL_GET_PRIVATE (model);
388
387
 
389
388
        model->priv->stamp = g_random_int ();
390
389
 
391
390
        model->priv->properties = g_sequence_new (NULL);
392
391
        model->priv->reverse_map = g_hash_table_new (g_str_hash, g_str_equal);
393
392
 
394
 
        model->priv->all = g_mem_chunk_alloc (model->priv->property_memchunk);
 
393
        model->priv->all = g_new0 (RhythmDBPropertyModelEntry, 1);
395
394
        model->priv->all->string = rb_refstring_new (_("All"));
396
395
}
397
396
 
422
421
                rb_refstring_unref (prop->sort_string);
423
422
        }
424
423
 
425
 
        g_mem_chunk_destroy (model->priv->property_memchunk);
426
424
        g_hash_table_destroy (model->priv->reverse_map);
427
425
        g_sequence_free (model->priv->properties);
428
426
 
429
427
        if (model->priv->query_model)
430
428
                g_object_unref (G_OBJECT (model->priv->query_model));
431
429
 
432
 
        g_free (model->priv);
433
 
 
434
430
        G_OBJECT_CLASS (rhythmdb_property_model_parent_class)->finalize (object);
435
431
}
436
432
 
514
510
                return;
515
511
        }
516
512
 
517
 
        prop = g_mem_chunk_alloc (model->priv->property_memchunk);
 
513
        prop = g_new0 (RhythmDBPropertyModelEntry, 1);
518
514
        prop->string = rb_refstring_new (propstr);
519
515
        prop->sort_string = rb_refstring_new (rhythmdb_entry_get_string (entry, model->priv->sort_propid));
520
516
        prop->refcount = 1;
571
567
        g_hash_table_remove (model->priv->reverse_map, propstr);
572
568
        rb_refstring_unref (prop->string);
573
569
        rb_refstring_unref (prop->sort_string);
574
 
        g_mem_chunk_free (model->priv->property_memchunk, prop);
 
570
        g_free (prop);
575
571
        return;
576
572
}
577
573