~ubuntu-branches/ubuntu/saucy/gnome-mahjongg/saucy-proposed

« back to all changes in this revision

Viewing changes to src/history.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-02-19 12:21:16 UTC
  • Revision ID: package-import@ubuntu.com-20130219122116-k1ufas8i5f34i8bp
Tags: upstream-3.7.5
ImportĀ upstreamĀ versionĀ 3.7.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* history.c generated by valac 0.18.1, the Vala compiler
 
2
 * generated from history.vala, do not modify */
 
3
 
 
4
 
 
5
#include <glib.h>
 
6
#include <glib-object.h>
 
7
#include <stdlib.h>
 
8
#include <string.h>
 
9
#include <glib/gstdio.h>
 
10
#include <float.h>
 
11
#include <math.h>
 
12
#include <gobject/gvaluecollector.h>
 
13
 
 
14
 
 
15
#define TYPE_HISTORY (history_get_type ())
 
16
#define HISTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_HISTORY, History))
 
17
#define HISTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_HISTORY, HistoryClass))
 
18
#define IS_HISTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_HISTORY))
 
19
#define IS_HISTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_HISTORY))
 
20
#define HISTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_HISTORY, HistoryClass))
 
21
 
 
22
typedef struct _History History;
 
23
typedef struct _HistoryClass HistoryClass;
 
24
typedef struct _HistoryPrivate HistoryPrivate;
 
25
 
 
26
#define TYPE_HISTORY_ENTRY (history_entry_get_type ())
 
27
#define HISTORY_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_HISTORY_ENTRY, HistoryEntry))
 
28
#define HISTORY_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_HISTORY_ENTRY, HistoryEntryClass))
 
29
#define IS_HISTORY_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_HISTORY_ENTRY))
 
30
#define IS_HISTORY_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_HISTORY_ENTRY))
 
31
#define HISTORY_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_HISTORY_ENTRY, HistoryEntryClass))
 
32
 
 
33
typedef struct _HistoryEntry HistoryEntry;
 
34
typedef struct _HistoryEntryClass HistoryEntryClass;
 
35
#define _g_free0(var) (var = (g_free (var), NULL))
 
36
#define __g_list_free__history_entry_unref0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__history_entry_unref0_ (var), NULL)))
 
37
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
 
38
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))
 
39
#define _history_entry_unref0(var) ((var == NULL) ? NULL : (var = (history_entry_unref (var), NULL)))
 
40
typedef struct _HistoryEntryPrivate HistoryEntryPrivate;
 
41
#define _g_time_zone_unref0(var) ((var == NULL) ? NULL : (var = (g_time_zone_unref (var), NULL)))
 
42
typedef struct _ParamSpecHistory ParamSpecHistory;
 
43
typedef struct _ParamSpecHistoryEntry ParamSpecHistoryEntry;
 
44
 
 
45
struct _History {
 
46
        GTypeInstance parent_instance;
 
47
        volatile int ref_count;
 
48
        HistoryPrivate * priv;
 
49
        gchar* filename;
 
50
        GList* entries;
 
51
};
 
52
 
 
53
struct _HistoryClass {
 
54
        GTypeClass parent_class;
 
55
        void (*finalize) (History *self);
 
56
};
 
57
 
 
58
struct _HistoryEntry {
 
59
        GTypeInstance parent_instance;
 
60
        volatile int ref_count;
 
61
        HistoryEntryPrivate * priv;
 
62
        GDateTime* date;
 
63
        gchar* name;
 
64
        guint duration;
 
65
};
 
66
 
 
67
struct _HistoryEntryClass {
 
68
        GTypeClass parent_class;
 
69
        void (*finalize) (HistoryEntry *self);
 
70
};
 
71
 
 
72
struct _ParamSpecHistory {
 
73
        GParamSpec parent_instance;
 
74
};
 
75
 
 
76
struct _ParamSpecHistoryEntry {
 
77
        GParamSpec parent_instance;
 
78
};
 
79
 
 
80
 
 
81
static gpointer history_parent_class = NULL;
 
82
static gpointer history_entry_parent_class = NULL;
 
83
 
 
84
gpointer history_ref (gpointer instance);
 
85
void history_unref (gpointer instance);
 
