summaryrefslogtreecommitdiff
path: root/src/dialogs/MultiTextEntryDialog.c
blob: e33e4156562beb9990609e020c1c6f7ae9d51194 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
/* MultiTextEntryDialog.c generated by valac 0.40.4, the Vala compiler
 * generated from MultiTextEntryDialog.vala, do not modify */

/* Copyright 2016 Software Freedom Conservancy Inc.
 * Copyright 2017 Jens Georg <mail@jensge.org>
 *
 * This software is licensed under the GNU LGPL (version 2.1 or later).
 * See the COPYING file in this distribution.
 */


#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>


#define TYPE_MULTI_TEXT_ENTRY_DIALOG (multi_text_entry_dialog_get_type ())
#define MULTI_TEXT_ENTRY_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MULTI_TEXT_ENTRY_DIALOG, MultiTextEntryDialog))
#define MULTI_TEXT_ENTRY_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MULTI_TEXT_ENTRY_DIALOG, MultiTextEntryDialogClass))
#define IS_MULTI_TEXT_ENTRY_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MULTI_TEXT_ENTRY_DIALOG))
#define IS_MULTI_TEXT_ENTRY_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MULTI_TEXT_ENTRY_DIALOG))
#define MULTI_TEXT_ENTRY_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MULTI_TEXT_ENTRY_DIALOG, MultiTextEntryDialogClass))

