1
/* preferences.c generated by valac 0.16.0, the Vala compiler
2
* generated from preferences.vala, do not modify */
6
#include <glib-object.h>
12
#include <glib/gi18n-lib.h>
15
#define TYPE_PREFERENCES (preferences_get_type ())
16
#define PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PREFERENCES, Preferences))
17
#define PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PREFERENCES, PreferencesClass))
18
#define IS_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PREFERENCES))
19
#define IS_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PREFERENCES))
20
#define PREFERENCES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PREFERENCES, PreferencesClass))
22
typedef struct _Preferences Preferences;
23
typedef struct _PreferencesClass PreferencesClass;
24
typedef struct _PreferencesPrivate PreferencesPrivate;
25
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
26
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
27
#define _g_free0(var) (var = (g_free (var), NULL))
29
#define TYPE_BLACKLIST_PREFERENCE (blacklist_preference_get_type ())
30
#define BLACKLIST_PREFERENCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_BLACKLIST_PREFERENCE, BlacklistPreference))
31
#define BLACKLIST_PREFERENCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_BLACKLIST_PREFERENCE, BlacklistPreferenceClass))
32
#define IS_BLACKLIST_PREFERENCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_BLACKLIST_PREFERENCE))
33
#define IS_BLACKLIST_PREFERENCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_BLACKLIST_PREFERENCE))
34
#define BLACKLIST_PREFERENCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_BLACKLIST_PREFERENCE, BlacklistPreferenceClass))
36
typedef struct _BlacklistPreference BlacklistPreference;
37
typedef struct _BlacklistPreferenceClass BlacklistPreferenceClass;
38
typedef struct _BlacklistPreferencePrivate BlacklistPreferencePrivate;
40
#define BLACKLIST_PREFERENCE_TYPE_COLUMN (blacklist_preference_column_get_type ())
43
GObject parent_instance;
44
PreferencesPrivate * priv;
47
struct _PreferencesClass {
48
GObjectClass parent_class;
51
struct _PreferencesPrivate {
55
struct _BlacklistPreference {
56
GObject parent_instance;
57
BlacklistPreferencePrivate * priv;
60
struct _BlacklistPreferenceClass {
61
GObjectClass parent_class;
64
struct _BlacklistPreferencePrivate {
65
GtkTreeView* _treeview;
66
GtkListStore* _liststore;
67
GStaticRecMutex __lock__liststore;
68
GtkButton* _add_button;
69
GtkButton* _remove_button;
75
BLACKLIST_PREFERENCE_COLUMN_APP_NAME = 0,
76
BLACKLIST_PREFERENCE_COLUMN_COUNT
77
} BlacklistPreferenceColumn;
80
static gpointer preferences_parent_class = NULL;
81
static gpointer blacklist_preference_parent_class = NULL;
83
GType preferences_get_type (void) G_GNUC_CONST;
84
#define PREFERENCES_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_PREFERENCES, PreferencesPrivate))
86
PREFERENCES_DUMMY_PROPERTY
88
#define PREFERENCES_SCHEMA_ID "net.launchpad.RecentNotifications"
89
#define PREFERENCES_SCHEMA_PATH "/net/launchpad/RecentNotifications/"
90
#define PREFERENCES_BLACKLIST "blacklist"
91
#define PREFERENCES_CONSOLE_LOG "console-log"
92
#define PREFERENCES_DEBUG "debug"
93
#define PREFERENCES_NOTIFICATION_LIMIT "notification-limit"
94
#define PREFERENCES_SHOW_COUNT "show-count"
95
Preferences* preferences_new (void);
96
Preferences* preferences_construct (GType object_type);
97
void preferences_bind (Preferences* self, const gchar* key, GObject* object, const gchar* property);
98
void preferences_bind_read_only (Preferences* self, const gchar* key, GObject* object, const gchar* property);
99
void preferences_show_dialog (Preferences* self);
100
BlacklistPreference* blacklist_preference_new (GSettings* settings, GtkBuilder* builder);
101
BlacklistPreference* blacklist_preference_construct (GType object_type, GSettings* settings, GtkBuilder* builder);
102
GType blacklist_preference_get_type (void) G_GNUC_CONST;
103
void blacklist_preference_connect_handlers (BlacklistPreference* self);
104
static void preferences_finalize (GObject* obj);
105
#define BLACKLIST_PREFERENCE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_BLACKLIST_PREFERENCE, BlacklistPreferencePrivate))
107
BLACKLIST_PREFERENCE_DUMMY_PROPERTY
109
static GType blacklist_preference_column_get_type (void) G_GNUC_UNUSED;
110
static void blacklist_preference_set_values (BlacklistPreference* self, gchar** values, int values_length1);
111
static void __lambda16_ (BlacklistPreference* self, GtkButton* button);
112
static void blacklist_preference_append_item (BlacklistPreference* self, const gchar* item);
113
static gchar** blacklist_preference_get_values (BlacklistPreference* self, int* result_length1);
114
static void ___lambda16__gtk_button_clicked (GtkButton* _sender, gpointer self);
115
static void __lambda17_ (BlacklistPreference* self, GtkButton* button);
116
static gboolean blacklist_preference_remove_item (BlacklistPreference* self);
117
static void ___lambda17__gtk_button_clicked (GtkButton* _sender, gpointer self);
118
static void blacklist_preference_finalize (GObject* obj);
119
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
120
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
121
static gint _vala_array_length (gpointer array);
124
Preferences* preferences_construct (GType object_type) {
125
Preferences * self = NULL;
127
self = (Preferences*) g_object_new (object_type, NULL);
128
_tmp0_ = g_settings_new (PREFERENCES_SCHEMA_ID);
129
_g_object_unref0 (self->priv->_settings);
130
self->priv->_settings = _tmp0_;
135
Preferences* preferences_new (void) {
136
return preferences_construct (TYPE_PREFERENCES);
141
* Binds an object's property. When the property is set, the GSettings key is
142
* updated, and when the GSettings key is updated, the property is updated.
144
* @param key the preference key
145
* @param object the object interested
146
* @param property the object's property to bind
148
void preferences_bind (Preferences* self, const gchar* key, GObject* object, const gchar* property) {
153
g_return_if_fail (self != NULL);
154
g_return_if_fail (key != NULL);
155
g_return_if_fail (object != NULL);
156
g_return_if_fail (property != NULL);
157
_tmp0_ = self->priv->_settings;
161
g_settings_bind (_tmp0_, _tmp1_, _tmp2_, _tmp3_, G_SETTINGS_BIND_DEFAULT);
166
* Binds an object's property. When the GSettings key is updated, the
167
* property is updated.
169
* @param key the preference key
170
* @param object the object interested
171
* @param property the object's property to bind
173
void preferences_bind_read_only (Preferences* self, const gchar* key, GObject* object, const gchar* property) {
178
g_return_if_fail (self != NULL);
179
g_return_if_fail (key != NULL);
180
g_return_if_fail (object != NULL);
181
g_return_if_fail (property != NULL);
182
_tmp0_ = self->priv->_settings;
186
g_settings_bind (_tmp0_, _tmp1_, _tmp2_, _tmp3_, G_SETTINGS_BIND_GET);
191
* Shows the preferences dialog.
193
static gpointer _g_object_ref0 (gpointer self) {
194
return self ? g_object_ref (self) : NULL;
198
void preferences_show_dialog (Preferences* self) {
204
GObject* _tmp8_ = NULL;
208
GObject* _tmp11_ = NULL;
209
GtkCheckButton* _tmp12_;
210
GtkCheckButton* debug_button;
211
GtkCheckButton* _tmp13_;
213
GObject* _tmp15_ = NULL;
214
GtkCheckButton* _tmp16_;
215
GtkCheckButton* console_log_button;
216
GtkCheckButton* _tmp17_;
218
GObject* _tmp19_ = NULL;
219
GtkCheckButton* _tmp20_;
220
GtkCheckButton* show_count_button;
221
GtkCheckButton* _tmp21_;
223
GObject* _tmp23_ = NULL;
224
GtkSpinButton* _tmp24_;
225
GtkSpinButton* notification_limit_button;
226
GtkSpinButton* _tmp25_;
229
BlacklistPreference* _tmp28_;
230
BlacklistPreference* blacklist_preferences;
231
BlacklistPreference* _tmp29_;
234
GError * _inner_error_ = NULL;
235
g_return_if_fail (self != NULL);
236
_tmp0_ = gtk_builder_new ();
238
_tmp1_ = g_strdup (UI_DATA_DIR "/preferences-dialog.ui");
245
gtk_builder_add_from_file (_tmp2_, _tmp3_, &_inner_error_);
246
if (_inner_error_ != NULL) {
247
goto __catch9_g_error;
258
_inner_error_ = NULL;
261
_tmp6_ = _tmp5_->message;
262
g_warning ("preferences.vala:61: Failed to load preferences dialog from '%s': %s", _tmp4_, _tmp6_);
265
_g_object_unref0 (builder);
269
if (_inner_error_ != NULL) {
271
_g_object_unref0 (builder);
272
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);
273
g_clear_error (&_inner_error_);
277
_tmp8_ = gtk_builder_get_object (_tmp7_, "preferences_dialog");
278
_tmp9_ = _g_object_ref0 (GTK_IS_DIALOG (_tmp8_) ? ((GtkDialog*) _tmp8_) : NULL);
281
_tmp11_ = gtk_builder_get_object (_tmp10_, "debug_button");
282
_tmp12_ = _g_object_ref0 (GTK_IS_CHECK_BUTTON (_tmp11_) ? ((GtkCheckButton*) _tmp11_) : NULL);
283
debug_button = _tmp12_;
284
_tmp13_ = debug_button;
285
preferences_bind (self, PREFERENCES_DEBUG, (GObject*) _tmp13_, "active");
287
_tmp15_ = gtk_builder_get_object (_tmp14_, "console_log_button");
288
_tmp16_ = _g_object_ref0 (GTK_IS_CHECK_BUTTON (_tmp15_) ? ((GtkCheckButton*) _tmp15_) : NULL);
289
console_log_button = _tmp16_;
290
_tmp17_ = console_log_button;
291
preferences_bind (self, PREFERENCES_CONSOLE_LOG, (GObject*) _tmp17_, "active");
293
_tmp19_ = gtk_builder_get_object (_tmp18_, "show_count_button");
294
_tmp20_ = _g_object_ref0 (GTK_IS_CHECK_BUTTON (_tmp19_) ? ((GtkCheckButton*) _tmp19_) : NULL);
295
show_count_button = _tmp20_;
296
_tmp21_ = show_count_button;
297
preferences_bind (self, PREFERENCES_SHOW_COUNT, (GObject*) _tmp21_, "active");
299
_tmp23_ = gtk_builder_get_object (_tmp22_, "notification_limit_button");
300
_tmp24_ = _g_object_ref0 (GTK_IS_SPIN_BUTTON (_tmp23_) ? ((GtkSpinButton*) _tmp23_) : NULL);
301
notification_limit_button = _tmp24_;
302
_tmp25_ = notification_limit_button;
303
preferences_bind (self, PREFERENCES_NOTIFICATION_LIMIT, (GObject*) _tmp25_, "value");
304
_tmp26_ = self->priv->_settings;
306
_tmp28_ = blacklist_preference_new (_tmp26_, _tmp27_);
307
blacklist_preferences = _tmp28_;
308
_tmp29_ = blacklist_preferences;
309
blacklist_preference_connect_handlers (_tmp29_);
311
gtk_dialog_run (_tmp30_);
313
gtk_widget_destroy ((GtkWidget*) _tmp31_);
314
_g_object_unref0 (blacklist_preferences);
315
_g_object_unref0 (notification_limit_button);
316
_g_object_unref0 (show_count_button);
317
_g_object_unref0 (console_log_button);
318
_g_object_unref0 (debug_button);
319
_g_object_unref0 (dialog);
321
_g_object_unref0 (builder);
325
static void preferences_class_init (PreferencesClass * klass) {
326
preferences_parent_class = g_type_class_peek_parent (klass);
327
g_type_class_add_private (klass, sizeof (PreferencesPrivate));
328
G_OBJECT_CLASS (klass)->finalize = preferences_finalize;
332
static void preferences_instance_init (Preferences * self) {
333
self->priv = PREFERENCES_GET_PRIVATE (self);
337
static void preferences_finalize (GObject* obj) {
339
self = PREFERENCES (obj);
340
_g_object_unref0 (self->priv->_settings);
341
G_OBJECT_CLASS (preferences_parent_class)->finalize (obj);
346
* Wrap GLib.Settings to provide preferences for the applet.
348
GType preferences_get_type (void) {
349
static volatile gsize preferences_type_id__volatile = 0;
350
if (g_once_init_enter (&preferences_type_id__volatile)) {
351
static const GTypeInfo g_define_type_info = { sizeof (PreferencesClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) preferences_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Preferences), 0, (GInstanceInitFunc) preferences_instance_init, NULL };
352
GType preferences_type_id;
353
preferences_type_id = g_type_register_static (G_TYPE_OBJECT, "Preferences", &g_define_type_info, 0);
354
g_once_init_leave (&preferences_type_id__volatile, preferences_type_id);
356
return preferences_type_id__volatile;
360
static GType blacklist_preference_column_get_type (void) {
361
static volatile gsize blacklist_preference_column_type_id__volatile = 0;
362
if (g_once_init_enter (&blacklist_preference_column_type_id__volatile)) {
363
static const GEnumValue values[] = {{BLACKLIST_PREFERENCE_COLUMN_APP_NAME, "BLACKLIST_PREFERENCE_COLUMN_APP_NAME", "app-name"}, {BLACKLIST_PREFERENCE_COLUMN_COUNT, "BLACKLIST_PREFERENCE_COLUMN_COUNT", "count"}, {0, NULL, NULL}};
364
GType blacklist_preference_column_type_id;
365
blacklist_preference_column_type_id = g_enum_register_static ("BlacklistPreferenceColumn", values);
366
g_once_init_leave (&blacklist_preference_column_type_id__volatile, blacklist_preference_column_type_id);
368
return blacklist_preference_column_type_id__volatile;
373
* Creates a new blacklist preference object and binds the blacklist setting.
375
* @param settings the GLib.Settings object to bind
377
BlacklistPreference* blacklist_preference_construct (GType object_type, GSettings* settings, GtkBuilder* builder) {
378
BlacklistPreference * self = NULL;
379
GtkListStore* _tmp0_;
380
GtkTreeViewColumn* _tmp1_;
381
GtkTreeViewColumn* _tmp2_;
382
GtkTreeViewColumn* column;
383
const gchar* _tmp3_ = NULL;
385
GObject* _tmp5_ = NULL;
388
GtkListStore* _tmp8_;
390
GtkCellRendererText* _tmp10_;
391
GtkCellRendererText* _tmp11_;
392
GtkCellRendererText* cell;
394
GObject* _tmp13_ = NULL;
397
GObject* _tmp16_ = NULL;
400
GObject* _tmp19_ = NULL;
406
gchar** _tmp25_ = NULL;
408
gint _tmp26__length1;
409
g_return_val_if_fail (settings != NULL, NULL);
410
g_return_val_if_fail (builder != NULL, NULL);
411
self = (BlacklistPreference*) g_object_new (object_type, NULL);
412
_tmp0_ = gtk_list_store_new ((gint) BLACKLIST_PREFERENCE_COLUMN_COUNT, G_TYPE_STRING);
413
_g_object_unref0 (self->priv->_liststore);
414
self->priv->_liststore = _tmp0_;
415
_tmp1_ = gtk_tree_view_column_new ();
416
_tmp2_ = g_object_ref_sink (_tmp1_);
418
_tmp3_ = _ ("Application Name");
419
gtk_tree_view_column_set_title (column, _tmp3_);
421
_tmp5_ = gtk_builder_get_object (_tmp4_, "blacklist_treeview");
422
_tmp6_ = _g_object_ref0 (GTK_IS_TREE_VIEW (_tmp5_) ? ((GtkTreeView*) _tmp5_) : NULL);
423
_g_object_unref0 (self->priv->_treeview);
424
self->priv->_treeview = _tmp6_;
425
_tmp7_ = self->priv->_treeview;
426
_tmp8_ = self->priv->_liststore;
427
gtk_tree_view_set_model (_tmp7_, (GtkTreeModel*) _tmp8_);
428
_tmp9_ = self->priv->_treeview;
429
gtk_tree_view_append_column (_tmp9_, column);
430
_tmp10_ = (GtkCellRendererText*) gtk_cell_renderer_text_new ();
431
_tmp11_ = g_object_ref_sink (_tmp10_);
433
gtk_cell_layout_pack_start ((GtkCellLayout*) column, (GtkCellRenderer*) cell, TRUE);
434
gtk_cell_layout_add_attribute ((GtkCellLayout*) column, (GtkCellRenderer*) cell, "text", (gint) BLACKLIST_PREFERENCE_COLUMN_APP_NAME);
436
_tmp13_ = gtk_builder_get_object (_tmp12_, "blacklist_add_entry");
437
_tmp14_ = _g_object_ref0 (GTK_IS_ENTRY (_tmp13_) ? ((GtkEntry*) _tmp13_) : NULL);
438
_g_object_unref0 (self->priv->_add_entry);
439
self->priv->_add_entry = _tmp14_;
441
_tmp16_ = gtk_builder_get_object (_tmp15_, "blacklist_add_button");
442
_tmp17_ = _g_object_ref0 (GTK_IS_BUTTON (_tmp16_) ? ((GtkButton*) _tmp16_) : NULL);
443
_g_object_unref0 (self->priv->_add_button);
444
self->priv->_add_button = _tmp17_;
446
_tmp19_ = gtk_builder_get_object (_tmp18_, "blacklist_remove_button");
447
_tmp20_ = _g_object_ref0 (GTK_IS_BUTTON (_tmp19_) ? ((GtkButton*) _tmp19_) : NULL);
448
_g_object_unref0 (self->priv->_remove_button);
449
self->priv->_remove_button = _tmp20_;
451
_tmp22_ = _g_object_ref0 (_tmp21_);
452
_g_object_unref0 (self->priv->_settings);
453
self->priv->_settings = _tmp22_;
455
_tmp25_ = _tmp24_ = g_settings_get_strv (_tmp23_, PREFERENCES_BLACKLIST);
457
_tmp26__length1 = _vala_array_length (_tmp24_);
458
blacklist_preference_set_values (self, _tmp26_, _vala_array_length (_tmp24_));
459
_tmp26_ = (_vala_array_free (_tmp26_, _tmp26__length1, (GDestroyNotify) g_free), NULL);
460
_g_object_unref0 (cell);
461
_g_object_unref0 (column);
466
BlacklistPreference* blacklist_preference_new (GSettings* settings, GtkBuilder* builder) {
467
return blacklist_preference_construct (TYPE_BLACKLIST_PREFERENCE, settings, builder);
472
* Connects the signal handlers and binds the properties. Using a separate
473
* method so vala doesn't complain BlacklistPreferences is unused.
475
static gchar* string_strip (const gchar* self) {
476
gchar* result = NULL;
477
gchar* _tmp0_ = NULL;
480
g_return_val_if_fail (self != NULL, NULL);
481
_tmp0_ = g_strdup (self);
490
static void __lambda16_ (BlacklistPreference* self, GtkButton* button) {
493
const gchar* _tmp2_ = NULL;
498
gchar* _tmp6_ = NULL;
503
g_return_if_fail (button != NULL);
505
gtk_widget_set_sensitive ((GtkWidget*) _tmp0_, FALSE);
506
_tmp1_ = self->priv->_add_entry;
507
_tmp2_ = gtk_entry_get_text (_tmp1_);
508
_tmp3_ = g_strdup (_tmp2_);
510
_tmp4_ = self->priv->_add_entry;
511
gtk_entry_set_text (_tmp4_, "");
513
_tmp6_ = string_strip (_tmp5_);
517
_tmp8_ = strlen (_tmp7_);
520
const gchar* _tmp10_;
523
gchar** _tmp13_ = NULL;
525
gint _tmp14__length1;
527
blacklist_preference_append_item (self, _tmp10_);
528
_tmp11_ = self->priv->_settings;
529
_tmp13_ = blacklist_preference_get_values (self, &_tmp12_);
531
_tmp14__length1 = _tmp12_;
532
g_settings_set_strv (_tmp11_, PREFERENCES_BLACKLIST, _tmp14_);
533
_tmp14_ = (_vala_array_free (_tmp14_, _tmp14__length1, (GDestroyNotify) g_free), NULL);
536
gtk_widget_set_sensitive ((GtkWidget*) _tmp15_, TRUE);
541
static void ___lambda16__gtk_button_clicked (GtkButton* _sender, gpointer self) {
542
__lambda16_ (self, _sender);
546
static void __lambda17_ (BlacklistPreference* self, GtkButton* button) {
548
gboolean _tmp1_ = FALSE;
550
g_return_if_fail (button != NULL);
552
gtk_widget_set_sensitive ((GtkWidget*) _tmp0_, FALSE);
553
_tmp1_ = blacklist_preference_remove_item (self);
557
gchar** _tmp4_ = NULL;
560
_tmp2_ = self->priv->_settings;
561
_tmp4_ = blacklist_preference_get_values (self, &_tmp3_);
563
_tmp5__length1 = _tmp3_;
564
g_settings_set_strv (_tmp2_, PREFERENCES_BLACKLIST, _tmp5_);
565
_tmp5_ = (_vala_array_free (_tmp5_, _tmp5__length1, (GDestroyNotify) g_free), NULL);
568
gtk_widget_set_sensitive ((GtkWidget*) _tmp6_, TRUE);
572
static void ___lambda17__gtk_button_clicked (GtkButton* _sender, gpointer self) {
573
__lambda17_ (self, _sender);
577
void blacklist_preference_connect_handlers (BlacklistPreference* self) {
580
g_return_if_fail (self != NULL);
581
_tmp0_ = self->priv->_add_button;
582
g_signal_connect_object (_tmp0_, "clicked", (GCallback) ___lambda16__gtk_button_clicked, self, 0);
583
_tmp1_ = self->priv->_remove_button;
584
g_signal_connect_object (_tmp1_, "clicked", (GCallback) ___lambda17__gtk_button_clicked, self, 0);
589
* Appends an item to the blacklist.
591
* @param item the string to append
593
static void blacklist_preference_append_item (BlacklistPreference* self, const gchar* item) {
594
GError * _inner_error_ = NULL;
595
g_return_if_fail (self != NULL);
596
g_return_if_fail (item != NULL);
598
GtkListStore* _tmp0_;
599
_tmp0_ = self->priv->_liststore;
600
g_static_rec_mutex_lock (&self->priv->__lock__liststore);
602
GtkListStore* _tmp1_;
605
GtkListStore* _tmp3_;
607
_tmp1_ = self->priv->_liststore;
608
_tmp2_ = gtk_tree_model_iter_n_children ((GtkTreeModel*) _tmp1_, NULL);
610
_tmp3_ = self->priv->_liststore;
612
gtk_list_store_insert_with_values (_tmp3_, NULL, i, BLACKLIST_PREFERENCE_COLUMN_APP_NAME, _tmp4_, -1);
616
GtkListStore* _tmp5_;
617
_tmp5_ = self->priv->_liststore;
618
g_static_rec_mutex_unlock (&self->priv->__lock__liststore);
620
if (_inner_error_ != NULL) {
621
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);
622
g_clear_error (&_inner_error_);
630
* Removes the selected item from the blacklist.
632
* @return true if an item was removed
634
static gboolean blacklist_preference_remove_item (BlacklistPreference* self) {
635
gboolean result = FALSE;
636
GError * _inner_error_ = NULL;
637
g_return_val_if_fail (self != NULL, FALSE);
639
GtkListStore* _tmp0_;
640
_tmp0_ = self->priv->_liststore;
641
g_static_rec_mutex_lock (&self->priv->__lock__liststore);
644
GtkTreeSelection* _tmp2_ = NULL;
645
GtkTreeSelection* _tmp3_;
646
GtkTreeSelection* selection;
647
GtkTreeIter iter = {0};
648
GtkTreeSelection* _tmp4_;
649
GtkTreeIter _tmp5_ = {0};
650
gboolean _tmp6_ = FALSE;
651
_tmp1_ = self->priv->_treeview;
652
_tmp2_ = gtk_tree_view_get_selection (_tmp1_);
653
_tmp3_ = _g_object_ref0 (_tmp2_);
656
_tmp6_ = gtk_tree_selection_get_selected (_tmp4_, NULL, &_tmp5_);
659
GtkListStore* _tmp7_;
661
_tmp7_ = self->priv->_liststore;
663
gtk_list_store_remove (_tmp7_, &_tmp8_);
665
_g_object_unref0 (selection);
667
GtkListStore* _tmp9_;
668
_tmp9_ = self->priv->_liststore;
669
g_static_rec_mutex_unlock (&self->priv->__lock__liststore);
674
_g_object_unref0 (selection);
676
GtkListStore* _tmp10_;
677
_tmp10_ = self->priv->_liststore;
678
g_static_rec_mutex_unlock (&self->priv->__lock__liststore);
682
_g_object_unref0 (selection);
686
GtkListStore* _tmp11_;
687
_tmp11_ = self->priv->_liststore;
688
g_static_rec_mutex_unlock (&self->priv->__lock__liststore);
690
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);
691
g_clear_error (&_inner_error_);
698
* Updates a Gtk.ListStore of a single string column with the values from an
701
* @param values the values to insert
703
static void blacklist_preference_set_values (BlacklistPreference* self, gchar** values, int values_length1) {
704
GError * _inner_error_ = NULL;
705
g_return_if_fail (self != NULL);
707
GtkListStore* _tmp0_;
708
_tmp0_ = self->priv->_liststore;
709
g_static_rec_mutex_lock (&self->priv->__lock__liststore);
711
GtkListStore* _tmp1_;
712
_tmp1_ = self->priv->_liststore;
713
gtk_list_store_clear (_tmp1_);
725
GtkListStore* _tmp7_;
730
const gchar* _tmp11_;
740
_tmp6__length1 = values_length1;
741
if (!(_tmp5_ < _tmp6__length1)) {
744
_tmp7_ = self->priv->_liststore;
747
_tmp9__length1 = values_length1;
749
_tmp11_ = _tmp9_[_tmp10_];
750
gtk_list_store_insert_with_values (_tmp7_, NULL, _tmp8_, BLACKLIST_PREFERENCE_COLUMN_APP_NAME, _tmp11_, -1);
757
GtkListStore* _tmp12_;
758
_tmp12_ = self->priv->_liststore;
759
g_static_rec_mutex_unlock (&self->priv->__lock__liststore);
761
if (_inner_error_ != NULL) {
762
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);
763
g_clear_error (&_inner_error_);
771
* Converts the values of a Gtk.ListStore of a single string column to an
774
* @return a new array of strings
776
static gchar** blacklist_preference_get_values (BlacklistPreference* self, int* result_length1) {
777
gchar** result = NULL;
778
GError * _inner_error_ = NULL;
779
g_return_val_if_fail (self != NULL, NULL);
781
GtkListStore* _tmp0_;
782
_tmp0_ = self->priv->_liststore;
783
g_static_rec_mutex_lock (&self->priv->__lock__liststore);
785
GtkListStore* _tmp1_;
789
gchar** _tmp4_ = NULL;
793
GtkTreeIter iter = {0};
794
GtkListStore* _tmp5_;
795
GtkTreeIter _tmp6_ = {0};
796
gboolean _tmp7_ = FALSE;
798
gint _tmp19__length1;
799
_tmp1_ = self->priv->_liststore;
800
_tmp2_ = gtk_tree_model_iter_n_children ((GtkTreeModel*) _tmp1_, NULL);
803
_tmp4_ = g_new0 (gchar*, _tmp3_ + 1);
805
values_length1 = _tmp3_;
806
_values_size_ = values_length1;
807
_tmp5_ = self->priv->_liststore;
808
_tmp7_ = gtk_tree_model_get_iter_first ((GtkTreeModel*) _tmp5_, &_tmp6_);
818
gchar* column_value = NULL;
819
GtkListStore* _tmp12_;
822
gint _tmp14__length1;
824
const gchar* _tmp16_;
829
GtkListStore* _tmp10_;
830
gboolean _tmp11_ = FALSE;
831
_tmp10_ = self->priv->_liststore;
832
_tmp11_ = gtk_tree_model_iter_next ((GtkTreeModel*) _tmp10_, &iter);
838
_tmp12_ = self->priv->_liststore;
840
gtk_tree_model_get ((GtkTreeModel*) _tmp12_, &_tmp13_, BLACKLIST_PREFERENCE_COLUMN_APP_NAME, &column_value, -1);
842
_tmp14__length1 = values_length1;
845
_tmp16_ = column_value;
846
_tmp17_ = g_strdup (_tmp16_);
847
_g_free0 (_tmp14_[_tmp15_]);
848
_tmp14_[_tmp15_] = _tmp17_;
849
_tmp18_ = _tmp14_[_tmp15_];
850
_g_free0 (column_value);
855
_tmp19__length1 = values_length1;
856
if (result_length1) {
857
*result_length1 = _tmp19__length1;
861
GtkListStore* _tmp20_;
862
_tmp20_ = self->priv->_liststore;
863
g_static_rec_mutex_unlock (&self->priv->__lock__liststore);
869
GtkListStore* _tmp21_;
870
_tmp21_ = self->priv->_liststore;
871
g_static_rec_mutex_unlock (&self->priv->__lock__liststore);
873
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);
874
g_clear_error (&_inner_error_);
880
static void blacklist_preference_class_init (BlacklistPreferenceClass * klass) {
881
blacklist_preference_parent_class = g_type_class_peek_parent (klass);
882
g_type_class_add_private (klass, sizeof (BlacklistPreferencePrivate));
883
G_OBJECT_CLASS (klass)->finalize = blacklist_preference_finalize;
887
static void blacklist_preference_instance_init (BlacklistPreference * self) {
888
self->priv = BLACKLIST_PREFERENCE_GET_PRIVATE (self);
889
g_static_rec_mutex_init (&self->priv->__lock__liststore);
893
static void blacklist_preference_finalize (GObject* obj) {
894
BlacklistPreference * self;
895
self = BLACKLIST_PREFERENCE (obj);
896
_g_object_unref0 (self->priv->_treeview);
897
g_static_rec_mutex_free (&self->priv->__lock__liststore);
898
_g_object_unref0 (self->priv->_liststore);
899
_g_object_unref0 (self->priv->_add_button);
900
_g_object_unref0 (self->priv->_remove_button);
901
_g_object_unref0 (self->priv->_add_entry);
902
_g_object_unref0 (self->priv->_settings);
903
G_OBJECT_CLASS (blacklist_preference_parent_class)->finalize (obj);
908
* Maintain synchronization between the Gtk.ListStore and the GLib.Settings key
911
GType blacklist_preference_get_type (void) {
912
static volatile gsize blacklist_preference_type_id__volatile = 0;
913
if (g_once_init_enter (&blacklist_preference_type_id__volatile)) {
914
static const GTypeInfo g_define_type_info = { sizeof (BlacklistPreferenceClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) blacklist_preference_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BlacklistPreference), 0, (GInstanceInitFunc) blacklist_preference_instance_init, NULL };
915
GType blacklist_preference_type_id;
916
blacklist_preference_type_id = g_type_register_static (G_TYPE_OBJECT, "BlacklistPreference", &g_define_type_info, 0);
917
g_once_init_leave (&blacklist_preference_type_id__volatile, blacklist_preference_type_id);
919
return blacklist_preference_type_id__volatile;
923
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
924
if ((array != NULL) && (destroy_func != NULL)) {
926
for (i = 0; i < array_length; i = i + 1) {
927
if (((gpointer*) array)[i] != NULL) {
928
destroy_func (((gpointer*) array)[i]);
935
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
936
_vala_array_destroy (array, array_length, destroy_func);
941
static gint _vala_array_length (gpointer array) {
945
while (((gpointer*) array)[length]) {