86
GParamSpec* param_spec_history (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
 
87
void value_set_history (GValue* value, gpointer v_object);
 
88
void value_take_history (GValue* value, gpointer v_object);
 
89
gpointer value_get_history (const GValue* value);
 
90
GType history_get_type (void) G_GNUC_CONST;
 
91
gpointer history_entry_ref (gpointer instance);
 
92
void history_entry_unref (gpointer instance);
 
93
GParamSpec* param_spec_history_entry (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
 
94
void value_set_history_entry (GValue* value, gpointer v_object);
 
95
void value_take_history_entry (GValue* value, gpointer v_object);
 
96
gpointer value_get_history_entry (const GValue* value);
 
97
GType history_entry_get_type (void) G_GNUC_CONST;
 
98
enum  {
 
99
        HISTORY_DUMMY_PROPERTY
 
100
};
 
101
static void _history_entry_unref0_ (gpointer var);
 
102
static void _g_list_free__history_entry_unref0_ (GList* self);
 
103
History* history_new (const gchar* filename);
 
104
History* history_construct (GType object_type, const gchar* filename);
 
105
void history_add (History* self, HistoryEntry* entry);
 
106
void history_load (History* self);
 
107
static GDateTime* history_parse_date (History* self, const gchar* date);
 
108
HistoryEntry* history_entry_new (GDateTime* date, const gchar* name, guint duration);
 
109
HistoryEntry* history_entry_construct (GType object_type, GDateTime* date, const gchar* name, guint duration);
 
110
void history_save (History* self);
 
111
static void g_cclosure_user_marshal_VOID__HISTORY_ENTRY (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data);
 
112
static void history_finalize (History* obj);
 
113
enum  {
 
114
        HISTORY_ENTRY_DUMMY_PROPERTY
 
115
};
 
116
static void history_entry_finalize (HistoryEntry* obj);
 
117
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
 
118
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
 
119
static gint _vala_array_length (gpointer array);
 
120
 
 
121
 
 
122
static void _history_entry_unref0_ (gpointer var) {
 
123
        (var == NULL) ? NULL : (var = (history_entry_unref (var), NULL));
 
124
}
 
125
 
 
126
 
 
127
static void _g_list_free__history_entry_unref0_ (GList* self) {
 
128
        g_list_foreach (self, (GFunc) _history_entry_unref0_, NULL);
 
129
        g_list_free (self);
 
130
}
 
131
 
 
132
 
 
133
History* history_construct (GType object_type, const gchar* filename) {
 
134
        History* self = NULL;
 
135
        const gchar* _tmp0_;
 
136
        gchar* _tmp1_;
 
137
        g_return_val_if_fail (filename != NULL, NULL);
 
138
        self = (History*) g_type_create_instance (object_type);
 
139
        _tmp0_ = filename;
 
140
        _tmp1_ = g_strdup (_tmp0_);
 
141
        _g_free0 (self->filename);
 
142
        self->filename = _tmp1_;
 
143
        __g_list_free__history_entry_unref0_0 (self->entries);
 
144
        self->entries = NULL;
 
145
        return self;
 
146
}
 
147
 
 
148
 
 
149
History* history_new (const gchar* filename) {
 
150
        return history_construct (TYPE_HISTORY, filename);
 
151
}
 
152
 
 
153
 
 
154
static gpointer _history_entry_ref0 (gpointer self) {
 
155
        return self ? history_entry_ref (self) : NULL;
 
156
}
 
157
 
 
158
 
 
159
void history_add (History* self, HistoryEntry* entry) {
 
160
        HistoryEntry* _tmp0_;
 
161
        HistoryEntry* _tmp1_;
 
162
        HistoryEntry* _tmp2_;
 
163
        g_return_if_fail (self != NULL);
 
164
        g_return_if_fail (entry != NULL);
 
165
        _tmp0_ = entry;
 
166
        _tmp1_ = _history_entry_ref0 (_tmp0_);
 
167
        self->entries = g_list_append (self->entries, _tmp1_);
 
168
        _tmp2_ = entry;
 
169
        g_signal_emit_by_name (self, "entry-added", _tmp2_);
 
170
}
 
171
 
 
172
 
 
173
void history_load (History* self) {
 
174
        gchar* _tmp0_;
 
175
        gchar* contents;
 
176
        const gchar* _tmp6_;
 
177
        gchar** _tmp7_;
 
178
        gchar** _tmp8_ = NULL;
 
179
        GError * _inner_error_ = NULL;
 
180
        g_return_if_fail (self != NULL);
 
181
        __g_list_free__history_entry_unref0_0 (self->entries);
 
182
        self->entries = NULL;
 
183
        _tmp0_ = g_strdup ("");
 
184
        contents = _tmp0_;
 
185
        {
 
186
                const gchar* _tmp1_;
 
187
                gchar* _tmp2_ = NULL;
 
188
                _tmp1_ = self->filename;
 
189
                g_file_get_contents (_tmp1_, &_tmp2_, NULL, &_inner_error_);
 
190
                _g_free0 (contents);
 
191
                contents = _tmp2_;
 
192
                if (_inner_error_ != NULL) {
 
193
                        if (_inner_error_->domain == G_FILE_ERROR) {
 
194
                                goto __catch8_g_file_error;
 
195
                        }
 
196
                        _g_free0 (contents);
 
197
                        g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
 
198
                        g_clear_error (&_inner_error_);
 
199
                        return;
 
200
                }
 
201
        }
 
202
        goto __finally8;
 
203
        __catch8_g_file_error:
 
204
        {
 
205
                GError* e = NULL;
 
206
                GError* _tmp3_;
 
207
                e = _inner_error_;
 
208
                _inner_error_ = NULL;
 
209
                _tmp3_ = e;
 
210
                if (!g_error_matches (_tmp3_, G_FILE_ERROR, G_FILE_ERROR_NOENT)) {
 
211
                        GError* _tmp4_;
 
212
                        const gchar* _tmp5_;
 
213
                        _tmp4_ = e;
 
214
                        _tmp5_ = _tmp4_->message;
 
215
                        g_warning ("history.vala:32: Failed to load history: %s", _tmp5_);
 
216
                }
 
217
                _g_error_free0 (e);
 
218
                _g_free0 (contents);
 
219
                return;
 
220
        }
 
221
        __finally8:
 
222
        if (_inner_error_ != NULL) {
 
223
                _g_free0 (contents);
 
224
                g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
 
225
                g_clear_error (&_inner_error_);
 
226
                return;
 
227
        }
 
228
        _tmp6_ = contents;
 
229
        _tmp8_ = _tmp7_ = g_strsplit (_tmp6_, "\n", 0);
 
230
        {
 
231
                gchar** line_collection = NULL;
 
232
                gint line_collection_length1 = 0;
 
233
                gint _line_collection_size_ = 0;
 
234
                gint line_it = 0;
 
235
                line_collection = _tmp8_;
 
236
                line_collection_length1 = _vala_array_length (_tmp7_);
 
237
                for (line_it = 0; line_it < _vala_array_length (_tmp7_); line_it = line_it + 1) {
 
238
                        gchar* _tmp9_;
 
239
                        gchar* line = NULL;
 
240
                        _tmp9_ = g_strdup (line_collection[line_it]);
 
241
                        line = _tmp9_;
 
242
                        {
 
243
                                const gchar* _tmp10_;
 
244
                                gchar** _tmp11_;
 
245
                                gchar** _tmp12_ = NULL;
 
246
                                gchar** tokens;
 
247
                                gint tokens_length1;
 
248
                                gint _tokens_size_;
 
249
                                gchar** _tmp13_;
 
250
                                gint _tmp13__length1;
 
251
                                gchar** _tmp14_;
 
252
                                gint _tmp14__length1;
 
253
                                const gchar* _tmp15_;
 
254
                                GDateTime* _tmp16_ = NULL;
 
255
                                GDateTime* date;
 
256
                                GDateTime* _tmp17_;
 
257
                                gchar** _tmp18_;
 
258
                                gint _tmp18__length1;
 
259
                                const gchar* _tmp19_;
 
260
                                gchar* _tmp20_;
 
261
                                gchar* name;
 
262
                                gchar** _tmp21_;
 
263
                                gint _tmp21__length1;
 
264
                                const gchar* _tmp22_;
 
265
                                gint _tmp23_ = 0;
 
266
                                gint duration;
 
267
                                GDateTime* _tmp24_;
 
268
                                const gchar* _tmp25_;
 
269
                                gint _tmp26_;
 
270
                                HistoryEntry* _tmp27_;
 
271
                                HistoryEntry* _tmp28_;
 
272
                                _tmp10_ = line;
 
273
                                _tmp12_ = _tmp11_ = g_strsplit (_tmp10_, " ", 0);
 
274
                                tokens = _tmp12_;
 
275
                                tokens_length1 = _vala_array_length (_tmp11_);
 
276
                                _tokens_size_ = tokens_length1;
 
277
                                _tmp13_ = tokens;
 
278
                                _tmp13__length1 = tokens_length1;
 
279
                                if (_tmp13__length1 != 3) {
 
280
                                        tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL);
 
281
                                        _g_free0 (line);
 
282
                                        continue;
 
283
                                }
 
284
                                _tmp14_ = tokens;
 
285
                                _tmp14__length1 = tokens_length1;
 
286
                                _tmp15_ = _tmp14_[0];
 
287
                                _tmp16_ = history_parse_date (self, _tmp15_);
 
288
                                date = _tmp16_;
 
289
                                _tmp17_ = date;
 
290
                                if (_tmp17_ == NULL) {
 
291
                                        _g_date_time_unref0 (date);
 
292
                                        tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL);
 
293
                                        _g_free0 (line);
 
294
                                        continue;
 
295
                                }
 
296
                                _tmp18_ = tokens;
 
297
                                _tmp18__length1 = tokens_length1;
 
298
                                _tmp19_ = _tmp18_[1];
 
299
                                _tmp20_ = g_strdup (_tmp19_);
 
300
                                name = _tmp20_;
 
301
                                _tmp21_ = tokens;
 
302
                                _tmp21__length1 = tokens_length1;
 
303
                                _tmp22_ = _tmp21_[2];
 
304
                                _tmp23_ = atoi (_tmp22_);
 
305
                                duration = _tmp23_;
 
306
                                _tmp24_ = date;
 
307
                                _tmp25_ = name;
 
308
                                _tmp26_ = duration;
 
309
                                _tmp27_ = history_entry_new (_tmp24_, _tmp25_, (guint) _tmp26_);
 
310
                                _tmp28_ = _tmp27_;
 
311
                                history_add (self, _tmp28_);
 
312
                                _history_entry_unref0 (_tmp28_);
 
313
                                _g_free0 (name);
 
314
                                _g_date_time_unref0 (date);
 
315
                                tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL);
 
316
                                _g_free0 (line);
 
317
                        }
 
318
                }
 
319
                line_collection = (_vala_array_free (line_collection, line_collection_length1, (GDestroyNotify) g_free), NULL);
 
320
        }
 
