~noskcaj/ubuntu/trusty/gnome-documents/3.10.2

« back to all changes in this revision

Viewing changes to egg-list-box/test-scrolled.c

  • Committer: Package Import Robot
  • Author(s): Andreas Henriksson, Thomas Bechtold
  • Date: 2013-04-04 13:32:08 UTC
  • mfrom: (3.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20130404133208-n19gqczi05z31ogb
Tags: 3.8.0-1
[ Thomas Bechtold ]
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* test-scrolled.c generated by valac 0.19.0, the Vala compiler
 
2
 * generated from test-scrolled.vala, do not modify */
 
3
 
 
4
/* -*- Mode: vala; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 8 -*- */
 
5
/*
 
6
 * Copyright (C) 2011 Alexander Larsson <alexl@redhat.com>
 
7
 *
 
8
 * This program is free software; you can redistribute it and/or modify
 
9
 * it under the terms of the GNU General Public License as published by
 
10
 * the Free Software Foundation; either version 2 of the License, or
 
11
 * (at your option) any later version.
 
12
 *
 
13
 * This program is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
16
 * GNU General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU General Public License
 
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
 */
 
21
 
 
22
#include <glib.h>
 
23
#include <glib-object.h>
 
24
#include <gtk/gtk.h>
 
25
#include <stdlib.h>
 
26
#include <string.h>
 
27
#include <egg-list-box.h>
 
28
 
 
29
 
 
30
#define TYPE_ROW (row_get_type ())
 
31
#define ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ROW, Row))
 
32
#define ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ROW, RowClass))
 
33
#define IS_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ROW))
 
34
#define IS_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ROW))
 
35
#define ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ROW, RowClass))
 
36
 
 
37
typedef struct _Row Row;
 
38
typedef struct _RowClass RowClass;
 
39
typedef struct _RowPrivate RowPrivate;
 
40
#define _g_free0(var) (var = (g_free (var), NULL))
 
41
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
 
42
typedef struct _Block1Data Block1Data;
 
43
 
 
44
struct _Row {
 
45
        GtkGrid parent_instance;
 
46
        RowPrivate * priv;
 
47
        gint32 value;
 
48
};
 
49
 
 
50
struct _RowClass {
 
51
        GtkGridClass parent_class;
 
52
};
 
53
 
 
54
struct _Block1Data {
 
55
        int _ref_count_;
 
56
        EggListBox* list;
 
57
};
 
58
 
 
59
 
 
60
static gpointer row_parent_class = NULL;
 
61
 
 
62
GType row_get_type (void) G_GNUC_CONST;
 
63
enum  {
 
64
        ROW_DUMMY_PROPERTY
 
65
};
 
66
Row* row_new (void);
 
67
Row* row_construct (GType object_type);
 
68
static void row_finalize (GObject* obj);
 
69
gint compare (GtkWidget* a, GtkWidget* b);
 
70
gboolean filter (GtkWidget* widget);
 
71
gint _vala_main (gchar** args, int args_length1);
 
72
static Block1Data* block1_data_ref (Block1Data* _data1_);
 
73
static void block1_data_unref (void * _userdata_);
 
74
static void __lambda2_ (Block1Data* _data1_);
 
75
static gint _compare_gcompare_data_func (gconstpointer a, gconstpointer b, gpointer self);
 
76
static void ___lambda2__gtk_button_clicked (GtkButton* _sender, gpointer self);
 
77
static void __lambda3_ (Block1Data* _data1_);
 
78
static gboolean _filter_egg_list_box_filter_func (GtkWidget* child, gpointer self);
 
79
static void ___lambda3__gtk_button_clicked (GtkButton* _sender, gpointer self);
 
80
static void __lambda4_ (Block1Data* _data1_);
 
81
static void ___lambda4__gtk_button_clicked (GtkButton* _sender, gpointer self);
 
82
 
 
83
 
 
84
Row* row_construct (GType object_type) {
 
85
        Row * self = NULL;
 
86
        gint32 _tmp0_ = 0;
 
87
        gint32 _tmp1_;
 
88
        gchar* _tmp2_ = NULL;
 
89
        gchar* _tmp3_;
 
90
        GtkLabel* _tmp4_;
 
91
        GtkLabel* _tmp5_;
 
92
        GtkLabel* l;
 
93
        self = (Row*) g_object_new (object_type, NULL);
 
94
        _tmp0_ = g_random_int_range ((gint32) 0, (gint32) 10000);
 
95
        self->value = _tmp0_;
 
96
        _tmp1_ = self->value;
 
97
        _tmp2_ = g_strdup_printf ("Value %u", (guint) _tmp1_);
 
98
        _tmp3_ = _tmp2_;
 
99
        _tmp4_ = (GtkLabel*) gtk_label_new (_tmp3_);
 
100
        g_object_ref_sink (_tmp4_);
 
101
        _tmp5_ = _tmp4_;
 
102
        _g_free0 (_tmp3_);
 
103
        l = _tmp5_;
 
104
        gtk_container_add ((GtkContainer*) self, (GtkWidget*) l);
 
105
        gtk_widget_show ((GtkWidget*) l);
 
106
        _g_object_unref0 (l);
 
107
        return self;
 
108
}
 
109
 
 
110
 
 
111
Row* row_new (void) {
 
112
        return row_construct (TYPE_ROW);
 
113
}
 
114
 
 
115
 
 
116
static void row_class_init (RowClass * klass) {
 
117
        row_parent_class = g_type_class_peek_parent (klass);
 
118
        G_OBJECT_CLASS (klass)->finalize = row_finalize;
 
119
}
 
120
 
 
121
 
 
122
static void row_instance_init (Row * self) {
 
123
}
 
124
 
 
125
 
 
126
static void row_finalize (GObject* obj) {
 
127
        Row * self;
 
128
        self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_ROW, Row);
 
129
        G_OBJECT_CLASS (row_parent_class)->finalize (obj);
 
130
}
 