typedef struct _MultiTextEntryDialog MultiTextEntryDialog;
typedef struct _MultiTextEntryDialogClass MultiTextEntryDialogClass;
typedef struct _MultiTextEntryDialogPrivate MultiTextEntryDialogPrivate;
enum  {
	MULTI_TEXT_ENTRY_DIALOG_0_PROPERTY,
	MULTI_TEXT_ENTRY_DIALOG_NUM_PROPERTIES
};
static GParamSpec* multi_text_entry_dialog_properties[MULTI_TEXT_ENTRY_DIALOG_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define TYPE_PAGE_WINDOW (page_window_get_type ())
#define PAGE_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PAGE_WINDOW, PageWindow))
#define PAGE_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PAGE_WINDOW, PageWindowClass))
#define IS_PAGE_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PAGE_WINDOW))
#define IS_PAGE_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PAGE_WINDOW))
#define PAGE_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PAGE_WINDOW, PageWindowClass))

typedef struct _PageWindow PageWindow;
typedef struct _PageWindowClass PageWindowClass;

#define TYPE_APP_WINDOW (app_window_get_type ())
#define APP_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_APP_WINDOW, AppWindow))
#define APP_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_APP_WINDOW, AppWindowClass))
#define IS_APP_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_APP_WINDOW))
#define IS_APP_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_APP_WINDOW))
#define APP_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_APP_WINDOW, AppWindowClass))

typedef struct _AppWindow AppWindow;
typedef struct _AppWindowClass AppWindowClass;
#define _g_free0(var) (var = (g_free (var), NULL))

struct _MultiTextEntryDialog {
	GtkDialog parent_instance;
	MultiTextEntryDialogPrivate * priv;
};

struct _MultiTextEntryDialogClass {
	GtkDialogClass parent_class;
};

typedef gboolean (*MultiTextEntryDialogOnModifyValidateType) (const gchar* text, void* user_data);
struct _MultiTextEntryDialogPrivate {
	MultiTextEntryDialogOnModifyValidateType on_modify_validate;
	gpointer on_modify_validate_target;
	GtkTextView* entry;
};


static gpointer multi_text_entry_dialog_parent_class = NULL;

GType multi_text_entry_dialog_get_type (void) G_GNUC_CONST;
#define MULTI_TEXT_ENTRY_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_MULTI_TEXT_ENTRY_DIALOG, MultiTextEntryDialogPrivate))
MultiTextEntryDialog* multi_text_entry_dialog_new (void);
MultiTextEntryDialog* multi_text_entry_dialog_construct (GType object_type);
gint resources_use_header_bar (void);
void multi_text_entry_dialog_setup (MultiTextEntryDialog* self,
                                    MultiTextEntryDialogOnModifyValidateType modify_validate,
                                    void* modify_validate_target,
                                    const gchar* title,
                                    const gchar* label,
                                    const gchar* initial_text);
GType page_window_get_type (void) G_GNUC_CONST;
GType app_window_get_type (void) G_GNUC_CONST;
AppWindow* app_window_get_instance (void);
gchar* multi_text_entry_dialog_execute (MultiTextEntryDialog* self);
static void multi_text_entry_dialog_finalize (GObject * obj);


MultiTextEntryDialog*
multi_text_entry_dialog_construct (GType object_type)
{
	MultiTextEntryDialog * self = NULL;
#line 17 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	self = (MultiTextEntryDialog*) g_object_new (object_type, "use-header-bar", resources_use_header_bar (), NULL);
#line 16 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	return self;
#line 103 "MultiTextEntryDialog.c"
}


MultiTextEntryDialog*
multi_text_entry_dialog_new (void)
{
#line 16 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	return multi_text_entry_dialog_construct (TYPE_MULTI_TEXT_ENTRY_DIALOG);
#line 112 "MultiTextEntryDialog.c"
}


void
multi_text_entry_dialog_setup (MultiTextEntryDialog* self,
                               MultiTextEntryDialogOnModifyValidateType modify_validate,
                               void* modify_validate_target,
                               const gchar* title,
                               const gchar* label,
                               const gchar* initial_text)
{
	AppWindow* _tmp0_;
	AppWindow* _tmp1_;
	GdkWindow* _tmp2_;
	AppWindow* _tmp3_;
	AppWindow* _tmp4_;
	const gchar* _tmp5_ = NULL;
	GtkTextView* _tmp6_;
	GtkTextBuffer* _tmp7_;
	GtkTextBuffer* _tmp8_;
	GtkTextView* _tmp9_;
#line 20 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	g_return_if_fail (IS_MULTI_TEXT_ENTRY_DIALOG (self));
#line 20 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	g_return_if_fail (title != NULL);
#line 20 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	g_return_if_fail (label != NULL);
#line 21 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	gtk_window_set_title (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_window_get_type (), GtkWindow), title);
#line 22 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	_tmp0_ = app_window_get_instance ();
#line 22 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	_tmp1_ = _tmp0_;
#line 22 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	_tmp2_ = gtk_widget_get_parent_window (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_widget_get_type (), GtkWidget));
#line 22 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	gtk_widget_set_parent_window (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), _tmp2_);
#line 22 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	_g_object_unref0 (_tmp1_);
#line 23 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	_tmp3_ = app_window_get_instance ();
#line 23 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	_tmp4_ = _tmp3_;
#line 23 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	gtk_window_set_transient_for (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_window_get_type (), GtkWindow), G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, gtk_window_get_type (), GtkWindow));
#line 23 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	_g_object_unref0 (_tmp4_);
#line 24 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	self->priv->on_modify_validate = modify_validate;
#line 24 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	self->priv->on_modify_validate_target = modify_validate_target;
#line 26 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	if (initial_text != NULL) {
#line 26 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
		_tmp5_ = initial_text;
#line 168 "MultiTextEntryDialog.c"
	} else {
#line 26 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
		_tmp5_ = "";
#line 172 "MultiTextEntryDialog.c"
	}
#line 26 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	_tmp6_ = self->priv->entry;
#line 26 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	_tmp7_ = gtk_text_view_get_buffer (_tmp6_);
#line 26 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	_tmp8_ = _tmp7_;
#line 26 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	g_object_set (_tmp8_, "text", _tmp5_, NULL);
#line 28 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	_tmp9_ = self->priv->entry;
#line 28 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	gtk_widget_grab_focus (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, gtk_widget_get_type (), GtkWidget));
#line 186 "MultiTextEntryDialog.c"
}