321
        _g_free0 (contents);
 
322
}
 
323
 
 
324
 
 
325
static gchar* g_date_time_to_string (GDateTime* self) {
 
326
        gchar* result = NULL;
 
327
        gchar* _tmp0_ = NULL;
 
328
        g_return_val_if_fail (self != NULL, NULL);
 
329
        _tmp0_ = g_date_time_format (self, "%FT%H:%M:%S%z");
 
330
        result = _tmp0_;
 
331
        return result;
 
332
}
 
333
 
 
334
 
 
335
void history_save (History* self) {
 
336
        gchar* _tmp0_;
 
337
        gchar* contents;
 
338
        GList* _tmp1_;
 
339
        GError * _inner_error_ = NULL;
 
340
        g_return_if_fail (self != NULL);
 
341
        _tmp0_ = g_strdup ("");
 
342
        contents = _tmp0_;
 
343
        _tmp1_ = self->entries;
 
344
        {
 
345
                GList* entry_collection = NULL;
 
346
                GList* entry_it = NULL;
 
347
                entry_collection = _tmp1_;
 
348
                for (entry_it = entry_collection; entry_it != NULL; entry_it = entry_it->next) {
 
349
                        HistoryEntry* _tmp2_;
 
350
                        HistoryEntry* entry = NULL;
 
351
                        _tmp2_ = _history_entry_ref0 ((HistoryEntry*) entry_it->data);
 
352
                        entry = _tmp2_;
 
353
                        {
 
354
                                HistoryEntry* _tmp3_;
 
355
                                GDateTime* _tmp4_;
 
356
                                gchar* _tmp5_ = NULL;
 
357
                                gchar* _tmp6_;
 
358
                                HistoryEntry* _tmp7_;
 
359
                                const gchar* _tmp8_;
 
360
                                HistoryEntry* _tmp9_;
 
361
                                guint _tmp10_;
 
362
                                gchar* _tmp11_ = NULL;
 
363
                                gchar* _tmp12_;
 
364
                                gchar* line;
 
365
                                const gchar* _tmp13_;
 
366
                                const gchar* _tmp14_;
 
367
                                gchar* _tmp15_;
 
368
                                _tmp3_ = entry;
 
369
                                _tmp4_ = _tmp3_->date;
 
370
                                _tmp5_ = g_date_time_to_string (_tmp4_);
 
371
                                _tmp6_ = _tmp5_;
 
372
                                _tmp7_ = entry;
 
373
                                _tmp8_ = _tmp7_->name;
 
374
                                _tmp9_ = entry;
 
375
                                _tmp10_ = _tmp9_->duration;
 
376
                                _tmp11_ = g_strdup_printf ("%s %s %u\n", _tmp6_, _tmp8_, _tmp10_);
 
377
                                _tmp12_ = _tmp11_;
 
378
                                _g_free0 (_tmp6_);
 
379
                                line = _tmp12_;
 
380
                                _tmp13_ = contents;
 
381
                                _tmp14_ = line;
 
382
                                _tmp15_ = g_strconcat (_tmp13_, _tmp14_, NULL);
 
383
                                _g_free0 (contents);
 
384
                                contents = _tmp15_;
 
385
                                _g_free0 (line);
 
386
                                _history_entry_unref0 (entry);
 
387
                        }
 
388
                }
 
389
        }
 
390
        {
 
391
                const gchar* _tmp16_;
 
392
                gchar* _tmp17_ = NULL;
 
393
                gchar* _tmp18_;
 
394
                const gchar* _tmp19_;
 
395
                const gchar* _tmp20_;
 
396
                _tmp16_ = self->filename;
 
397
                _tmp17_ = g_path_get_dirname (_tmp16_);
 
398
                _tmp18_ = _tmp17_;
 
399
                g_mkdir_with_parents (_tmp18_, 0775);
 
400
                _g_free0 (_tmp18_);
 
401
                _tmp19_ = self->filename;
 
402
                _tmp20_ = contents;
 
403
                g_file_set_contents (_tmp19_, _tmp20_, (gssize) (-1), &_inner_error_);
 
404
                if (_inner_error_ != NULL) {
 
405
                        if (_inner_error_->domain == G_FILE_ERROR) {
 
406
                                goto __catch9_g_file_error;
 
407
                        }
 
408
                        _g_free0 (contents);
 
409
                        g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
 
410
                        g_clear_error (&_inner_error_);
 
411
                        return;
 
412
                }
 
413
        }
 
414
        goto __finally9;
 
415
        __catch9_g_file_error:
 
416
        {
 
417
                GError* e = NULL;
 
418
                GError* _tmp21_;
 
419
                const gchar* _tmp22_;
 
420
                e = _inner_error_;
 
421
                _inner_error_ = NULL;
 
422
                _tmp21_ = e;
 
423
                _tmp22_ = _tmp21_->message;
 
424
                g_warning ("history.vala:69: Failed to save history: %s", _tmp22_);
 
425
                _g_error_free0 (e);
 
426
        }
 
427
        __finally9:
 
428
        if (_inner_error_ != NULL) {
 
429
                _g_free0 (contents);
 
430
                g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
 
431
                g_clear_error (&_inner_error_);
 
432
                return;
 
433
        }
 
434
        _g_free0 (contents);
 
435
}
 