131
 
 
132
 
 
133
GType row_get_type (void) {
 
134
        static volatile gsize row_type_id__volatile = 0;
 
135
        if (g_once_init_enter (&row_type_id__volatile)) {
 
136
                static const GTypeInfo g_define_type_info = { sizeof (RowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) row_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Row), 0, (GInstanceInitFunc) row_instance_init, NULL };
 
137
                GType row_type_id;
 
138
                row_type_id = g_type_register_static (GTK_TYPE_GRID, "Row", &g_define_type_info, 0);
 
139
                g_once_init_leave (&row_type_id__volatile, row_type_id);
 
140
        }
 
141
        return row_type_id__volatile;
 
142
}
 
143
 
 
144
 
 
145
gint compare (GtkWidget* a, GtkWidget* b) {
 
146
        gint result = 0;
 
147
        GtkWidget* _tmp0_;
 
148
        gint32 _tmp1_;
 
149
        GtkWidget* _tmp2_;
 
150
        gint32 _tmp3_;
 
151
        g_return_val_if_fail (a != NULL, 0);
 
152
        g_return_val_if_fail (b != NULL, 0);
 
153
        _tmp0_ = b;
 
154
        _tmp1_ = (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, TYPE_ROW) ? ((Row*) _tmp0_) : NULL)->value;
 
155
        _tmp2_ = a;
 
156
        _tmp3_ = (G_TYPE_CHECK_INSTANCE_TYPE (_tmp2_, TYPE_ROW) ? ((Row*) _tmp2_) : NULL)->value;
 
157
        result = (gint) (((gint32) _tmp1_) - ((gint32) _tmp3_));
 
158
        return result;
 
159
}
 
160
 
 
161
 
 
162
gboolean filter (GtkWidget* widget) {
 
163
        gboolean result = FALSE;
 
164
        GtkWidget* _tmp0_;
 
165
        gint32 _tmp1_;
 
166
        g_return_val_if_fail (widget != NULL, FALSE);
 
167
        _tmp0_ = widget;
 
168
        _tmp1_ = (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, TYPE_ROW) ? ((Row*) _tmp0_) : NULL)->value;
 
169
        result = (_tmp1_ % 2) == ((gint32) 0);
 
170
        return result;
 
171
}
 
172
 
 
173
 
 
174
static Block1Data* block1_data_ref (Block1Data* _data1_) {
 
175
        g_atomic_int_inc (&_data1_->_ref_count_);
 
176
        return _data1_;
 
177
}
 