gchar*
multi_text_entry_dialog_execute (MultiTextEntryDialog* self)
{
	gchar* result = NULL;
	gchar* text = NULL;
#line 31 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	g_return_val_if_fail (IS_MULTI_TEXT_ENTRY_DIALOG (self), NULL);
#line 32 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	text = NULL;
#line 34 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	gtk_widget_show_all (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
#line 36 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	if (gtk_dialog_run (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_dialog_get_type (), GtkDialog)) == ((gint) GTK_RESPONSE_OK)) {
#line 203 "MultiTextEntryDialog.c"
		GtkTextView* _tmp0_;
		GtkTextBuffer* _tmp1_;
		GtkTextBuffer* _tmp2_;
		gchar* _tmp3_;
		gchar* _tmp4_;
#line 37 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
		_tmp0_ = self->priv->entry;
#line 37 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
		_tmp1_ = gtk_text_view_get_buffer (_tmp0_);
#line 37 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
		_tmp2_ = _tmp1_;
#line 37 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
		g_object_get (_tmp2_, "text", &_tmp3_, NULL);
#line 37 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
		_tmp4_ = _tmp3_;
#line 37 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
		_g_free0 (text);
#line 37 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
		text = _tmp4_;
#line 223 "MultiTextEntryDialog.c"
	}
#line 39 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	gtk_widget_destroy (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
#line 41 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	result = text;
#line 41 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	return result;
#line 231 "MultiTextEntryDialog.c"
}


static void
multi_text_entry_dialog_class_init (MultiTextEntryDialogClass * klass)
{
	gint MultiTextEntryDialog_private_offset;
#line 9 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	multi_text_entry_dialog_parent_class = g_type_class_peek_parent (klass);
#line 9 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	g_type_class_add_private (klass, sizeof (MultiTextEntryDialogPrivate));
#line 9 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	G_OBJECT_CLASS (klass)->finalize = multi_text_entry_dialog_finalize;
#line 9 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	MultiTextEntryDialog_private_offset = g_type_class_get_instance_private_offset (klass);
#line 9 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Shotwell/ui/multitextentrydialog.ui");
#line 9 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "entry", FALSE, MultiTextEntryDialog_private_offset + G_STRUCT_OFFSET (MultiTextEntryDialogPrivate, entry));
#line 251 "MultiTextEntryDialog.c"
}


static void
multi_text_entry_dialog_instance_init (MultiTextEntryDialog * self)
{
#line 9 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	self->priv = MULTI_TEXT_ENTRY_DIALOG_GET_PRIVATE (self);
#line 9 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	gtk_widget_init_template (GTK_WIDGET (self));
#line 262 "MultiTextEntryDialog.c"
}


static void
multi_text_entry_dialog_finalize (GObject * obj)
{
	MultiTextEntryDialog * self;
#line 9 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_MULTI_TEXT_ENTRY_DIALOG, MultiTextEntryDialog);
#line 14 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	_g_object_unref0 (self->priv->entry);
#line 9 "/home/jens/Source/shotwell/src/dialogs/MultiTextEntryDialog.vala"
	G_OBJECT_CLASS (multi_text_entry_dialog_parent_class)->finalize (obj);
#line 276 "MultiTextEntryDialog.c"
}


GType
multi_text_entry_dialog_get_type (void)
{
	static volatile gsize multi_text_entry_dialog_type_id__volatile = 0;
	if (g_once_init_enter (&multi_text_entry_dialog_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (MultiTextEntryDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) multi_text_entry_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MultiTextEntryDialog), 0, (GInstanceInitFunc) multi_text_entry_dialog_instance_init, NULL };
		GType multi_text_entry_dialog_type_id;
		multi_text_entry_dialog_type_id = g_type_register_static (gtk_dialog_get_type (), "MultiTextEntryDialog", &g_define_type_info, 0);
		g_once_init_leave (&multi_text_entry_dialog_type_id__volatile, multi_text_entry_dialog_type_id);
	}
	return multi_text_entry_dialog_type_id__volatile;
}