436
 
 
437
 
 
438
static gchar string_get (const gchar* self, glong index) {
 
439
        gchar result = '\0';
 
440
        glong _tmp0_;
 
441
        gchar _tmp1_;
 
442
        g_return_val_if_fail (self != NULL, '\0');
 
443
        _tmp0_ = index;
 
444
        _tmp1_ = ((gchar*) self)[_tmp0_];
 
445
        result = _tmp1_;
 
446
        return result;
 
447
}
 
448
 
 
449
 
 
450
static glong string_strnlen (gchar* str, glong maxlen) {
 
451
        glong result = 0L;
 
452
        gchar* _tmp0_;
 
453
        glong _tmp1_;
 
454
        gchar* _tmp2_ = NULL;
 
455
        gchar* end;
 
456
        gchar* _tmp3_;
 
457
        _tmp0_ = str;
 
458
        _tmp1_ = maxlen;
 
459
        _tmp2_ = memchr (_tmp0_, 0, (gsize) _tmp1_);
 
460
        end = _tmp2_;
 
461
        _tmp3_ = end;
 
462
        if (_tmp3_ == NULL) {
 
463
                glong _tmp4_;
 
464
                _tmp4_ = maxlen;
 
465
                result = _tmp4_;
 
466
                return result;
 
467
        } else {
 
468
                gchar* _tmp5_;
 
469
                gchar* _tmp6_;
 
470
                _tmp5_ = end;
 
471
                _tmp6_ = str;
 
472
                result = (glong) (_tmp5_ - _tmp6_);
 
473
                return result;
 
474
        }
 
475
}
 
476
 
 
477
 
 
478
static gchar* string_substring (const gchar* self, glong offset, glong len) {
 
479
        gchar* result = NULL;
 
480
        glong string_length = 0L;
 
481
        gboolean _tmp0_ = FALSE;
 
482
        glong _tmp1_;
 
483
        gboolean _tmp3_;
 
484
        glong _tmp9_;
 
485
        glong _tmp15_;
 
486
        glong _tmp18_;
 
487
        glong _tmp19_;
 
488
        glong _tmp20_;
 
489
        glong _tmp21_;
 
490
        glong _tmp22_;
 
491
        gchar* _tmp23_ = NULL;
 
492
        g_return_val_if_fail (self != NULL, NULL);
 
493
        _tmp1_ = offset;
 
494
        if (_tmp1_ >= ((glong) 0)) {
 
495
                glong _tmp2_;
 
496
                _tmp2_ = len;
 
497
                _tmp0_ = _tmp2_ >= ((glong) 0);
 
498
        } else {
 
499
                _tmp0_ = FALSE;
 
500
        }
 
501
        _tmp3_ = _tmp0_;
 
502
        if (_tmp3_) {
 
503
                glong _tmp4_;
 
504
                glong _tmp5_;
 
505
                glong _tmp6_ = 0L;
 
506
                _tmp4_ = offset;
 
507
                _tmp5_ = len;
 
508
                _tmp6_ = string_strnlen ((gchar*) self, _tmp4_ + _tmp5_);
 
509
                string_length = _tmp6_;
 
510
        } else {
 
511
                gint _tmp7_;
 
512
                gint _tmp8_;
 
513
                _tmp7_ = strlen (self);
 
514
                _tmp8_ = _tmp7_;
 
515
                string_length = (glong) _tmp8_;
 
516
        }
 
517
        _tmp9_ = offset;
 
518
        if (_tmp9_ < ((glong) 0)) {
 
519
                glong _tmp10_;
 
520
                glong _tmp11_;
 
521
                glong _tmp12_;
 
522
                _tmp10_ = string_length;
 
523
                _tmp11_ = offset;
 
524
                offset = _tmp10_ + _tmp11_;
 
525
                _tmp12_ = offset;
 
526
                g_return_val_if_fail (_tmp12_ >= ((glong) 0), NULL);
 
527
        } else {
 
528
                glong _tmp13_;
 
529
                glong _tmp14_;
 
530
                _tmp13_ = offset;
 
531
                _tmp14_ = string_length;
 
532
                g_return_val_if_fail (_tmp13_ <= _tmp14_, NULL);
 
533
        }
 
534
        _tmp15_ = len;
 
535
        if (_tmp15_ < ((glong) 0)) {
 
536
                glong _tmp16_;
 
537
                glong _tmp17_;
 
538
                _tmp16_ = string_length;
 
539
                _tmp17_ = offset;
 
540
                len = _tmp16_ - _tmp17_;
 
541
        }
 
542
        _tmp18_ = offset;
 
543
        _tmp19_ = len;
 
544
        _tmp20_ = string_length;
 
545
        g_return_val_if_fail ((_tmp18_ + _tmp19_) <= _tmp20_, NULL);
 
546
        _tmp21_ = offset;
 
547
        _tmp22_ = len;
 
548
        _tmp23_ = g_strndup (((gchar*) self) + _tmp21_, (gsize) _tmp22_);
 
549
        result = _tmp23_;
 
550
        return result;
 
551
}
 