178
 
 
179
 
 
180
static void block1_data_unref (void * _userdata_) {
 
181
        Block1Data* _data1_;
 
182
        _data1_ = (Block1Data*) _userdata_;
 
183
        if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
 
184
                _g_object_unref0 (_data1_->list);
 
185
                g_slice_free (Block1Data, _data1_);
 
186
        }
 
187
}
 
188
 
 
189
 
 
190
static gint _compare_gcompare_data_func (gconstpointer a, gconstpointer b, gpointer self) {
 
191
        gint result;
 
192
        result = compare (a, b);
 
193
        return result;
 
194
}
 
195
 
 
196
 
 
197
static void __lambda2_ (Block1Data* _data1_) {
 
198
        EggListBox* _tmp0_;
 
199
        _tmp0_ = _data1_->list;
 
200
        egg_list_box_set_sort_func (_tmp0_, _compare_gcompare_data_func, NULL, NULL);
 
201
}
 
202
 
 
203
 
 
204
static void ___lambda2__gtk_button_clicked (GtkButton* _sender, gpointer self) {
 
205
        __lambda2_ (self);
 
206
}
 
207
 
 
208
 
 
209
static gboolean _filter_egg_list_box_filter_func (GtkWidget* child, gpointer self) {
 
210
        gboolean result;
 
211
        result = filter (child);
 
212
        return result;
 
213
}
 
214
 
 
215
 
 
216
static void __lambda3_ (Block1Data* _data1_) {
 
217
        EggListBox* _tmp0_;
 
218
        _tmp0_ = _data1_->list;
 
219
        egg_list_box_set_filter_func (_tmp0_, _filter_egg_list_box_filter_func, NULL, NULL);
 
220
}
 
221
 
 
222
 
 
223
static void ___lambda3__gtk_button_clicked (GtkButton* _sender, gpointer self) {
 
224
        __lambda3_ (self);
 
225
}
 
226
 
 
227
 
 
228
static void __lambda4_ (Block1Data* _data1_) {
 
229
        EggListBox* _tmp0_;
 
230
        _tmp0_ = _data1_->list;
 
231
        egg_list_box_set_filter_func (_tmp0_, NULL, NULL, NULL);
 
232
}
 
233
 
 
234
 
 
235
static void ___lambda4__gtk_button_clicked (GtkButton* _sender, gpointer self) {
 
236
        __lambda4_ (self);
 
237
}
 
