1
/* history.c generated by valac 0.18.1, the Vala compiler
2
* generated from history.vala, do not modify */
6
#include <glib-object.h>
9
#include <glib/gstdio.h>
12
#include <gobject/gvaluecollector.h>
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))
22
typedef struct _History History;
23
typedef struct _HistoryClass HistoryClass;
24
typedef struct _HistoryPrivate HistoryPrivate;
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))
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;
46
GTypeInstance parent_instance;
47
volatile int ref_count;
48
HistoryPrivate * priv;
53
struct _HistoryClass {
54
GTypeClass parent_class;
55
void (*finalize) (History *self);
58
struct _HistoryEntry {
59
GTypeInstance parent_instance;
60
volatile int ref_count;
61
HistoryEntryPrivate * priv;
67
struct _HistoryEntryClass {
68
GTypeClass parent_class;
69
void (*finalize) (HistoryEntry *self);
72
struct _ParamSpecHistory {
73
GParamSpec parent_instance;
76
struct _ParamSpecHistoryEntry {
77
GParamSpec parent_instance;
81
static gpointer history_parent_class = NULL;
82
static gpointer history_entry_parent_class = NULL;
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;
99
HISTORY_DUMMY_PROPERTY
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);
114
HISTORY_ENTRY_DUMMY_PROPERTY
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);
122
static void _history_entry_unref0_ (gpointer var) {
123
(var == NULL) ? NULL : (var = (history_entry_unref (var), NULL));
127
static void _g_list_free__history_entry_unref0_ (GList* self) {
128
g_list_foreach (self, (GFunc) _history_entry_unref0_, NULL);
133
History* history_construct (GType object_type, const gchar* filename) {
134
History* self = NULL;
137
g_return_val_if_fail (filename != NULL, NULL);
138
self = (History*) g_type_create_instance (object_type);
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;
149
History* history_new (const gchar* filename) {
150
return history_construct (TYPE_HISTORY, filename);
154
static gpointer _history_entry_ref0 (gpointer self) {
155
return self ? history_entry_ref (self) : NULL;
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);
166
_tmp1_ = _history_entry_ref0 (_tmp0_);
167
self->entries = g_list_append (self->entries, _tmp1_);
169
g_signal_emit_by_name (self, "entry-added", _tmp2_);
173
void history_load (History* self) {
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 ("");
187
gchar* _tmp2_ = NULL;
188
_tmp1_ = self->filename;
189
g_file_get_contents (_tmp1_, &_tmp2_, NULL, &_inner_error_);
192
if (_inner_error_ != NULL) {
193
if (_inner_error_->domain == G_FILE_ERROR) {
194
goto __catch8_g_file_error;
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_);
203
__catch8_g_file_error:
208
_inner_error_ = NULL;
210
if (!g_error_matches (_tmp3_, G_FILE_ERROR, G_FILE_ERROR_NOENT)) {
214
_tmp5_ = _tmp4_->message;
215
g_warning ("history.vala:32: Failed to load history: %s", _tmp5_);
222
if (_inner_error_ != NULL) {
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_);
229
_tmp8_ = _tmp7_ = g_strsplit (_tmp6_, "\n", 0);
231
gchar** line_collection = NULL;
232
gint line_collection_length1 = 0;
233
gint _line_collection_size_ = 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) {
240
_tmp9_ = g_strdup (line_collection[line_it]);
243
const gchar* _tmp10_;
245
gchar** _tmp12_ = NULL;
250
gint _tmp13__length1;
252
gint _tmp14__length1;
253
const gchar* _tmp15_;
254
GDateTime* _tmp16_ = NULL;
258
gint _tmp18__length1;
259
const gchar* _tmp19_;
263
gint _tmp21__length1;
264
const gchar* _tmp22_;
268
const gchar* _tmp25_;
270
HistoryEntry* _tmp27_;
271
HistoryEntry* _tmp28_;
273
_tmp12_ = _tmp11_ = g_strsplit (_tmp10_, " ", 0);
275
tokens_length1 = _vala_array_length (_tmp11_);
276
_tokens_size_ = tokens_length1;
278
_tmp13__length1 = tokens_length1;
279
if (_tmp13__length1 != 3) {
280
tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL);
285
_tmp14__length1 = tokens_length1;
286
_tmp15_ = _tmp14_[0];
287
_tmp16_ = history_parse_date (self, _tmp15_);
290
if (_tmp17_ == NULL) {
291
_g_date_time_unref0 (date);
292
tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL);
297
_tmp18__length1 = tokens_length1;
298
_tmp19_ = _tmp18_[1];
299
_tmp20_ = g_strdup (_tmp19_);
302
_tmp21__length1 = tokens_length1;
303
_tmp22_ = _tmp21_[2];
304
_tmp23_ = atoi (_tmp22_);
309
_tmp27_ = history_entry_new (_tmp24_, _tmp25_, (guint) _tmp26_);
311
history_add (self, _tmp28_);
312
_history_entry_unref0 (_tmp28_);
314
_g_date_time_unref0 (date);
315
tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL);
319
line_collection = (_vala_array_free (line_collection, line_collection_length1, (GDestroyNotify) g_free), NULL);
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");
335
void history_save (History* self) {
339
GError * _inner_error_ = NULL;
340
g_return_if_fail (self != NULL);
341
_tmp0_ = g_strdup ("");
343
_tmp1_ = self->entries;
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);
354
HistoryEntry* _tmp3_;
356
gchar* _tmp5_ = NULL;
358
HistoryEntry* _tmp7_;
360
HistoryEntry* _tmp9_;
362
gchar* _tmp11_ = NULL;
365
const gchar* _tmp13_;
366
const gchar* _tmp14_;
369
_tmp4_ = _tmp3_->date;
370
_tmp5_ = g_date_time_to_string (_tmp4_);
373
_tmp8_ = _tmp7_->name;
375
_tmp10_ = _tmp9_->duration;
376
_tmp11_ = g_strdup_printf ("%s %s %u\n", _tmp6_, _tmp8_, _tmp10_);
382
_tmp15_ = g_strconcat (_tmp13_, _tmp14_, NULL);
386
_history_entry_unref0 (entry);
391
const gchar* _tmp16_;
392
gchar* _tmp17_ = NULL;
394
const gchar* _tmp19_;
395
const gchar* _tmp20_;
396
_tmp16_ = self->filename;
397
_tmp17_ = g_path_get_dirname (_tmp16_);
399
g_mkdir_with_parents (_tmp18_, 0775);
401
_tmp19_ = self->filename;
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;
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_);
415
__catch9_g_file_error:
419
const gchar* _tmp22_;
421
_inner_error_ = NULL;
423
_tmp22_ = _tmp21_->message;
424
g_warning ("history.vala:69: Failed to save history: %s", _tmp22_);
428
if (_inner_error_ != NULL) {
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_);
438
static gchar string_get (const gchar* self, glong index) {
442
g_return_val_if_fail (self != NULL, '\0');
444
_tmp1_ = ((gchar*) self)[_tmp0_];
450
static glong string_strnlen (gchar* str, glong maxlen) {
454
gchar* _tmp2_ = NULL;
459
_tmp2_ = memchr (_tmp0_, 0, (gsize) _tmp1_);
462
if (_tmp3_ == NULL) {
472
result = (glong) (_tmp5_ - _tmp6_);
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;
491
gchar* _tmp23_ = NULL;
492
g_return_val_if_fail (self != NULL, NULL);
494
if (_tmp1_ >= ((glong) 0)) {
497
_tmp0_ = _tmp2_ >= ((glong) 0);
508
_tmp6_ = string_strnlen ((gchar*) self, _tmp4_ + _tmp5_);
509
string_length = _tmp6_;
513
_tmp7_ = strlen (self);
515
string_length = (glong) _tmp8_;
518
if (_tmp9_ < ((glong) 0)) {
522
_tmp10_ = string_length;
524
offset = _tmp10_ + _tmp11_;
526
g_return_val_if_fail (_tmp12_ >= ((glong) 0), NULL);
531
_tmp14_ = string_length;
532
g_return_val_if_fail (_tmp13_ <= _tmp14_, NULL);
535
if (_tmp15_ < ((glong) 0)) {
538
_tmp16_ = string_length;
540
len = _tmp16_ - _tmp17_;
544
_tmp20_ = string_length;
545
g_return_val_if_fail ((_tmp18_ + _tmp19_) <= _tmp20_, NULL);
548
_tmp23_ = g_strndup (((gchar*) self) + _tmp21_, (gsize) _tmp22_);
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;
569
const gchar* _tmp23_;
570
gchar* _tmp24_ = NULL;
575
const gchar* _tmp28_;
576
gchar* _tmp29_ = NULL;
581
const gchar* _tmp33_;
582
gchar* _tmp34_ = NULL;
587
const gchar* _tmp38_;
588
gchar* _tmp39_ = NULL;
593
const gchar* _tmp43_;
594
gchar* _tmp44_ = NULL;
599
const gchar* _tmp48_;
600
gchar* _tmp49_ = NULL;
605
const gchar* _tmp53_;
606
gchar* _tmp54_ = NULL;
608
const gchar* _tmp55_;
619
g_return_val_if_fail (self != NULL, NULL);
620
g_return_val_if_fail (date != NULL, NULL);
622
_tmp6_ = strlen (_tmp5_);
630
_tmp9_ = string_get (_tmp8_, (glong) 4);
631
_tmp4_ = _tmp9_ != '-';
637
const gchar* _tmp11_;
638
gchar _tmp12_ = '\0';
640
_tmp12_ = string_get (_tmp11_, (glong) 7);
641
_tmp3_ = _tmp12_ != '-';
647
const gchar* _tmp14_;
648
gchar _tmp15_ = '\0';
650
_tmp15_ = string_get (_tmp14_, (glong) 10);
651
_tmp2_ = _tmp15_ != 'T';
657
const gchar* _tmp17_;
658
gchar _tmp18_ = '\0';
660
_tmp18_ = string_get (_tmp17_, (glong) 13);
661
_tmp1_ = _tmp18_ != ':';
667
const gchar* _tmp20_;
668
gchar _tmp21_ = '\0';
670
_tmp21_ = string_get (_tmp20_, (glong) 16);
671
_tmp0_ = _tmp21_ != ':';
679
_tmp24_ = string_substring (_tmp23_, (glong) 0, (glong) 4);
681
_tmp26_ = atoi (_tmp25_);
686
_tmp29_ = string_substring (_tmp28_, (glong) 5, (glong) 2);
688
_tmp31_ = atoi (_tmp30_);
693
_tmp34_ = string_substring (_tmp33_, (glong) 8, (glong) 2);
695
_tmp36_ = atoi (_tmp35_);
700
_tmp39_ = string_substring (_tmp38_, (glong) 11, (glong) 2);
702
_tmp41_ = atoi (_tmp40_);
707
_tmp44_ = string_substring (_tmp43_, (glong) 14, (glong) 2);
709
_tmp46_ = atoi (_tmp45_);
714
_tmp49_ = string_substring (_tmp48_, (glong) 17, (glong) 2);
716
_tmp51_ = atoi (_tmp50_);
721
_tmp54_ = string_substring (_tmp53_, (glong) 19, (glong) (-1));
724
_tmp56_ = g_time_zone_new (_tmp55_);
732
_tmp64_ = g_date_time_new (_tmp57_, _tmp58_, _tmp59_, _tmp60_, _tmp61_, _tmp62_, (gdouble) _tmp63_);
734
_g_time_zone_unref0 (_tmp57_);
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;
753
data1 = param_values->data[0].v_pointer;
754
data2 = closure->data;
756
callback = (GMarshalFunc_VOID__HISTORY_ENTRY) (marshal_data ? marshal_data : cc->callback);
757
callback (data1, value_get_history_entry (param_values + 1), data2);
761
static void value_history_init (GValue* value) {
762
value->data[0].v_pointer = NULL;
766
static void value_history_free_value (GValue* value) {
767
if (value->data[0].v_pointer) {
768
history_unref (value->data[0].v_pointer);
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);
777
dest_value->data[0].v_pointer = NULL;
782
static gpointer value_history_peek_pointer (const GValue* value) {
783
return value->data[0].v_pointer;
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) {
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);
796
value->data[0].v_pointer = history_ref (object);
798
value->data[0].v_pointer = NULL;
804
static gchar* value_history_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
806
object_p = collect_values[0].v_pointer;
808
return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
810
if (!value->data[0].v_pointer) {
812
} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
813
*object_p = value->data[0].v_pointer;
815
*object_p = history_ref (value->data[0].v_pointer);
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);
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;
836
void value_set_history (GValue* value, gpointer v_object) {
838
g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_HISTORY));
839
old = value->data[0].v_pointer;
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);
846
value->data[0].v_pointer = NULL;
854
void value_take_history (GValue* value, gpointer v_object) {
856
g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_HISTORY));
857
old = value->data[0].v_pointer;
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;
863
value->data[0].v_pointer = NULL;
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);
878
static void history_instance_init (History * self) {
883
static void history_finalize (History* obj) {
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);
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);
901
return history_type_id__volatile;
905
gpointer history_ref (gpointer instance) {
908
g_atomic_int_inc (&self->ref_count);
913
void history_unref (gpointer 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);
923
static gpointer _g_date_time_ref0 (gpointer self) {
924
return self ? g_date_time_ref (self) : NULL;
928
HistoryEntry* history_entry_construct (GType object_type, GDateTime* date, const gchar* name, guint duration) {
929
HistoryEntry* self = NULL;
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);
939
_tmp1_ = _g_date_time_ref0 (_tmp0_);
940
_g_date_time_unref0 (self->date);
943
_tmp3_ = g_strdup (_tmp2_);
944
_g_free0 (self->name);
947
self->duration = _tmp4_;
952
HistoryEntry* history_entry_new (GDateTime* date, const gchar* name, guint duration) {
953
return history_entry_construct (TYPE_HISTORY_ENTRY, date, name, duration);
957
static void value_history_entry_init (GValue* value) {
958
value->data[0].v_pointer = NULL;
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);
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);
973
dest_value->data[0].v_pointer = NULL;
978
static gpointer value_history_entry_peek_pointer (const GValue* value) {
979
return value->data[0].v_pointer;
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);
992
value->data[0].v_pointer = history_entry_ref (object);
994
value->data[0].v_pointer = NULL;
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;
1004
return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
1006
if (!value->data[0].v_pointer) {
1008
} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
1009
*object_p = value->data[0].v_pointer;
1011
*object_p = history_entry_ref (value->data[0].v_pointer);
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);
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;
1032
void value_set_history_entry (GValue* value, gpointer v_object) {
1034
g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_HISTORY_ENTRY));
1035
old = value->data[0].v_pointer;
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);
1042
value->data[0].v_pointer = NULL;
1045
history_entry_unref (old);
1050
void value_take_history_entry (GValue* value, gpointer v_object) {
1052
g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_HISTORY_ENTRY));
1053
old = value->data[0].v_pointer;
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;
1059
value->data[0].v_pointer = NULL;
1062
history_entry_unref (old);
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;
1073
static void history_entry_instance_init (HistoryEntry * self) {
1074
self->ref_count = 1;
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);
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);
1096
return history_entry_type_id__volatile;
1100
gpointer history_entry_ref (gpointer instance) {
1103
g_atomic_int_inc (&self->ref_count);
1108
void history_entry_unref (gpointer 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);
1118
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
1119
if ((array != NULL) && (destroy_func != NULL)) {
1121
for (i = 0; i < array_length; i = i + 1) {
1122
if (((gpointer*) array)[i] != NULL) {
1123
destroy_func (((gpointer*) array)[i]);
1130
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
1131
_vala_array_destroy (array, array_length, destroy_func);
1136
static gint _vala_array_length (gpointer array) {
1140
while (((gpointer*) array)[length]) {