552
 
 
553
 
 
554
static GDateTime* history_parse_date (History* self, const gchar* date) {
 
555
        GDateTime* result = NULL;
 
556
        gboolean _tmp0_ = FALSE;
 
557
        gboolean _tmp1_ = FALSE;
 
558
        gboolean _tmp2_ = FALSE;
 
559
        gboolean _tmp3_ = FALSE;
 
560
        gboolean _tmp4_ = FALSE;
 
561
        const gchar* _tmp5_;
 
562
        gint _tmp6_;
 
563
        gint _tmp7_;
 
564
        gboolean _tmp10_;
 
565
        gboolean _tmp13_;
 
566
        gboolean _tmp16_;
 
567
        gboolean _tmp19_;
 
568
        gboolean _tmp22_;
 
569
        const gchar* _tmp23_;
 
570
        gchar* _tmp24_ = NULL;
 
571
        gchar* _tmp25_;
 
572
        gint _tmp26_ = 0;
 
573
        gint _tmp27_;
 
574
        gint year;
 
575
        const gchar* _tmp28_;
 
576
        gchar* _tmp29_ = NULL;
 
577
        gchar* _tmp30_;
 
578
        gint _tmp31_ = 0;
 
579
        gint _tmp32_;
 
580
        gint month;
 
581
        const gchar* _tmp33_;
 
582
        gchar* _tmp34_ = NULL;
 
583
        gchar* _tmp35_;
 
584
        gint _tmp36_ = 0;
 
585
        gint _tmp37_;
 
586
        gint day;
 
587
        const gchar* _tmp38_;
 
588
        gchar* _tmp39_ = NULL;
 
589
        gchar* _tmp40_;
 
590
        gint _tmp41_ = 0;
 
591
        gint _tmp42_;
 
592
        gint hour;
 
593
        const gchar* _tmp43_;
 
594
        gchar* _tmp44_ = NULL;
 
595
        gchar* _tmp45_;
 
596
        gint _tmp46_ = 0;
 
597
        gint _tmp47_;
 
598
        gint minute;
 
599
        const gchar* _tmp48_;
 
600
        gchar* _tmp49_ = NULL;
 
601
        gchar* _tmp50_;
 
602
        gint _tmp51_ = 0;
 
603
        gint _tmp52_;
 
604
        gint seconds;
 
605
        const gchar* _tmp53_;
 
606
        gchar* _tmp54_ = NULL;
 
607
        gchar* timezone;
 
608
        const gchar* _tmp55_;
 
609
        GTimeZone* _tmp56_;
 
610
        GTimeZone* _tmp57_;
 
611
        gint _tmp58_;
 
612
        gint _tmp59_;
 
613
        gint _tmp60_;
 
614
        gint _tmp61_;
 
615
        gint _tmp62_;
 
616
        gint _tmp63_;
 
617
        GDateTime* _tmp64_;
 
618
        GDateTime* _tmp65_;
 
619
        g_return_val_if_fail (self != NULL, NULL);
 
620
        g_return_val_if_fail (date != NULL, NULL);
 
621
        _tmp5_ = date;
 
622
        _tmp6_ = strlen (_tmp5_);
 
623
        _tmp7_ = _tmp6_;
 
624
        if (_tmp7_ < 19) {
 
625
                _tmp4_ = TRUE;
 
626
        } else {
 
627
                const gchar* _tmp8_;
 
628
                gchar _tmp9_ = '\0';
 
629
                _tmp8_ = date;
 
630
                _tmp9_ = string_get (_tmp8_, (glong) 4);
 
631
                _tmp4_ = _tmp9_ != '-';
 
632
        }
 
633
        _tmp10_ = _tmp4_;
 
634
        if (_tmp10_) {
 
635
                _tmp3_ = TRUE;
 
636
        } else {
 
637
                const gchar* _tmp11_;
 
638
                gchar _tmp12_ = '\0';
 
639
                _tmp11_ = date;
 
640
                _tmp12_ = string_get (_tmp11_, (glong) 7);
 
641
                _tmp3_ = _tmp12_ != '-';
 
642
        }
 
643
        _tmp13_ = _tmp3_;
 
644
        if (_tmp13_) {
 
645
                _tmp2_ = TRUE;
 
646
        } else {
 
647
                const gchar* _tmp14_;
 
648
                gchar _tmp15_ = '\0';
 
649
                _tmp14_ = date;
 
650
                _tmp15_ = string_get (_tmp14_, (glong) 10);
 
651
                _tmp2_ = _tmp15_ != 'T';
 
652
        }
 
653
        _tmp16_ = _tmp2_;
 
654
        if (_tmp16_) {
 
655
                _tmp1_ = TRUE;
 
656
        } else {
 
657
                const gchar* _tmp17_;
 
658
                gchar _tmp18_ = '\0';
 
659
                _tmp17_ = date;
 
660
                _tmp18_ = string_get (_tmp17_, (glong) 13);
 
661
                _tmp1_ = _tmp18_ != ':';
 
662
        }
 
663
        _tmp19_ = _tmp1_;
 
664
        if (_tmp19_) {
 
665
                _tmp0_ = TRUE;
 
666
        } else {
 
667
                const gchar* _tmp20_;
 
668
                gchar _tmp21_ = '\0';
 
669
                _tmp20_ = date;
 
670
                _tmp21_ = string_get (_tmp20_, (glong) 16);
 
671
                _tmp0_ = _tmp21_ != ':';
 
672
        }
 
673
        _tmp22_ = _tmp0_;
 
674
        if (_tmp22_) {
 
675
                result = NULL;
 
676
                return result;
 
677
        }
 
678
        _tmp23_ = date;
 
679
        _tmp24_ = string_substring (_tmp23_, (glong) 0, (glong) 4);
 
680
        _tmp25_ = _tmp24_;
 
681
        _tmp26_ = atoi (_tmp25_);
 
682
        _tmp27_ = _tmp26_;
 
683
        _g_free0 (_tmp25_);
 
684
        year = _tmp27_;
 
685
        _tmp28_ = date;
 
686
        _tmp29_ = string_substring (_tmp28_, (glong) 5, (glong) 2);
 
687
        _tmp30_ = _tmp29_;
 
688
        _tmp31_ = atoi (_tmp30_);
 
689
        _tmp32_ = _tmp31_;
 
690
        _g_free0 (_tmp30_);
 
691
        month = _tmp32_;
 
692
        _tmp33_ = date;
 
693
        _tmp34_ = string_substring (_tmp33_, (glong) 8, (glong) 2);
 
694
        _tmp35_ = _tmp34_;
 
695
        _tmp36_ = atoi (_tmp35_);
 
696
        _tmp37_ = _tmp36_;
 
697
        _g_free0 (_tmp35_);
 
698
        day = _tmp37_;
 
699
        _tmp38_ = date;
 
700
        _tmp39_ = string_substring (_tmp38_, (glong) 11, (glong) 2);
 
701
        _tmp40_ = _tmp39_;
 
702
        _tmp41_ = atoi (_tmp40_);
 
703
        _tmp42_ = _tmp41_;
 
704
        _g_free0 (_tmp40_);
 
705
        hour = _tmp42_;
 
706
        _tmp43_ = date;
 
707
        _tmp44_ = string_substring (_tmp43_, (glong) 14, (glong) 2);
 
708
        _tmp45_ = _tmp44_;
 
709
        _tmp46_ = atoi (_tmp45_);
 
710
        _tmp47_ = _tmp46_;
 
711
        _g_free0 (_tmp45_);
 
712
        minute = _tmp47_;
 
713
        _tmp48_ = date;
 
714
        _tmp49_ = string_substring (_tmp48_, (glong) 17, (glong) 2);
 
715
        _tmp50_ = _tmp49_;
 
716
        _tmp51_ = atoi (_tmp50_);
 
717
        _tmp52_ = _tmp51_;
 
718
        _g_free0 (_tmp50_);
 
719
        seconds = _tmp52_;
 
720
        _tmp53_ = date;
 
721
        _tmp54_ = string_substring (_tmp53_, (glong) 19, (glong) (-1));
 
722
        timezone = _tmp54_;
 
723
        _tmp55_ = timezone;
 
724
        _tmp56_ = g_time_zone_new (_tmp55_);
 
725
        _tmp57_ = _tmp56_;
 
726
        _tmp58_ = year;
 
727
        _tmp59_ = month;
 
728
        _tmp60_ = day;
 
729
        _tmp61_ = hour;
 
730
        _tmp62_ = minute;
 
731
        _tmp63_ = seconds;
 
732
        _tmp64_ = g_date_time_new (_tmp57_, _tmp58_, _tmp59_, _tmp60_, _tmp61_, _tmp62_, (gdouble) _tmp63_);
 
733
        _tmp65_ = _tmp64_;
 
734
        _g_time_zone_unref0 (_tmp57_);
 
735
        result = _tmp65_;
 
736
        _g_free0 (timezone);
 
737
        return result;
 
738
}
 