238
 
 
239
 
 
240
gint _vala_main (gchar** args, int args_length1) {
 
241
        gint result = 0;
 
242
        Block1Data* _data1_;
 
243
        gint num_rows;
 
244
        gchar** _tmp0_;
 
245
        gint _tmp0__length1;
 
246
        gint _tmp4_;
 
247
        GtkWindow* _tmp5_;
 
248
        GtkWindow* w;
 
249
        GtkBox* _tmp6_;
 
250
        GtkBox* hbox;
 
251
        GtkWindow* _tmp7_;
 
252
        GtkBox* _tmp8_;
 
253
        GtkScrolledWindow* _tmp9_;
 
254
        GtkScrolledWindow* scrolled;
 
255
        GtkScrolledWindow* _tmp10_;
 
256
        GtkBox* _tmp11_;
 
257
        GtkScrolledWindow* _tmp12_;
 
258
        GtkBox* _tmp13_;
 
259
        GtkBox* scrolled_box;
 
260
        GtkScrolledWindow* _tmp14_;
 
261
        GtkBox* _tmp15_;
 
262
        GtkLabel* _tmp16_;
 
263
        GtkLabel* label;
 
264
        GtkBox* _tmp17_;
 
265
        GtkLabel* _tmp18_;
 
266
        EggListBox* _tmp19_;
 
267
        GtkBox* _tmp20_;
 
268
        EggListBox* _tmp21_;
 
269
        EggListBox* _tmp22_;
 
270
        GtkScrolledWindow* _tmp23_;
 
271
        GtkAdjustment* _tmp24_ = NULL;
 
272
        GtkBox* _tmp33_;
 
273
        GtkBox* vbox;
 
274
        GtkBox* _tmp34_;
 
275
        GtkButton* _tmp35_;
 
276
        GtkButton* b;
 
277
        GtkButton* _tmp36_;
 
278
        GtkButton* _tmp37_;
 
279
        GtkButton* _tmp38_;
 
280
        GtkButton* _tmp39_;
 
281
        GtkButton* _tmp40_;
 
282
        GtkButton* _tmp41_;
 
283
        GtkButton* _tmp42_;
 
284
        GtkButton* _tmp43_;
 
285
        GtkWindow* _tmp44_;
 
286
        _data1_ = g_slice_new0 (Block1Data);
 
287
        _data1_->_ref_count_ = 1;
 
288
        num_rows = 0;
 
289
        gtk_init (&args_length1, &args);
 
290
        _tmp0_ = args;
 
291
        _tmp0__length1 = args_length1;
 
292
        if (_tmp0__length1 > 1) {
 
293
                gchar** _tmp1_;
 
294
                gint _tmp1__length1;
 
295
                const gchar* _tmp2_;
 
296
                gint _tmp3_ = 0;
 
297
                _tmp1_ = args;
 
298
                _tmp1__length1 = args_length1;
 
299
                _tmp2_ = _tmp1_[1];
 
300
                _tmp3_ = atoi (_tmp2_);
 
301
                num_rows = _tmp3_;
 
302
        }
 
303
        _tmp4_ = num_rows;
 
304
        if (_tmp4_ == 0) {
 
305
                num_rows = 1000;
 
306
        }
 
307
        _tmp5_ = (GtkWindow*) gtk_window_new (GTK_WINDOW_TOPLEVEL);
 
308
        g_object_ref_sink (_tmp5_);
 
309
        w = _tmp5_;
 
310
        _tmp6_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
 
311
        g_object_ref_sink (_tmp6_);
 
312
        hbox = _tmp6_;
 
313
        _tmp7_ = w;
 
314
        _tmp8_ = hbox;
 
315
        gtk_container_add ((GtkContainer*) _tmp7_, (GtkWidget*) _tmp8_);
 
316
        _tmp9_ = (GtkScrolledWindow*) gtk_scrolled_window_new (NULL, NULL);
 
317
        g_object_ref_sink (_tmp9_);
 
318
        scrolled = _tmp9_;
 
319
        _tmp10_ = scrolled;
 
320
        gtk_scrolled_window_set_policy (_tmp10_, GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
 
321
        _tmp11_ = hbox;
 
322
        _tmp12_ = scrolled;
 
323
        gtk_container_add ((GtkContainer*) _tmp11_, (GtkWidget*) _tmp12_);
 
324
        _tmp13_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
 
325
        g_object_ref_sink (_tmp13_);
 
326
        scrolled_box = _tmp13_;
 
327
        _tmp14_ = scrolled;
 
328
        _tmp15_ = scrolled_box;
 
329
        gtk_container_add ((GtkContainer*) _tmp14_, (GtkWidget*) _tmp15_);
 
330
        _tmp16_ = (GtkLabel*) gtk_label_new ("This is \na LABEL\nwith rows");
 
331
        g_object_ref_sink (_tmp16_);
 
332
        label = _tmp16_;
 
333
        _tmp17_ = scrolled_box;
 
334
        _tmp18_ = label;
 
335
        gtk_container_add ((GtkContainer*) _tmp17_, (GtkWidget*) _tmp18_);
 
336
        _tmp19_ = egg_list_box_new ();
 
337
        g_object_ref_sink (_tmp19_);
 
338
        _data1_->list = _tmp19_;
 
339
        _tmp20_ = scrolled_box;
 
340
        _tmp21_ = _data1_->list;
 
341
        gtk_container_add ((GtkContainer*) _tmp20_, (GtkWidget*) _tmp21_);
 
342
        _tmp22_ = _data1_->list;
 
343
        _tmp23_ = scrolled;
 
344
        _tmp24_ = gtk_scrolled_window_get_vadjustment (_tmp23_);
 
345
        egg_list_box_set_adjustment (_tmp22_, _tmp24_);
 
346
        {
 
347
                gint i;
 
348
                i = 0;
 
349
                {
 
350
                        gboolean _tmp25_;
 
351
                        _tmp25_ = TRUE;
 
352
                        while (TRUE) {
 
353
                                gboolean _tmp26_;
 
354
                                gint _tmp28_;
 
355
                                gint _tmp29_;
 
356
                                Row* _tmp30_;
 
357
                                Row* row;
 
358
                                EggListBox* _tmp31_;
 
359
                                Row* _tmp32_;
 
360
                                _tmp26_ = _tmp25_;
 
361
                                if (!_tmp26_) {
 
362
                                        gint _tmp27_;
 
363
                                        _tmp27_ = i;
 
364
                                        i = _tmp27_ + 1;
 
365
                                }
 
366
                                _tmp25_ = FALSE;
 
367
                                _tmp28_ = i;
 
368
                                _tmp29_ = num_rows;
 
369
                                if (!(_tmp28_ < _tmp29_)) {
 
370
                                        break;
 
371
                                }
 
372
                                _tmp30_ = row_new ();
 
373
                                g_object_ref_sink (_tmp30_);
 
374
                                row = _tmp30_;
 
375
                                _tmp31_ = _data1_->list;
 
376
                                _tmp32_ = row;
 
377
                                gtk_container_add ((GtkContainer*) _tmp31_, (GtkWidget*) _tmp32_);
 
378
                                _g_object_unref0 (row);
 
379
                        }
 
380
                }
 
381
        }
 
382
        _tmp33_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
 
383
        g_object_ref_sink (_tmp33_);
 
384
        vbox = _tmp33_;
 
385
        _tmp34_ = hbox;
 
386
        gtk_container_add ((GtkContainer*) _tmp34_, (GtkWidget*) vbox);
 
387
        _tmp35_ = (GtkButton*) gtk_button_new_with_label ("sort");
 
388
        g_object_ref_sink (_tmp35_);
 
389
        b = _tmp35_;
 
390
        _tmp36_ = b;
 
391
        gtk_container_add ((GtkContainer*) vbox, (GtkWidget*) _tmp36_);
 
392
        _tmp37_ = b;
 
393
        g_signal_connect_data (_tmp37_, "clicked", (GCallback) ___lambda2__gtk_button_clicked, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0);
 
394
        _tmp38_ = (GtkButton*) gtk_button_new_with_label ("filter");
 
395
        g_object_ref_sink (_tmp38_);
 
396
        _g_object_unref0 (b);
 
397
        b = _tmp38_;
 
398
        _tmp39_ = b;
 
399
        gtk_container_add ((GtkContainer*) vbox, (GtkWidget*) _tmp39_);
 
400
        _tmp40_ = b;
 
401
        g_signal_connect_data (_tmp40_, "clicked", (GCallback) ___lambda3__gtk_button_clicked, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0);
 
402
        _tmp41_ = (GtkButton*) gtk_button_new_with_label ("unfilter");
 
403
        g_object_ref_sink (_tmp41_);
 
404
        _g_object_unref0 (b);
 
405
        b = _tmp41_;
 
406
        _tmp42_ = b;
 
407
        gtk_container_add ((GtkContainer*) vbox, (GtkWidget*) _tmp42_);
 
408
        _tmp43_ = b;
 
409
        g_signal_connect_data (_tmp43_, "clicked", (GCallback) ___lambda4__gtk_button_clicked, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0);
 
410
        _tmp44_ = w;
 
411
        gtk_widget_show_all ((GtkWidget*) _tmp44_);
 
412
        gtk_main ();
 
413
        result = 0;
 
414
        _g_object_unref0 (b);
 
415
        _g_object_unref0 (vbox);
 
416
        _g_object_unref0 (label);
 
417
        _g_object_unref0 (scrolled_box);
 
418
        _g_object_unref0 (scrolled);
 
419
        _g_object_unref0 (hbox);
 
420
        _g_object_unref0 (w);
 
421
        block1_data_unref (_data1_);
 
422
        _data1_ = NULL;
 
423
        return result;
 
424
}
 
425
 
 
426
 
 
427
int main (int argc, char ** argv) {
 
428
        g_type_init ();
 
429
        return _vala_main (argv, argc);
 
430
}
 
431
 
 
432
 
 
433