1
/* ConfigChoice.c generated by valac, the Vala compiler
2
* generated from ConfigChoice.vala, do not modify */
4
/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 2 -*- */
6
This file is part of DĆ©jĆ Dup.
7
Ā© 2008,2009 Michael Terry <mike@mterry.name>
9
DĆ©jĆ Dup is free software: you can redistribute it and/or modify
10
it under the terms of the GNU General Public License as published by
11
the Free Software Foundation, either version 3 of the License, or
12
(at your option) any later version.
14
DĆ©jĆ Dup is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
GNU General Public License for more details.
19
You should have received a copy of the GNU General Public License
20
along with DĆ©jĆ Dup. If not, see <http://www.gnu.org/licenses/>.
24
#include <glib-object.h>
26
#include <gconf/gconf-client.h>
31
#define DEJA_DUP_TYPE_CONFIG_WIDGET (deja_dup_config_widget_get_type ())
32
#define DEJA_DUP_CONFIG_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DEJA_DUP_TYPE_CONFIG_WIDGET, DejaDupConfigWidget))
33
#define DEJA_DUP_CONFIG_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DEJA_DUP_TYPE_CONFIG_WIDGET, DejaDupConfigWidgetClass))
34
#define DEJA_DUP_IS_CONFIG_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DEJA_DUP_TYPE_CONFIG_WIDGET))
35
#define DEJA_DUP_IS_CONFIG_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DEJA_DUP_TYPE_CONFIG_WIDGET))
36
#define DEJA_DUP_CONFIG_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DEJA_DUP_TYPE_CONFIG_WIDGET, DejaDupConfigWidgetClass))
38
typedef struct _DejaDupConfigWidget DejaDupConfigWidget;
39
typedef struct _DejaDupConfigWidgetClass DejaDupConfigWidgetClass;
40
typedef struct _DejaDupConfigWidgetPrivate DejaDupConfigWidgetPrivate;
42
#define DEJA_DUP_TYPE_CONFIG_CHOICE (deja_dup_config_choice_get_type ())
43
#define DEJA_DUP_CONFIG_CHOICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DEJA_DUP_TYPE_CONFIG_CHOICE, DejaDupConfigChoice))
44
#define DEJA_DUP_CONFIG_CHOICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DEJA_DUP_TYPE_CONFIG_CHOICE, DejaDupConfigChoiceClass))
45
#define DEJA_DUP_IS_CONFIG_CHOICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DEJA_DUP_TYPE_CONFIG_CHOICE))
46
#define DEJA_DUP_IS_CONFIG_CHOICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DEJA_DUP_TYPE_CONFIG_CHOICE))
47
#define DEJA_DUP_CONFIG_CHOICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DEJA_DUP_TYPE_CONFIG_CHOICE, DejaDupConfigChoiceClass))
49
typedef struct _DejaDupConfigChoice DejaDupConfigChoice;
50
typedef struct _DejaDupConfigChoiceClass DejaDupConfigChoiceClass;
51
typedef struct _DejaDupConfigChoicePrivate DejaDupConfigChoicePrivate;
52
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
53
#define _g_free0(var) (var = (g_free (var), NULL))
54
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
56
struct _DejaDupConfigWidget {
57
GtkEventBox parent_instance;
58
DejaDupConfigWidgetPrivate * priv;
62
struct _DejaDupConfigWidgetClass {
63
GtkEventBoxClass parent_class;
64
void (*set_from_config) (DejaDupConfigWidget* self);
67
struct _DejaDupConfigChoice {
68
DejaDupConfigWidget parent_instance;
69
DejaDupConfigChoicePrivate * priv;
75
struct _DejaDupConfigChoiceClass {
76
DejaDupConfigWidgetClass parent_class;
77
void (*handle_changed) (DejaDupConfigChoice* self);
81
static gpointer deja_dup_config_choice_parent_class = NULL;
83
GType deja_dup_config_widget_get_type (void);
84
GType deja_dup_config_choice_get_type (void);
86
DEJA_DUP_CONFIG_CHOICE_DUMMY_PROPERTY
88
void deja_dup_config_choice_handle_changed (DejaDupConfigChoice* self);
89
static void _deja_dup_config_choice_handle_changed_gtk_combo_box_changed (GtkComboBox* _sender, gpointer self);
90
void deja_dup_config_widget_set_from_config (DejaDupConfigWidget* self);
91
void deja_dup_config_choice_init (DejaDupConfigChoice* self, GtkTreeModel* model, gint gconf_col);
92
static GValue* _g_value_dup (GValue* self);
93
GValue* deja_dup_config_choice_get_current_value (DejaDupConfigChoice* self);
94
const char* deja_dup_config_widget_get_key (DejaDupConfigWidget* self);
95
static void deja_dup_config_choice_real_handle_changed (DejaDupConfigChoice* self);
96
static void deja_dup_config_choice_real_set_from_config (DejaDupConfigWidget* base);
97
DejaDupConfigChoice* deja_dup_config_choice_new (void);
98
DejaDupConfigChoice* deja_dup_config_choice_construct (GType object_type);
99
static GObject * deja_dup_config_choice_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
100
static void deja_dup_config_choice_finalize (GObject* obj);
101
static int _vala_strcmp0 (const char * str1, const char * str2);
105
static void _deja_dup_config_choice_handle_changed_gtk_combo_box_changed (GtkComboBox* _sender, gpointer self) {
106
deja_dup_config_choice_handle_changed (self);
110
void deja_dup_config_choice_init (DejaDupConfigChoice* self, GtkTreeModel* model, gint gconf_col) {
111
g_return_if_fail (self != NULL);
112
g_return_if_fail (model != NULL);
113
gtk_combo_box_set_model (self->combo, model);
114
self->gconf_col = gconf_col;
115
g_signal_connect_object (self->combo, "changed", (GCallback) _deja_dup_config_choice_handle_changed_gtk_combo_box_changed, self, 0);
116
deja_dup_config_widget_set_from_config ((DejaDupConfigWidget*) self);
120
static GValue* _g_value_dup (GValue* self) {
121
return g_boxed_copy (G_TYPE_VALUE, self);
125
static gpointer __g_value_dup0 (gpointer self) {
126
return self ? _g_value_dup (self) : NULL;
130
GValue* deja_dup_config_choice_get_current_value (DejaDupConfigChoice* self) {
132
GtkTreeIter iter = {0};
133
g_return_val_if_fail (self != NULL, NULL);
134
if (gtk_combo_box_get_active_iter (self->combo, &iter)) {
141
gtk_tree_model_get_value (gtk_combo_box_get_model (self->combo), &iter, self->gconf_col, &_tmp0_);
142
val = (_tmp1_ = _tmp0_, G_IS_VALUE (&val) ? (g_value_unset (&val), NULL) : NULL, _tmp1_);
143
result = (_tmp4_ = __g_value_dup0 ((_tmp3_ = _tmp2_ = val, &_tmp3_)), G_IS_VALUE (&_tmp2_) ? (g_value_unset (&_tmp2_), NULL) : NULL, _tmp4_);
145
G_IS_VALUE (&val) ? (g_value_unset (&val), NULL) : NULL;
152
static void deja_dup_config_choice_real_handle_changed (DejaDupConfigChoice* self) {
153
GError * _inner_error_;
157
g_return_if_fail (self != NULL);
158
_inner_error_ = NULL;
159
val = deja_dup_config_choice_get_current_value (self);
164
_tmp0_ = g_value_get_string (val);
166
strval = g_strdup (_tmp0_);
168
gconf_client_set_string (((DejaDupConfigWidget*) self)->client, deja_dup_config_widget_get_key ((DejaDupConfigWidget*) self), strval, &_inner_error_);
169
if (_inner_error_ != NULL) {
170
goto __catch3_g_error;
179
_inner_error_ = NULL;
181
g_warning ("ConfigChoice.vala:67: %s\n", e->message);
186
if (_inner_error_ != NULL) {
189
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);
190
g_clear_error (&_inner_error_);
193
g_signal_emit_by_name (self, "choice-changed", strval);
199
void deja_dup_config_choice_handle_changed (DejaDupConfigChoice* self) {
200
DEJA_DUP_CONFIG_CHOICE_GET_CLASS (self)->handle_changed (self);
204
static void deja_dup_config_choice_real_set_from_config (DejaDupConfigWidget* base) {
205
DejaDupConfigChoice * self;
206
GError * _inner_error_;
208
gboolean _tmp2_ = FALSE;
209
gboolean valid = FALSE;
210
GtkTreeIter iter = {0};
211
self = (DejaDupConfigChoice*) base;
212
_inner_error_ = NULL;
217
_tmp0_ = gconf_client_get_string (((DejaDupConfigWidget*) self)->client, deja_dup_config_widget_get_key ((DejaDupConfigWidget*) self), &_inner_error_);
218
if (_inner_error_ != NULL) {
219
goto __catch4_g_error;
222
confval = (_tmp1_ = g_strdup (_tmp0_), _g_free0 (confval), _tmp1_);
229
_inner_error_ = NULL;
231
g_warning ("ConfigChoice.vala:80: %s\n", e->message);
236
if (_inner_error_ != NULL) {
238
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);
239
g_clear_error (&_inner_error_);
242
if (confval == NULL) {
245
_tmp2_ = _vala_strcmp0 (confval, "") == 0;
249
confval = (_tmp3_ = g_strdup (self->default_val), _g_free0 (confval), _tmp3_);
251
if (confval == NULL) {
255
valid = gtk_tree_model_get_iter_first (gtk_combo_box_get_model (self->combo), &iter);
264
gtk_tree_model_get_value (gtk_combo_box_get_model (self->combo), &iter, self->gconf_col, &_tmp4_);
265
val = (_tmp5_ = _tmp4_, G_IS_VALUE (&val) ? (g_value_unset (&val), NULL) : NULL, _tmp5_);
266
strval = g_strdup (g_value_get_string (&val));
267
if (_vala_strcmp0 (strval, confval) == 0) {
268
gtk_combo_box_set_active_iter (self->combo, &iter);
269
G_IS_VALUE (&val) ? (g_value_unset (&val), NULL) : NULL;
273
valid = gtk_tree_model_iter_next (gtk_combo_box_get_model (self->combo), &iter);
274
G_IS_VALUE (&val) ? (g_value_unset (&val), NULL) : NULL;
281
DejaDupConfigChoice* deja_dup_config_choice_construct (GType object_type) {
282
DejaDupConfigChoice * self;
283
self = g_object_newv (object_type, 0, NULL);
288
DejaDupConfigChoice* deja_dup_config_choice_new (void) {
289
return deja_dup_config_choice_construct (DEJA_DUP_TYPE_CONFIG_CHOICE);
293
static GObject * deja_dup_config_choice_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
295
GObjectClass * parent_class;
296
DejaDupConfigChoice * self;
297
parent_class = G_OBJECT_CLASS (deja_dup_config_choice_parent_class);
298
obj = parent_class->constructor (type, n_construct_properties, construct_properties);
299
self = DEJA_DUP_CONFIG_CHOICE (obj);
302
self->combo = (_tmp0_ = g_object_ref_sink ((GtkComboBox*) gtk_combo_box_new_text ()), _g_object_unref0 (self->combo), _tmp0_);
303
gtk_container_add ((GtkContainer*) self, (GtkWidget*) self->combo);
309
static void deja_dup_config_choice_class_init (DejaDupConfigChoiceClass * klass) {
310
deja_dup_config_choice_parent_class = g_type_class_peek_parent (klass);
311
DEJA_DUP_CONFIG_CHOICE_CLASS (klass)->handle_changed = deja_dup_config_choice_real_handle_changed;
312
DEJA_DUP_CONFIG_WIDGET_CLASS (klass)->set_from_config = deja_dup_config_choice_real_set_from_config;
313
G_OBJECT_CLASS (klass)->constructor = deja_dup_config_choice_constructor;
314
G_OBJECT_CLASS (klass)->finalize = deja_dup_config_choice_finalize;
315
g_signal_new ("choice_changed", DEJA_DUP_TYPE_CONFIG_CHOICE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
319
static void deja_dup_config_choice_instance_init (DejaDupConfigChoice * self) {
320
self->default_val = NULL;
324
static void deja_dup_config_choice_finalize (GObject* obj) {
325
DejaDupConfigChoice * self;
326
self = DEJA_DUP_CONFIG_CHOICE (obj);
327
_g_object_unref0 (self->combo);
328
_g_free0 (self->default_val);
329
G_OBJECT_CLASS (deja_dup_config_choice_parent_class)->finalize (obj);
333
GType deja_dup_config_choice_get_type (void) {
334
static GType deja_dup_config_choice_type_id = 0;
335
if (deja_dup_config_choice_type_id == 0) {
336
static const GTypeInfo g_define_type_info = { sizeof (DejaDupConfigChoiceClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) deja_dup_config_choice_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DejaDupConfigChoice), 0, (GInstanceInitFunc) deja_dup_config_choice_instance_init, NULL };
337
deja_dup_config_choice_type_id = g_type_register_static (DEJA_DUP_TYPE_CONFIG_WIDGET, "DejaDupConfigChoice", &g_define_type_info, 0);
339
return deja_dup_config_choice_type_id;
343
static int _vala_strcmp0 (const char * str1, const char * str2) {
345
return -(str1 != str2);
350
return strcmp (str1, str2);