739
 
 
740
 
 
741
static void g_cclosure_user_marshal_VOID__HISTORY_ENTRY (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) {
 
742
        typedef void (*GMarshalFunc_VOID__HISTORY_ENTRY) (gpointer data1, gpointer arg_1, gpointer data2);
 
743
        register GMarshalFunc_VOID__HISTORY_ENTRY callback;
 
744
        register GCClosure * cc;
 
745
        register gpointer data1;
 
746
        register gpointer data2;
 
747
        cc = (GCClosure *) closure;
 
748
        g_return_if_fail (n_param_values == 2);
 
749
        if (G_CCLOSURE_SWAP_DATA (closure)) {
 
750
                data1 = closure->data;
 
751
                data2 = param_values->data[0].v_pointer;
 
752
        } else {
 
753
                data1 = param_values->data[0].v_pointer;
 
754
                data2 = closure->data;
 
755
        }
 
756
        callback = (GMarshalFunc_VOID__HISTORY_ENTRY) (marshal_data ? marshal_data : cc->callback);
 
757
        callback (data1, value_get_history_entry (param_values + 1), data2);
 
758
}
 
759
 
 
760
 
 
761
static void value_history_init (GValue* value) {
 
762
        value->data[0].v_pointer = NULL;
 
763
}
 
764
 
 
765
 
 
766
static void value_history_free_value (GValue* value) {
 
767
        if (value->data[0].v_pointer) {
 
768
                history_unref (value->data[0].v_pointer);
 
769
        }
 
770
}
 
771
 
 
772
 
 
773
static void value_history_copy_value (const GValue* src_value, GValue* dest_value) {
 
774
        if (src_value->data[0].v_pointer) {
 
775
                dest_value->data[0].v_pointer = history_ref (src_value->data[0].v_pointer);
 
776
        } else {
 
777
                dest_value->data[0].v_pointer = NULL;
 
778
        }
 
779
}
 
780
 
 
781
 
 
782
static gpointer value_history_peek_pointer (const GValue* value) {
 
783
        return value->data[0].v_pointer;
 
784
}
 
785
 
 
786
 
 
787
static gchar* value_history_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
 
788
        if (collect_values[0].v_pointer) {
 
789
                History* object;
 
790
                object = collect_values[0].v_pointer;
 
791
                if (object->parent_instance.g_class == NULL) {
 
792
                        return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
 
793
                } else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
 
794
                        return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
 
795
                }
 
796
                value->data[0].v_pointer = history_ref (object);
 
797
        } else {
 
798
                value->data[0].v_pointer = NULL;
 
799
        }
 
800
        return NULL;
 
801
}
 
802
 
 
803
 
 
804
static gchar* value_history_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
 
805
        History** object_p;
 
806
        object_p = collect_values[0].v_pointer;
 
807
        if (!object_p) {
 
808
                return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
 
809
        }
 
810
        if (!value->data[0].v_pointer) {
 
811
                *object_p = NULL;
 
812
        } else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
 
813
                *object_p = value->data[0].v_pointer;
 
814
        } else {
 
815
                *object_p = history_ref (value->data[0].v_pointer);
 
816
        }
 
817
        return NULL;
 
818
}
 
819
 
 
820
 
 
821
GParamSpec* param_spec_history (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
 
822
        ParamSpecHistory* spec;
 
823
        g_return_val_if_fail (g_type_is_a (object_type, TYPE_HISTORY), NULL);
 
824
        spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
 
825
        G_PARAM_SPEC (spec)->value_type = object_type;
 
826
        return G_PARAM_SPEC (spec);
 
827
}
 
828
 
 
829
 
 
830
gpointer value_get_history (const GValue* value) {
 
831
        g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_HISTORY), NULL);
 
832
        return value->data[0].v_pointer;
 
833
}
 
834
 
 
835
 
 
836
void value_set_history (GValue* value, gpointer v_object) {
 
837
        History* old;
 
838
        g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_HISTORY));
 
839
        old = value->data[0].v_pointer;
 
840
        if (v_object) {
 
841
                g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_HISTORY));
 
842
                g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
 
843
                value->data[0].v_pointer = v_object;
 
844
                history_ref (value->data[0].v_pointer);
 
845
        } else {
 
846
                value->data[0].v_pointer = NULL;
 
847
        }
 
848
        if (old) {
 
849
                history_unref (old);
 
850
        }
 
851
}
 
852
 
 
853
 
 
854
void value_take_history (GValue* value, gpointer v_object) {
 
855
        History* old;
 
856
        g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_HISTORY));
 
857
        old = value->data[0].v_pointer;
 
858
        if (v_object) {
 
859
                g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_HISTORY));
 
860
                g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
 
861
                value->data[0].v_pointer = v_object;
 
862
        } else {
 
863
                value->data[0].v_pointer = NULL;
 
864
        }
 
865
        if (old) {
 
866
                history_unref (old);
 
867
        }
 
868
}
 
869
 
 
870
 
 
871
static void history_class_init (HistoryClass * klass) {
 
872
        history_parent_class = g_type_class_peek_parent (klass);
 
873
        HISTORY_CLASS (klass)->finalize = history_finalize;
 
874
        g_signal_new ("entry_added", TYPE_HISTORY, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__HISTORY_ENTRY, G_TYPE_NONE, 1, TYPE_HISTORY_ENTRY);
 
875
}
 
876
 
 
877
 
 
878
static void history_instance_init (History * self) {
 
879
        self->ref_count = 1;
 
880
}
 
881
 
 
882
 
 
883
static void history_finalize (History* obj) {
 
884
        History * self;
 
885
        self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_HISTORY, History);
 
886
        _g_free0 (self->filename);
 
887
        __g_list_free__history_entry_unref0_0 (self->entries);
 
888
}
 
889
 
 
890
 
 
891
GType history_get_type (void) {
 
892
        static volatile gsize history_type_id__volatile = 0;
 
893
        if (g_once_init_enter (&history_type_id__volatile)) {
 
894
                static const GTypeValueTable g_define_type_value_table = { value_history_init, value_history_free_value, value_history_copy_value, value_history_peek_pointer, "p", value_history_collect_value, "p", value_history_lcopy_value };
 
895
                static const GTypeInfo g_define_type_info = { sizeof (HistoryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) history_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (History), 0, (GInstanceInitFunc) history_instance_init, &g_define_type_value_table };
 
896
                static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
 
897
                GType history_type_id;
 
898
                history_type_id = g_type_register_fundamental (g_type_fundamental_next (), "History", &g_define_type_info, &g_define_type_fundamental_info, 0);
 
899
                g_once_init_leave (&history_type_id__volatile, history_type_id);
 
900
        }
 
901
        return history_type_id__volatile;
 
902
}
 
903
 
 
904
 
 
905
gpointer history_ref (gpointer instance) {
 
906
        History* self;
 
907
        self = instance;
 
908
        g_atomic_int_inc (&self->ref_count);
 
909
        return instance;
 
910
}
 
911
 
 
912
 
 
913
void history_unref (gpointer instance) {
 
914
        History* self;
 
915
        self = instance;
 
916
        if (g_atomic_int_dec_and_test (&self->ref_count)) {
 
917
                HISTORY_GET_CLASS (self)->finalize (self);
 
918
                g_type_free_instance ((GTypeInstance *) self);
 
919
        }
 
920
}
 
921
 
 
922
 
 
923
static gpointer _g_date_time_ref0 (gpointer self) {
 
924
        return self ? g_date_time_ref (self) : NULL;
 
925
}
 
926
 
 
927
 
 
928
HistoryEntry* history_entry_construct (GType object_type, GDateTime* date, const gchar* name, guint duration) {
 
929
        HistoryEntry* self = NULL;
 
930
        GDateTime* _tmp0_;
 
931
        GDateTime* _tmp1_;
 
932
        const gchar* _tmp2_;
 
933
        gchar* _tmp3_;
 
934
        guint _tmp4_;
 
935
        g_return_val_if_fail (date != NULL, NULL);
 
936
        g_return_val_if_fail (name != NULL, NULL);
 
937
        self = (HistoryEntry*) g_type_create_instance (object_type);
 
938
        _tmp0_ = date;
 
939
        _tmp1_ = _g_date_time_ref0 (_tmp0_);
 
940
        _g_date_time_unref0 (self->date);
 
941
        self->date = _tmp1_;
 
942
        _tmp2_ = name;
 
943
        _tmp3_ = g_strdup (_tmp2_);
 
944
        _g_free0 (self->name);
 
945
        self->name = _tmp3_;
 
946
        _tmp4_ = duration;
 
947
        self->duration = _tmp4_;
 
948
        return self;
 
949
}
 
950
 
 
951
 
 
952
HistoryEntry* history_entry_new (GDateTime* date, const gchar* name, guint duration) {
 
953
        return history_entry_construct (TYPE_HISTORY_ENTRY, date, name, duration);
 
954
}
 
955
 
 
956
 
 
957
static void value_history_entry_init (GValue* value) {
 
958
        value->data[0].v_pointer = NULL;
 
959
}
 
960
 
 
961
 
 
962
static void value_history_entry_free_value (GValue* value) {
 
963
        if (value->data[0].v_pointer) {
 
964
                history_entry_unref (value->data[0].v_pointer);
 
965
        }
 
966
}
 
967
 
 
968
 
 
969
static void value_history_entry_copy_value (const GValue* src_value, GValue* dest_value) {
 
970
        if (src_value->data[0].v_pointer) {
 
971
                dest_value->data[0].v_pointer = history_entry_ref (src_value->data[0].v_pointer);
 
972
        } else {
 
973
                dest_value->data[0].v_pointer = NULL;
 
974
        }
 
975
}
 
976
 
 
977
 
 
978
static gpointer value_history_entry_peek_pointer (const GValue* value) {
 
979
        return value->data[0].v_pointer;
 
980
}
 
981
 
 
982
 
 
983
static gchar* value_history_entry_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
 
984
        if (collect_values[0].v_pointer) {
 
985
                HistoryEntry* object;
 
986
                object = collect_values[0].v_pointer;
 
987
                if (object->parent_instance.g_class == NULL) {
 
988
                        return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
 
989
                } else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
 
990
                        return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
 
991
                }
 
992
                value->data[0].v_pointer = history_entry_ref (object);
 
993
        } else {
 
994
                value->data[0].v_pointer = NULL;
 
995
        }
 
996
        return NULL;
 
997
}
 
998
 
 
999
 
 
1000
static gchar* value_history_entry_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
 
1001
        HistoryEntry** object_p;
 
1002
        object_p = collect_values[0].v_pointer;
 
1003
        if (!object_p) {
 
1004
                return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
 
1005
        }
 
1006
        if (!value->data[0].v_pointer) {
 
1007
                *object_p = NULL;
 
1008
        } else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
 
1009
                *object_p = value->data[0].v_pointer;
 
1010
        } else {
 
1011
                *object_p = history_entry_ref (value->data[0].v_pointer);
 
1012
        }
 
1013
        return NULL;
 
1014
}
 
1015
 
 
1016
 
 
1017
GParamSpec* param_spec_history_entry (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
 
1018
        ParamSpecHistoryEntry* spec;
 
1019
        g_return_val_if_fail (g_type_is_a (object_type, TYPE_HISTORY_ENTRY), NULL);
 
1020
        spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
 
1021
        G_PARAM_SPEC (spec)->value_type = object_type;
 
1022
        return G_PARAM_SPEC (spec);
 
1023
}
 
1024
 
 
1025
 
 
1026
gpointer value_get_history_entry (const GValue* value) {
 
1027
        g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_HISTORY_ENTRY), NULL);
 
1028
        return value->data[0].v_pointer;
 
1029
}
 
1030
 
 
1031
 
 
1032
void value_set_history_entry (GValue* value, gpointer v_object) {
 
1033
        HistoryEntry* old;
 
1034
        g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_HISTORY_ENTRY));
 
1035
        old = value->data[0].v_pointer;
 
1036
        if (v_object) {
 
1037
                g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_HISTORY_ENTRY));
 
1038
                g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
 
1039
                value->data[0].v_pointer = v_object;
 
1040
                history_entry_ref (value->data[0].v_pointer);
 
1041
        } else {
 
1042
                value->data[0].v_pointer = NULL;
 
1043
        }
 
1044
        if (old) {
 
1045
                history_entry_unref (old);
 
1046
        }
 
1047
}
 
1048
 
 
1049
 
 
1050
void value_take_history_entry (GValue* value, gpointer v_object) {
 
1051
        HistoryEntry* old;
 
1052
        g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_HISTORY_ENTRY));
 
1053
        old = value->data[0].v_pointer;
 
1054
        if (v_object) {
 
1055
                g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_HISTORY_ENTRY));
 
1056
                g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
 
1057
                value->data[0].v_pointer = v_object;
 
1058
        } else {
 
1059
                value->data[0].v_pointer = NULL;
 
1060
        }
 
1061
        if (old) {
 
1062
                history_entry_unref (old);
 
1063
        }
 
1064
}
 
1065
 
 
1066
 
 
1067
static void history_entry_class_init (HistoryEntryClass * klass) {
 
1068
        history_entry_parent_class = g_type_class_peek_parent (klass);
 
1069
        HISTORY_ENTRY_CLASS (klass)->finalize = history_entry_finalize;
 
1070
}
 
1071
 
 
1072
 
 
1073
static void history_entry_instance_init (HistoryEntry * self) {
 
1074
        self->ref_count = 1;
 
1075
}
 
1076
 
 
1077
 
 
1078
static void history_entry_finalize (HistoryEntry* obj) {
 
1079
        HistoryEntry * self;
 
1080
        self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_HISTORY_ENTRY, HistoryEntry);
 
1081
        _g_date_time_unref0 (self->date);
 
1082
        _g_free0 (self->name);
 
1083
}
 
1084
 
 
1085
 
 
1086
GType history_entry_get_type (void) {
 
1087
        static volatile gsize history_entry_type_id__volatile = 0;
 
1088
        if (g_once_init_enter (&history_entry_type_id__volatile)) {
 
1089
                static const GTypeValueTable g_define_type_value_table = { value_history_entry_init, value_history_entry_free_value, value_history_entry_copy_value, value_history_entry_peek_pointer, "p", value_history_entry_collect_value, "p", value_history_entry_lcopy_value };
 
1090
                static const GTypeInfo g_define_type_info = { sizeof (HistoryEntryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) history_entry_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (HistoryEntry), 0, (GInstanceInitFunc) history_entry_instance_init, &g_define_type_value_table };
 
1091
                static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
 
1092
                GType history_entry_type_id;
 
1093
                history_entry_type_id = g_type_register_fundamental (g_type_fundamental_next (), "HistoryEntry", &g_define_type_info, &g_define_type_fundamental_info, 0);
 
1094
                g_once_init_leave (&history_entry_type_id__volatile, history_entry_type_id);
 
1095
        }
 
1096
        return history_entry_type_id__volatile;
 
1097
}
 
1098
 
 
1099
 
 
1100
gpointer history_entry_ref (gpointer instance) {
 
1101
        HistoryEntry* self;
 
1102
        self = instance;
 
1103
        g_atomic_int_inc (&self->ref_count);
 
1104
        return instance;
 
1105
}
 
1106
 
 
1107
 
 
1108
void history_entry_unref (gpointer instance) {
 
1109
        HistoryEntry* self;
 
1110
        self = instance;
 
1111
        if (g_atomic_int_dec_and_test (&self->ref_count)) {
 
1112
                HISTORY_ENTRY_GET_CLASS (self)->finalize (self);
 
1113
                g_type_free_instance ((GTypeInstance *) self);
 
1114
        }
 
1115
}
 
1116
 
 
1117
 
 
1118
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
 
1119
        if ((array != NULL) && (destroy_func != NULL)) {
 
1120
                int i;
 
1121
                for (i = 0; i < array_length; i = i + 1) {
 
1122
                        if (((gpointer*) array)[i] != NULL) {
 
1123
                                destroy_func (((gpointer*) array)[i]);
 
1124
                        }
 
1125
                }
 
1126
        }
 
1127
}
 
1128
 
 
1129
 
 
1130
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
 
1131
        _vala_array_destroy (array, array_length, destroy_func);
 
1132
        g_free (array);
 
1133
}
 
1134
 
 
1135
 
 
1136
static gint _vala_array_length (gpointer array) {
 
1137
        int length;
 
1138
        length = 0;
 
1139
        if (array) {
 
1140
                while (((gpointer*) array)[length]) {
 
1141
                        length++;
 
1142
                }
 
1143
        }
 
1144
        return length;
 
1145
}
 
1146
 
 
1147
 
 
1148