1 /* document_view.c generated by valac 0.48.9, the Vala compiler
2 * generated from document_view.vala, do not modify */
3
4 /*
5 * This file is part of GNOME LaTeX.
6 *
7 * Copyright © 2010-2020 Sébastien Wilmet
8 *
9 * GNOME LaTeX 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.
13 *
14 * GNOME LaTeX 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.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with GNOME LaTeX. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23 #include <tepl/tepl.h>
24 #include <glib-object.h>
25 #include <gio/gio.h>
26 #include <pango/pango.h>
27 #include <stdlib.h>
28 #include <string.h>
29 #include <glib.h>
30 #include <gtk/gtk.h>
31 #include <latexila.h>
32 #include <gtksourceview/gtksource.h>
33 #include <gdk/gdk.h>
34 #include <gspell/gspell.h>
35 #include <glib/gi18n-lib.h>
36
37 #define TYPE_DOCUMENT_VIEW (document_view_get_type ())
38 #define DOCUMENT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DOCUMENT_VIEW, DocumentView))
39 #define DOCUMENT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DOCUMENT_VIEW, DocumentViewClass))
40 #define IS_DOCUMENT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DOCUMENT_VIEW))
41 #define IS_DOCUMENT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DOCUMENT_VIEW))
42 #define DOCUMENT_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DOCUMENT_VIEW, DocumentViewClass))
43
44 typedef struct _DocumentView DocumentView;
45 typedef struct _DocumentViewClass DocumentViewClass;
46 typedef struct _DocumentViewPrivate DocumentViewPrivate;
47 enum {
48 DOCUMENT_VIEW_0_PROPERTY,
49 DOCUMENT_VIEW_NUM_PROPERTIES
50 };
51 static GParamSpec* document_view_properties[DOCUMENT_VIEW_NUM_PROPERTIES];
52 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
53 #define __vala_PangoFontDescription_free0(var) ((var == NULL) ? NULL : (var = (_vala_PangoFontDescription_free (var), NULL)))
54
55 #define TYPE_DOCUMENT (document_get_type ())
56 #define DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DOCUMENT, Document))
57 #define DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DOCUMENT, DocumentClass))
58 #define IS_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DOCUMENT))
59 #define IS_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DOCUMENT))
60 #define DOCUMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DOCUMENT, DocumentClass))
61
62 typedef struct _Document Document;
63 typedef struct _DocumentClass DocumentClass;
64
65 #define TYPE_COMPLETION_PROVIDER (completion_provider_get_type ())
66 #define COMPLETION_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_COMPLETION_PROVIDER, CompletionProvider))
67 #define COMPLETION_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_COMPLETION_PROVIDER, CompletionProviderClass))
68 #define IS_COMPLETION_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_COMPLETION_PROVIDER))
69 #define IS_COMPLETION_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_COMPLETION_PROVIDER))
70 #define COMPLETION_PROVIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_COMPLETION_PROVIDER, CompletionProviderClass))
71
72 typedef struct _CompletionProvider CompletionProvider;
73 typedef struct _CompletionProviderClass CompletionProviderClass;
74 #define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
75
76 #define TYPE_APP_SETTINGS (app_settings_get_type ())
77 #define APP_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_APP_SETTINGS, AppSettings))
78 #define APP_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_APP_SETTINGS, AppSettingsClass))
79 #define IS_APP_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_APP_SETTINGS))
80 #define IS_APP_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_APP_SETTINGS))
81 #define APP_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_APP_SETTINGS, AppSettingsClass))
82
83 typedef struct _AppSettings AppSettings;
84 typedef struct _AppSettingsClass AppSettingsClass;
85 #define _g_free0(var) (var = (g_free (var), NULL))
86 typedef struct _Block18Data Block18Data;
87
88 struct _DocumentView {
89 TeplView parent_instance;
90 DocumentViewPrivate * priv;
91 };
92
93 struct _DocumentViewClass {
94 TeplViewClass parent_class;
95 };
96
97 struct _DocumentViewPrivate {
98 GSettings* _editor_settings;
99 PangoFontDescription* _font_desc;
100 };
101
102 struct _Block18Data {
103 int _ref_count_;
104 DocumentView* self;
105 GspellChecker* spell_checker;
106 };
107
108 static gint DocumentView_private_offset;
109 static gpointer document_view_parent_class = NULL;
110 static gboolean document_view__no_spell_language_dialog_shown;
111 static gboolean document_view__no_spell_language_dialog_shown = FALSE;
112
113 GType document_view_get_type (void) G_GNUC_CONST;
114 G_DEFINE_AUTOPTR_CLEANUP_FUNC (DocumentView, g_object_unref)
115 #define DOCUMENT_VIEW_METADATA_KEY_SPELL_LANGUAGE "gnome-latex-spell-language"
116 #define DOCUMENT_VIEW_METADATA_KEY_INLINE_SPELL "gnome-latex-inline-spell"
117 #define DOCUMENT_VIEW_INLINE_SPELL_ENABLED_STR "1"
118 #define DOCUMENT_VIEW_INLINE_SPELL_DISABLED_STR "0"
119 static void _vala_PangoFontDescription_free (PangoFontDescription* self);
120 GType document_get_type (void) G_GNUC_CONST;
121 G_DEFINE_AUTOPTR_CLEANUP_FUNC (Document, g_object_unref)
122 DocumentView* document_view_new (Document* doc);
123 DocumentView* document_view_construct (GType object_type,
124 Document* doc);
125 static void __lambda46_ (DocumentView* self,
126 GObject* d,
127 GParamSpec* p);
128 gboolean document_get_readonly (Document* self);
129 static void ___lambda46__g_object_notify (GObject* _sender,
130 GParamSpec* pspec,
131 gpointer self);
132 void document_view_set_font_from_settings (DocumentView* self);
133 GType completion_provider_get_type (void) G_GNUC_CONST;
134 G_DEFINE_AUTOPTR_CLEANUP_FUNC (CompletionProvider, g_object_unref)
135 CompletionProvider* completion_provider_get_default (void);
136 static void document_view_hide_completion_calltip_when_needed (DocumentView* self);
137 static void document_view_init_spell_checking (DocumentView* self);
138 static gboolean document_view_on_button_release_event (DocumentView* self,
139 GdkEventButton* event);
140 static gboolean _document_view_on_button_release_event_gtk_widget_button_release_event (GtkWidget* _sender,
141 GdkEventButton* event,
142 gpointer self);
143 GType app_settings_get_type (void) G_GNUC_CONST;
144 G_DEFINE_AUTOPTR_CLEANUP_FUNC (AppSettings, g_object_unref)
145 AppSettings* app_settings_get_default (void);
146 const gchar* app_settings_get_system_font (AppSettings* self);
147 void document_view_set_font_from_string (DocumentView* self,
148 const gchar* font);
149 void document_view_enlarge_font (DocumentView* self);
150 void document_view_shrink_font (DocumentView* self);
151 GFile* document_get_location (Document* self);
152 GFile* document_get_main_file (Document* self);
153 static void __lambda47_ (DocumentView* self);
154 void completion_provider_hide_calltip_window (CompletionProvider* self);
155 static void ___lambda47__g_object_notify (GObject* _sender,
156 GParamSpec* pspec,
157 gpointer self);
158 static Block18Data* block18_data_ref (Block18Data* _data18_);
159 static void block18_data_unref (void * _userdata_);
160 static GspellLanguage* document_view_get_spell_language (DocumentView* self);
161 void document_view_setup_inline_spell_checker (DocumentView* self);
162 static void document_view_inline_checker_enabled_notify_cb (DocumentView* self);
163 static void _document_view_inline_checker_enabled_notify_cb_g_object_notify (GObject* _sender,
164 GParamSpec* pspec,
165 gpointer self);
166 static void __lambda48_ (Block18Data* _data18_);
167 static void ___lambda48__g_object_notify (GObject* _sender,
168 GParamSpec* pspec,
169 gpointer self);
170 static void __lambda49_ (Block18Data* _data18_);
171 static void ___lambda49__g_settings_changed (GSettings* _sender,
172 const gchar* key,
173 gpointer self);
174 static void __lambda50_ (DocumentView* self);
175 static void ___lambda50__g_settings_changed (GSettings* _sender,
176 const gchar* key,
177 gpointer self);
178 static GspellChecker* document_view_get_spell_checker (DocumentView* self);
179 void document_view_launch_spell_checker_dialog (DocumentView* self);
180 void document_view_launch_spell_language_chooser_dialog (DocumentView* self);
181 void document_view_save_spell_language_metadata (DocumentView* self);
182 void document_set_metadata (Document* self,
183 const gchar* key,
184 const gchar* val);
185 void document_view_save_inline_spell_metadata (DocumentView* self);
186 static void document_view_finalize (GObject * obj);
187 static GType document_view_get_type_once (void);
188
189 static inline gpointer
document_view_get_instance_private(DocumentView * self)190 document_view_get_instance_private (DocumentView* self)
191 {
192 return G_STRUCT_MEMBER_P (self, DocumentView_private_offset);
193 }
194
195 static void
_vala_PangoFontDescription_free(PangoFontDescription * self)196 _vala_PangoFontDescription_free (PangoFontDescription* self)
197 {
198 #line 30 "document_view.vala"
199 g_boxed_free (pango_font_description_get_type (), self);
200 #line 201 "document_view.c"
201 }
202
203 static void
__lambda46_(DocumentView * self,GObject * d,GParamSpec * p)204 __lambda46_ (DocumentView* self,
205 GObject* d,
206 GParamSpec* p)
207 {
208 gboolean _tmp0_;
209 gboolean _tmp1_;
210 #line 38 "document_view.vala"
211 g_return_if_fail (d != NULL);
212 #line 38 "document_view.vala"
213 g_return_if_fail (p != NULL);
214 #line 40 "document_view.vala"
215 _tmp0_ = document_get_readonly (G_TYPE_CHECK_INSTANCE_CAST (d, TYPE_DOCUMENT, Document));
216 #line 40 "document_view.vala"
217 _tmp1_ = _tmp0_;
218 #line 40 "document_view.vala"
219 gtk_text_view_set_editable ((GtkTextView*) self, !_tmp1_);
220 #line 221 "document_view.c"
221 }
222
223 static void
___lambda46__g_object_notify(GObject * _sender,GParamSpec * pspec,gpointer self)224 ___lambda46__g_object_notify (GObject* _sender,
225 GParamSpec* pspec,
226 gpointer self)
227 {
228 #line 38 "document_view.vala"
229 __lambda46_ ((DocumentView*) self, _sender, pspec);
230 #line 231 "document_view.c"
231 }
232
233 static gboolean
_document_view_on_button_release_event_gtk_widget_button_release_event(GtkWidget * _sender,GdkEventButton * event,gpointer self)234 _document_view_on_button_release_event_gtk_widget_button_release_event (GtkWidget* _sender,
235 GdkEventButton* event,
236 gpointer self)
237 {
238 gboolean result;
239 result = document_view_on_button_release_event ((DocumentView*) self, event);
240 #line 71 "document_view.vala"
241 return result;
242 #line 243 "document_view.c"
243 }
244
245 DocumentView*
document_view_construct(GType object_type,Document * doc)246 document_view_construct (GType object_type,
247 Document* doc)
248 {
249 DocumentView * self = NULL;
250 GSettings* _tmp0_;
251 GError* _inner_error0_ = NULL;
252 #line 34 "document_view.vala"
253 g_return_val_if_fail (doc != NULL, NULL);
254 #line 34 "document_view.vala"
255 self = (DocumentView*) g_object_new (object_type, NULL);
256 #line 36 "document_view.vala"
257 gtk_text_view_set_buffer ((GtkTextView*) self, (GtkTextBuffer*) doc);
258 #line 38 "document_view.vala"
259 g_signal_connect_object ((GObject*) doc, "notify::readonly", (GCallback) ___lambda46__g_object_notify, self, 0);
260 #line 43 "document_view.vala"
261 latexila_view_setup ((GtkSourceView*) self);
262 #line 46 "document_view.vala"
263 _tmp0_ = g_settings_new ("org.gnome.gnome-latex.preferences.editor");
264 #line 46 "document_view.vala"
265 _g_object_unref0 (self->priv->_editor_settings);
266 #line 46 "document_view.vala"
267 self->priv->_editor_settings = _tmp0_;
268 #line 48 "document_view.vala"
269 document_view_set_font_from_settings (self);
270 #line 271 "document_view.c"
271 {
272 CompletionProvider* provider = NULL;
273 CompletionProvider* _tmp1_;
274 GtkSourceCompletion* _tmp2_;
275 GtkSourceCompletion* _tmp3_;
276 GtkSourceCompletion* _tmp4_;
277 GtkSourceCompletion* _tmp5_;
278 GtkSourceCompletion* _tmp6_;
279 GtkSourceCompletion* _tmp7_;
280 GtkSourceCompletion* _tmp8_;
281 GtkSourceCompletion* _tmp9_;
282 GtkSourceCompletion* _tmp10_;
283 GtkSourceCompletion* _tmp11_;
284 #line 53 "document_view.vala"
285 _tmp1_ = completion_provider_get_default ();
286 #line 53 "document_view.vala"
287 provider = _tmp1_;
288 #line 54 "document_view.vala"
289 _tmp2_ = gtk_source_view_get_completion ((GtkSourceView*) self);
290 #line 54 "document_view.vala"
291 _tmp3_ = _tmp2_;
292 #line 54 "document_view.vala"
293 gtk_source_completion_add_provider (_tmp3_, (GtkSourceCompletionProvider*) provider, &_inner_error0_);
294 #line 54 "document_view.vala"
295 if (G_UNLIKELY (_inner_error0_ != NULL)) {
296 #line 54 "document_view.vala"
297 _g_object_unref0 (provider);
298 #line 299 "document_view.c"
299 goto __catch0_g_error;
300 }
301 #line 55 "document_view.vala"
302 _tmp4_ = gtk_source_view_get_completion ((GtkSourceView*) self);
303 #line 55 "document_view.vala"
304 _tmp5_ = _tmp4_;
305 #line 55 "document_view.vala"
306 g_object_set (_tmp5_, "remember-info-visibility", TRUE, NULL);
307 #line 56 "document_view.vala"
308 _tmp6_ = gtk_source_view_get_completion ((GtkSourceView*) self);
309 #line 56 "document_view.vala"
310 _tmp7_ = _tmp6_;
311 #line 56 "document_view.vala"
312 g_object_set (_tmp7_, "show-headers", FALSE, NULL);
313 #line 57 "document_view.vala"
314 _tmp8_ = gtk_source_view_get_completion ((GtkSourceView*) self);
315 #line 57 "document_view.vala"
316 _tmp9_ = _tmp8_;
317 #line 57 "document_view.vala"
318 g_object_set (_tmp9_, "auto-complete-delay", (guint) 0, NULL);
319 #line 58 "document_view.vala"
320 _tmp10_ = gtk_source_view_get_completion ((GtkSourceView*) self);
321 #line 58 "document_view.vala"
322 _tmp11_ = _tmp10_;
323 #line 58 "document_view.vala"
324 g_object_set (_tmp11_, "accelerators", (guint) 0, NULL);
325 #line 60 "document_view.vala"
326 document_view_hide_completion_calltip_when_needed (self);
327 #line 51 "document_view.vala"
328 _g_object_unref0 (provider);
329 #line 330 "document_view.c"
330 }
331 goto __finally0;
332 __catch0_g_error:
333 {
334 GError* e = NULL;
335 GError* _tmp12_;
336 const gchar* _tmp13_;
337 #line 51 "document_view.vala"
338 e = _inner_error0_;
339 #line 51 "document_view.vala"
340 _inner_error0_ = NULL;
341 #line 64 "document_view.vala"
342 _tmp12_ = e;
343 #line 64 "document_view.vala"
344 _tmp13_ = _tmp12_->message;
345 #line 64 "document_view.vala"
346 g_warning ("document_view.vala:64: Completion: %s", _tmp13_);
347 #line 51 "document_view.vala"
348 _g_error_free0 (e);
349 #line 350 "document_view.c"
350 }
351 __finally0:
352 #line 51 "document_view.vala"
353 if (G_UNLIKELY (_inner_error0_ != NULL)) {
354 #line 51 "document_view.vala"
355 g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
356 #line 51 "document_view.vala"
357 g_clear_error (&_inner_error0_);
358 #line 51 "document_view.vala"
359 return NULL;
360 #line 361 "document_view.c"
361 }
362 #line 68 "document_view.vala"
363 document_view_init_spell_checking (self);
364 #line 71 "document_view.vala"
365 g_signal_connect_object ((GtkWidget*) self, "button-release-event", (GCallback) _document_view_on_button_release_event_gtk_widget_button_release_event, self, 0);
366 #line 34 "document_view.vala"
367 return self;
368 #line 369 "document_view.c"
369 }
370
371 DocumentView*
document_view_new(Document * doc)372 document_view_new (Document* doc)
373 {
374 #line 34 "document_view.vala"
375 return document_view_construct (TYPE_DOCUMENT_VIEW, doc);
376 #line 377 "document_view.c"
377 }
378
379 void
document_view_set_font_from_settings(DocumentView * self)380 document_view_set_font_from_settings (DocumentView* self)
381 {
382 gchar* font = NULL;
383 GSettings* _tmp0_;
384 const gchar* _tmp8_;
385 #line 74 "document_view.vala"
386 g_return_if_fail (self != NULL);
387 #line 77 "document_view.vala"
388 _tmp0_ = self->priv->_editor_settings;
389 #line 77 "document_view.vala"
390 if (g_settings_get_boolean (_tmp0_, "use-default-font")) {
391 #line 392 "document_view.c"
392 AppSettings* _tmp1_;
393 AppSettings* _tmp2_;
394 const gchar* _tmp3_;
395 const gchar* _tmp4_;
396 gchar* _tmp5_;
397 #line 78 "document_view.vala"
398 _tmp1_ = app_settings_get_default ();
399 #line 78 "document_view.vala"
400 _tmp2_ = _tmp1_;
401 #line 78 "document_view.vala"
402 _tmp3_ = app_settings_get_system_font (_tmp2_);
403 #line 78 "document_view.vala"
404 _tmp4_ = _tmp3_;
405 #line 78 "document_view.vala"
406 _tmp5_ = g_strdup (_tmp4_);
407 #line 78 "document_view.vala"
408 _g_free0 (font);
409 #line 78 "document_view.vala"
410 font = _tmp5_;
411 #line 78 "document_view.vala"
412 _g_object_unref0 (_tmp2_);
413 #line 414 "document_view.c"
414 } else {
415 GSettings* _tmp6_;
416 gchar* _tmp7_;
417 #line 80 "document_view.vala"
418 _tmp6_ = self->priv->_editor_settings;
419 #line 80 "document_view.vala"
420 _tmp7_ = g_settings_get_string (_tmp6_, "editor-font");
421 #line 80 "document_view.vala"
422 _g_free0 (font);
423 #line 80 "document_view.vala"
424 font = _tmp7_;
425 #line 426 "document_view.c"
426 }
427 #line 82 "document_view.vala"
428 _tmp8_ = font;
429 #line 82 "document_view.vala"
430 document_view_set_font_from_string (self, _tmp8_);
431 #line 74 "document_view.vala"
432 _g_free0 (font);
433 #line 434 "document_view.c"
434 }
435
436 void
document_view_set_font_from_string(DocumentView * self,const gchar * font)437 document_view_set_font_from_string (DocumentView* self,
438 const gchar* font)
439 {
440 PangoFontDescription* _tmp0_;
441 PangoFontDescription* _tmp1_;
442 #line 85 "document_view.vala"
443 g_return_if_fail (self != NULL);
444 #line 85 "document_view.vala"
445 g_return_if_fail (font != NULL);
446 #line 87 "document_view.vala"
447 _tmp0_ = pango_font_description_from_string (font);
448 #line 87 "document_view.vala"
449 __vala_PangoFontDescription_free0 (self->priv->_font_desc);
450 #line 87 "document_view.vala"
451 self->priv->_font_desc = _tmp0_;
452 #line 88 "document_view.vala"
453 _tmp1_ = self->priv->_font_desc;
454 #line 88 "document_view.vala"
455 gtk_widget_override_font ((GtkWidget*) self, _tmp1_);
456 #line 457 "document_view.c"
457 }
458
459 void
document_view_enlarge_font(DocumentView * self)460 document_view_enlarge_font (DocumentView* self)
461 {
462 PangoFontDescription* _tmp0_;
463 PangoFontDescription* _tmp1_;
464 PangoFontDescription* _tmp2_;
465 #line 91 "document_view.vala"
466 g_return_if_fail (self != NULL);
467 #line 94 "document_view.vala"
468 _tmp0_ = self->priv->_font_desc;
469 #line 94 "document_view.vala"
470 _tmp1_ = self->priv->_font_desc;
471 #line 94 "document_view.vala"
472 pango_font_description_set_size (_tmp0_, pango_font_description_get_size (_tmp1_) + PANGO_SCALE);
473 #line 95 "document_view.vala"
474 _tmp2_ = self->priv->_font_desc;
475 #line 95 "document_view.vala"
476 gtk_widget_override_font ((GtkWidget*) self, _tmp2_);
477 #line 478 "document_view.c"
478 }
479
480 void
document_view_shrink_font(DocumentView * self)481 document_view_shrink_font (DocumentView* self)
482 {
483 PangoFontDescription* _tmp0_;
484 PangoFontDescription* _tmp1_;
485 PangoFontDescription* _tmp2_;
486 #line 98 "document_view.vala"
487 g_return_if_fail (self != NULL);
488 #line 101 "document_view.vala"
489 _tmp0_ = self->priv->_font_desc;
490 #line 101 "document_view.vala"
491 _tmp1_ = self->priv->_font_desc;
492 #line 101 "document_view.vala"
493 pango_font_description_set_size (_tmp0_, pango_font_description_get_size (_tmp1_) - PANGO_SCALE);
494 #line 102 "document_view.vala"
495 _tmp2_ = self->priv->_font_desc;
496 #line 102 "document_view.vala"
497 gtk_widget_override_font ((GtkWidget*) self, _tmp2_);
498 #line 499 "document_view.c"
499 }
500
501 static gpointer
_g_object_ref0(gpointer self)502 _g_object_ref0 (gpointer self)
503 {
504 #line 111 "document_view.vala"
505 return self ? g_object_ref (self) : NULL;
506 #line 507 "document_view.c"
507 }
508
509 static gboolean
document_view_on_button_release_event(DocumentView * self,GdkEventButton * event)510 document_view_on_button_release_event (DocumentView* self,
511 GdkEventButton* event)
512 {
513 gboolean _tmp0_ = FALSE;
514 gboolean result = FALSE;
515 #line 105 "document_view.vala"
516 g_return_val_if_fail (self != NULL, FALSE);
517 #line 105 "document_view.vala"
518 g_return_val_if_fail (event != NULL, FALSE);
519 #line 108 "document_view.vala"
520 if (event->button == ((guint) 1)) {
521 #line 522 "document_view.c"
522 GdkModifierType _tmp1_;
523 #line 109 "document_view.vala"
524 _tmp1_ = event->state;
525 #line 109 "document_view.vala"
526 _tmp0_ = (_tmp1_ & GDK_CONTROL_MASK) == GDK_CONTROL_MASK;
527 #line 528 "document_view.c"
528 } else {
529 #line 108 "document_view.vala"
530 _tmp0_ = FALSE;
531 #line 532 "document_view.c"
532 }
533 #line 108 "document_view.vala"
534 if (_tmp0_) {
535 #line 536 "document_view.c"
536 LatexilaSynctex* synctex = NULL;
537 LatexilaSynctex* _tmp2_;
538 LatexilaSynctex* _tmp3_;
539 Document* doc = NULL;
540 GtkTextBuffer* _tmp4_;
541 GtkTextBuffer* _tmp5_;
542 Document* _tmp6_;
543 LatexilaSynctex* _tmp7_;
544 GtkTextBuffer* _tmp8_;
545 GtkTextBuffer* _tmp9_;
546 Document* _tmp10_;
547 GFile* _tmp11_;
548 GFile* _tmp12_;
549 Document* _tmp13_;
550 GFile* _tmp14_;
551 GFile* _tmp15_;
552 #line 111 "document_view.vala"
553 _tmp2_ = latexila_synctex_get_instance ();
554 #line 111 "document_view.vala"
555 _tmp3_ = _g_object_ref0 (_tmp2_);
556 #line 111 "document_view.vala"
557 synctex = _tmp3_;
558 #line 112 "document_view.vala"
559 _tmp4_ = gtk_text_view_get_buffer ((GtkTextView*) self);
560 #line 112 "document_view.vala"
561 _tmp5_ = _tmp4_;
562 #line 112 "document_view.vala"
563 _tmp6_ = _g_object_ref0 (IS_DOCUMENT (_tmp5_) ? ((Document*) _tmp5_) : NULL);
564 #line 112 "document_view.vala"
565 doc = _tmp6_;
566 #line 113 "document_view.vala"
567 _tmp7_ = synctex;
568 #line 113 "document_view.vala"
569 _tmp8_ = gtk_text_view_get_buffer ((GtkTextView*) self);
570 #line 113 "document_view.vala"
571 _tmp9_ = _tmp8_;
572 #line 113 "document_view.vala"
573 _tmp10_ = doc;
574 #line 113 "document_view.vala"
575 _tmp11_ = document_get_location (_tmp10_);
576 #line 113 "document_view.vala"
577 _tmp12_ = _tmp11_;
578 #line 113 "document_view.vala"
579 _tmp13_ = doc;
580 #line 113 "document_view.vala"
581 _tmp14_ = document_get_main_file (_tmp13_);
582 #line 113 "document_view.vala"
583 _tmp15_ = _tmp14_;
584 #line 113 "document_view.vala"
585 latexila_synctex_forward_search (_tmp7_, _tmp9_, _tmp12_, _tmp15_, (guint) event->time);
586 #line 113 "document_view.vala"
587 _g_object_unref0 (_tmp15_);
588 #line 108 "document_view.vala"
589 _g_object_unref0 (doc);
590 #line 108 "document_view.vala"
591 _g_object_unref0 (synctex);
592 #line 593 "document_view.c"
593 }
594 #line 118 "document_view.vala"
595 result = FALSE;
596 #line 118 "document_view.vala"
597 return result;
598 #line 599 "document_view.c"
599 }
600
601 static void
__lambda47_(DocumentView * self)602 __lambda47_ (DocumentView* self)
603 {
604 CompletionProvider* provider = NULL;
605 CompletionProvider* _tmp0_;
606 #line 125 "document_view.vala"
607 _tmp0_ = completion_provider_get_default ();
608 #line 125 "document_view.vala"
609 provider = _tmp0_;
610 #line 126 "document_view.vala"
611 completion_provider_hide_calltip_window (provider);
612 #line 123 "document_view.vala"
613 _g_object_unref0 (provider);
614 #line 615 "document_view.c"
615 }
616
617 static void
___lambda47__g_object_notify(GObject * _sender,GParamSpec * pspec,gpointer self)618 ___lambda47__g_object_notify (GObject* _sender,
619 GParamSpec* pspec,
620 gpointer self)
621 {
622 #line 123 "document_view.vala"
623 __lambda47_ ((DocumentView*) self);
624 #line 625 "document_view.c"
625 }
626
627 static void
document_view_hide_completion_calltip_when_needed(DocumentView * self)628 document_view_hide_completion_calltip_when_needed (DocumentView* self)
629 {
630 GtkTextBuffer* _tmp0_;
631 GtkTextBuffer* _tmp1_;
632 #line 121 "document_view.vala"
633 g_return_if_fail (self != NULL);
634 #line 123 "document_view.vala"
635 _tmp0_ = gtk_text_view_get_buffer ((GtkTextView*) self);
636 #line 123 "document_view.vala"
637 _tmp1_ = _tmp0_;
638 #line 123 "document_view.vala"
639 g_signal_connect_object ((GObject*) _tmp1_, "notify::cursor-position", (GCallback) ___lambda47__g_object_notify, self, 0);
640 #line 641 "document_view.c"
641 }
642
643 static Block18Data*
block18_data_ref(Block18Data * _data18_)644 block18_data_ref (Block18Data* _data18_)
645 {
646 #line 132 "document_view.vala"
647 g_atomic_int_inc (&_data18_->_ref_count_);
648 #line 132 "document_view.vala"
649 return _data18_;
650 #line 651 "document_view.c"
651 }
652
653 static void
block18_data_unref(void * _userdata_)654 block18_data_unref (void * _userdata_)
655 {
656 Block18Data* _data18_;
657 _data18_ = (Block18Data*) _userdata_;
658 #line 132 "document_view.vala"
659 if (g_atomic_int_dec_and_test (&_data18_->_ref_count_)) {
660 #line 661 "document_view.c"
661 DocumentView* self;
662 #line 132 "document_view.vala"
663 self = _data18_->self;
664 #line 132 "document_view.vala"
665 _g_object_unref0 (_data18_->spell_checker);
666 #line 132 "document_view.vala"
667 _g_object_unref0 (self);
668 #line 132 "document_view.vala"
669 g_slice_free (Block18Data, _data18_);
670 #line 671 "document_view.c"
671 }
672 }
673
674 static void
_document_view_inline_checker_enabled_notify_cb_g_object_notify(GObject * _sender,GParamSpec * pspec,gpointer self)675 _document_view_inline_checker_enabled_notify_cb_g_object_notify (GObject* _sender,
676 GParamSpec* pspec,
677 gpointer self)
678 {
679 #line 144 "document_view.vala"
680 document_view_inline_checker_enabled_notify_cb ((DocumentView*) self);
681 #line 682 "document_view.c"
682 }
683
684 static void
__lambda48_(Block18Data * _data18_)685 __lambda48_ (Block18Data* _data18_)
686 {
687 DocumentView* self;
688 GspellLanguage* _tmp0_;
689 #line 148 "document_view.vala"
690 self = _data18_->self;
691 #line 150 "document_view.vala"
692 _tmp0_ = document_view_get_spell_language (self);
693 #line 150 "document_view.vala"
694 gspell_checker_set_language (_data18_->spell_checker, _tmp0_);
695 #line 151 "document_view.vala"
696 document_view_setup_inline_spell_checker (self);
697 #line 698 "document_view.c"
698 }
699
700 static void
___lambda48__g_object_notify(GObject * _sender,GParamSpec * pspec,gpointer self)701 ___lambda48__g_object_notify (GObject* _sender,
702 GParamSpec* pspec,
703 gpointer self)
704 {
705 #line 148 "document_view.vala"
706 __lambda48_ (self);
707 #line 708 "document_view.c"
708 }
709
710 static void
__lambda49_(Block18Data * _data18_)711 __lambda49_ (Block18Data* _data18_)
712 {
713 DocumentView* self;
714 GspellLanguage* _tmp0_;
715 #line 154 "document_view.vala"
716 self = _data18_->self;
717 #line 156 "document_view.vala"
718 _tmp0_ = document_view_get_spell_language (self);
719 #line 156 "document_view.vala"
720 gspell_checker_set_language (_data18_->spell_checker, _tmp0_);
721 #line 722 "document_view.c"
722 }
723
724 static void
___lambda49__g_settings_changed(GSettings * _sender,const gchar * key,gpointer self)725 ___lambda49__g_settings_changed (GSettings* _sender,
726 const gchar* key,
727 gpointer self)
728 {
729 #line 154 "document_view.vala"
730 __lambda49_ (self);
731 #line 732 "document_view.c"
732 }
733
734 static void
__lambda50_(DocumentView * self)735 __lambda50_ (DocumentView* self)
736 {
737 #line 161 "document_view.vala"
738 document_view_setup_inline_spell_checker (self);
739 #line 740 "document_view.c"
740 }
741
742 static void
___lambda50__g_settings_changed(GSettings * _sender,const gchar * key,gpointer self)743 ___lambda50__g_settings_changed (GSettings* _sender,
744 const gchar* key,
745 gpointer self)
746 {
747 #line 159 "document_view.vala"
748 __lambda50_ ((DocumentView*) self);
749 #line 750 "document_view.c"
750 }
751
752 static void
document_view_init_spell_checking(DocumentView * self)753 document_view_init_spell_checking (DocumentView* self)
754 {
755 Block18Data* _data18_;
756 GspellLanguage* _tmp0_;
757 GspellChecker* _tmp1_;
758 GspellTextBuffer* gspell_buffer = NULL;
759 GtkTextBuffer* _tmp2_;
760 GtkTextBuffer* _tmp3_;
761 GspellTextBuffer* _tmp4_;
762 GspellTextView* gspell_view = NULL;
763 GspellTextView* _tmp5_;
764 GspellTextView* _tmp6_;
765 Document* doc = NULL;
766 GtkTextBuffer* _tmp7_;
767 Document* _tmp8_;
768 GSettings* _tmp9_;
769 GSettings* _tmp10_;
770 #line 132 "document_view.vala"
771 g_return_if_fail (self != NULL);
772 #line 132 "document_view.vala"
773 _data18_ = g_slice_new0 (Block18Data);
774 #line 132 "document_view.vala"
775 _data18_->_ref_count_ = 1;
776 #line 132 "document_view.vala"
777 _data18_->self = g_object_ref (self);
778 #line 134 "document_view.vala"
779 _tmp0_ = document_view_get_spell_language (self);
780 #line 134 "document_view.vala"
781 _tmp1_ = gspell_checker_new (_tmp0_);
782 #line 134 "document_view.vala"
783 _data18_->spell_checker = _tmp1_;
784 #line 136 "document_view.vala"
785 _tmp2_ = gtk_text_view_get_buffer ((GtkTextView*) self);
786 #line 136 "document_view.vala"
787 _tmp3_ = _tmp2_;
788 #line 136 "document_view.vala"
789 _tmp4_ = gspell_text_buffer_get_from_gtk_text_buffer (_tmp3_);
790 #line 136 "document_view.vala"
791 gspell_buffer = _tmp4_;
792 #line 138 "document_view.vala"
793 gspell_text_buffer_set_spell_checker (gspell_buffer, _data18_->spell_checker);
794 #line 140 "document_view.vala"
795 document_view_setup_inline_spell_checker (self);
796 #line 142 "document_view.vala"
797 _tmp5_ = gspell_text_view_get_from_gtk_text_view (G_TYPE_CHECK_INSTANCE_TYPE (self, gtk_text_view_get_type ()) ? ((GtkTextView*) self) : NULL);
798 #line 142 "document_view.vala"
799 _tmp6_ = _g_object_ref0 (_tmp5_);
800 #line 142 "document_view.vala"
801 gspell_view = _tmp6_;
802 #line 144 "document_view.vala"
803 g_signal_connect_object ((GObject*) gspell_view, "notify::inline-spell-checking", (GCallback) _document_view_inline_checker_enabled_notify_cb_g_object_notify, self, 0);
804 #line 146 "document_view.vala"
805 _tmp7_ = gtk_text_view_get_buffer ((GtkTextView*) self);
806 #line 146 "document_view.vala"
807 _tmp8_ = _g_object_ref0 (IS_DOCUMENT (_tmp7_) ? ((Document*) _tmp7_) : NULL);
808 #line 146 "document_view.vala"
809 doc = _tmp8_;
810 #line 148 "document_view.vala"
811 g_signal_connect_data ((GObject*) doc, "notify::location", (GCallback) ___lambda48__g_object_notify, block18_data_ref (_data18_), (GClosureNotify) block18_data_unref, 0);
812 #line 154 "document_view.vala"
813 _tmp9_ = self->priv->_editor_settings;
814 #line 154 "document_view.vala"
815 g_signal_connect_data (_tmp9_, "changed::spell-checking-language", (GCallback) ___lambda49__g_settings_changed, block18_data_ref (_data18_), (GClosureNotify) block18_data_unref, 0);
816 #line 159 "document_view.vala"
817 _tmp10_ = self->priv->_editor_settings;
818 #line 159 "document_view.vala"
819 g_signal_connect_object (_tmp10_, "changed::highlight-misspelled-words", (GCallback) ___lambda50__g_settings_changed, self, 0);
820 #line 132 "document_view.vala"
821 _g_object_unref0 (doc);
822 #line 132 "document_view.vala"
823 _g_object_unref0 (gspell_view);
824 #line 132 "document_view.vala"
825 block18_data_unref (_data18_);
826 #line 132 "document_view.vala"
827 _data18_ = NULL;
828 #line 829 "document_view.c"
829 }
830
831 static gchar
string_get(const gchar * self,glong index)832 string_get (const gchar* self,
833 glong index)
834 {
835 gchar _tmp0_;
836 gchar result = '\0';
837 #line 1232 "glib-2.0.vapi"
838 g_return_val_if_fail (self != NULL, '\0');
839 #line 1233 "glib-2.0.vapi"
840 _tmp0_ = ((gchar*) self)[index];
841 #line 1233 "glib-2.0.vapi"
842 result = _tmp0_;
843 #line 1233 "glib-2.0.vapi"
844 return result;
845 #line 846 "document_view.c"
846 }
847
848 static GspellLanguage*
document_view_get_spell_language(DocumentView * self)849 document_view_get_spell_language (DocumentView* self)
850 {
851 Document* doc = NULL;
852 GtkTextBuffer* _tmp0_;
853 Document* _tmp1_;
854 gchar* lang_code = NULL;
855 Document* _tmp2_;
856 TeplMetadata* _tmp3_;
857 gchar* _tmp4_;
858 const gchar* _tmp5_;
859 const gchar* _tmp8_;
860 const gchar* _tmp9_;
861 GspellLanguage* _tmp10_;
862 GspellLanguage* result = NULL;
863 #line 165 "document_view.vala"
864 g_return_val_if_fail (self != NULL, NULL);
865 #line 167 "document_view.vala"
866 _tmp0_ = gtk_text_view_get_buffer ((GtkTextView*) self);
867 #line 167 "document_view.vala"
868 _tmp1_ = _g_object_ref0 (IS_DOCUMENT (_tmp0_) ? ((Document*) _tmp0_) : NULL);
869 #line 167 "document_view.vala"
870 doc = _tmp1_;
871 #line 169 "document_view.vala"
872 _tmp2_ = doc;
873 #line 169 "document_view.vala"
874 _tmp3_ = tepl_buffer_get_metadata ((TeplBuffer*) _tmp2_);
875 #line 169 "document_view.vala"
876 _tmp4_ = tepl_metadata_get (_tmp3_, DOCUMENT_VIEW_METADATA_KEY_SPELL_LANGUAGE);
877 #line 169 "document_view.vala"
878 lang_code = _tmp4_;
879 #line 170 "document_view.vala"
880 _tmp5_ = lang_code;
881 #line 170 "document_view.vala"
882 if (_tmp5_ == NULL) {
883 #line 884 "document_view.c"
884 GSettings* _tmp6_;
885 gchar* _tmp7_;
886 #line 171 "document_view.vala"
887 _tmp6_ = self->priv->_editor_settings;
888 #line 171 "document_view.vala"
889 _tmp7_ = g_settings_get_string (_tmp6_, "spell-checking-language");
890 #line 171 "document_view.vala"
891 _g_free0 (lang_code);
892 #line 171 "document_view.vala"
893 lang_code = _tmp7_;
894 #line 895 "document_view.c"
895 }
896 #line 173 "document_view.vala"
897 _tmp8_ = lang_code;
898 #line 173 "document_view.vala"
899 if (string_get (_tmp8_, (glong) 0) == '\0') {
900 #line 174 "document_view.vala"
901 result = NULL;
902 #line 174 "document_view.vala"
903 _g_free0 (lang_code);
904 #line 174 "document_view.vala"
905 _g_object_unref0 (doc);
906 #line 174 "document_view.vala"
907 return result;
908 #line 909 "document_view.c"
909 }
910 #line 176 "document_view.vala"
911 _tmp9_ = lang_code;
912 #line 176 "document_view.vala"
913 _tmp10_ = gspell_language_lookup (_tmp9_);
914 #line 176 "document_view.vala"
915 result = _tmp10_;
916 #line 176 "document_view.vala"
917 _g_free0 (lang_code);
918 #line 176 "document_view.vala"
919 _g_object_unref0 (doc);
920 #line 176 "document_view.vala"
921 return result;
922 #line 923 "document_view.c"
923 }
924
925 static GspellChecker*
document_view_get_spell_checker(DocumentView * self)926 document_view_get_spell_checker (DocumentView* self)
927 {
928 GspellTextBuffer* gspell_buffer = NULL;
929 GtkTextBuffer* _tmp0_;
930 GtkTextBuffer* _tmp1_;
931 GspellTextBuffer* _tmp2_;
932 GspellChecker* _tmp3_;
933 GspellChecker* result = NULL;
934 #line 179 "document_view.vala"
935 g_return_val_if_fail (self != NULL, NULL);
936 #line 181 "document_view.vala"
937 _tmp0_ = gtk_text_view_get_buffer ((GtkTextView*) self);
938 #line 181 "document_view.vala"
939 _tmp1_ = _tmp0_;
940 #line 181 "document_view.vala"
941 _tmp2_ = gspell_text_buffer_get_from_gtk_text_buffer (_tmp1_);
942 #line 181 "document_view.vala"
943 gspell_buffer = _tmp2_;
944 #line 184 "document_view.vala"
945 _tmp3_ = gspell_text_buffer_get_spell_checker (gspell_buffer);
946 #line 184 "document_view.vala"
947 result = _tmp3_;
948 #line 184 "document_view.vala"
949 return result;
950 #line 951 "document_view.c"
951 }
952
953 void
document_view_setup_inline_spell_checker(DocumentView * self)954 document_view_setup_inline_spell_checker (DocumentView* self)
955 {
956 Document* doc = NULL;
957 GtkTextBuffer* _tmp0_;
958 Document* _tmp1_;
959 gboolean enabled = FALSE;
960 gchar* metadata = NULL;
961 Document* _tmp2_;
962 TeplMetadata* _tmp3_;
963 gchar* _tmp4_;
964 const gchar* _tmp5_;
965 GspellTextView* gspell_view = NULL;
966 GspellTextView* _tmp8_;
967 GspellTextView* _tmp9_;
968 #line 187 "document_view.vala"
969 g_return_if_fail (self != NULL);
970 #line 189 "document_view.vala"
971 _tmp0_ = gtk_text_view_get_buffer ((GtkTextView*) self);
972 #line 189 "document_view.vala"
973 _tmp1_ = _g_object_ref0 (IS_DOCUMENT (_tmp0_) ? ((Document*) _tmp0_) : NULL);
974 #line 189 "document_view.vala"
975 doc = _tmp1_;
976 #line 193 "document_view.vala"
977 _tmp2_ = doc;
978 #line 193 "document_view.vala"
979 _tmp3_ = tepl_buffer_get_metadata ((TeplBuffer*) _tmp2_);
980 #line 193 "document_view.vala"
981 _tmp4_ = tepl_metadata_get (_tmp3_, DOCUMENT_VIEW_METADATA_KEY_INLINE_SPELL);
982 #line 193 "document_view.vala"
983 metadata = _tmp4_;
984 #line 194 "document_view.vala"
985 _tmp5_ = metadata;
986 #line 194 "document_view.vala"
987 if (_tmp5_ != NULL) {
988 #line 989 "document_view.c"
989 const gchar* _tmp6_;
990 #line 195 "document_view.vala"
991 _tmp6_ = metadata;
992 #line 195 "document_view.vala"
993 enabled = g_strcmp0 (_tmp6_, DOCUMENT_VIEW_INLINE_SPELL_ENABLED_STR) == 0;
994 #line 995 "document_view.c"
995 } else {
996 GSettings* _tmp7_;
997 #line 197 "document_view.vala"
998 _tmp7_ = self->priv->_editor_settings;
999 #line 197 "document_view.vala"
1000 enabled = g_settings_get_boolean (_tmp7_, "highlight-misspelled-words");
1001 #line 1002 "document_view.c"
1002 }
1003 #line 199 "document_view.vala"
1004 _tmp8_ = gspell_text_view_get_from_gtk_text_view (G_TYPE_CHECK_INSTANCE_TYPE (self, gtk_text_view_get_type ()) ? ((GtkTextView*) self) : NULL);
1005 #line 199 "document_view.vala"
1006 _tmp9_ = _g_object_ref0 (_tmp8_);
1007 #line 199 "document_view.vala"
1008 gspell_view = _tmp9_;
1009 #line 201 "document_view.vala"
1010 gspell_text_view_set_inline_spell_checking (gspell_view, enabled);
1011 #line 187 "document_view.vala"
1012 _g_object_unref0 (gspell_view);
1013 #line 187 "document_view.vala"
1014 _g_free0 (metadata);
1015 #line 187 "document_view.vala"
1016 _g_object_unref0 (doc);
1017 #line 1018 "document_view.c"
1018 }
1019
1020 void
document_view_launch_spell_checker_dialog(DocumentView * self)1021 document_view_launch_spell_checker_dialog (DocumentView* self)
1022 {
1023 GspellNavigator* navigator = NULL;
1024 GspellNavigator* _tmp0_;
1025 GspellNavigator* _tmp1_;
1026 GspellCheckerDialog* dialog = NULL;
1027 GtkWidget* _tmp2_;
1028 GspellCheckerDialog* _tmp3_;
1029 #line 204 "document_view.vala"
1030 g_return_if_fail (self != NULL);
1031 #line 206 "document_view.vala"
1032 _tmp0_ = gspell_navigator_text_view_new (G_TYPE_CHECK_INSTANCE_TYPE (self, gtk_text_view_get_type ()) ? ((GtkTextView*) self) : NULL);
1033 #line 206 "document_view.vala"
1034 _tmp1_ = _g_object_ref0 (_tmp0_);
1035 #line 206 "document_view.vala"
1036 navigator = _tmp1_;
1037 #line 208 "document_view.vala"
1038 _tmp2_ = gtk_widget_get_toplevel ((GtkWidget*) self);
1039 #line 208 "document_view.vala"
1040 _tmp3_ = (GspellCheckerDialog*) gspell_checker_dialog_new (G_TYPE_CHECK_INSTANCE_TYPE (_tmp2_, gtk_window_get_type ()) ? ((GtkWindow*) _tmp2_) : NULL, navigator);
1041 #line 208 "document_view.vala"
1042 g_object_ref_sink (_tmp3_);
1043 #line 208 "document_view.vala"
1044 dialog = _tmp3_;
1045 #line 211 "document_view.vala"
1046 gtk_widget_show ((GtkWidget*) dialog);
1047 #line 204 "document_view.vala"
1048 _g_object_unref0 (dialog);
1049 #line 204 "document_view.vala"
1050 _g_object_unref0 (navigator);
1051 #line 1052 "document_view.c"
1052 }
1053
1054 void
document_view_launch_spell_language_chooser_dialog(DocumentView * self)1055 document_view_launch_spell_language_chooser_dialog (DocumentView* self)
1056 {
1057 GspellChecker* spell_checker = NULL;
1058 GspellChecker* _tmp0_;
1059 GspellChecker* _tmp1_;
1060 GspellLanguageChooserDialog* dialog = NULL;
1061 GtkWidget* _tmp2_;
1062 GspellLanguage* _tmp3_;
1063 GspellLanguageChooserDialog* _tmp4_;
1064 GspellLanguage* lang = NULL;
1065 GspellLanguage* _tmp5_;
1066 #line 214 "document_view.vala"
1067 g_return_if_fail (self != NULL);
1068 #line 216 "document_view.vala"
1069 _tmp0_ = document_view_get_spell_checker (self);
1070 #line 216 "document_view.vala"
1071 _tmp1_ = _g_object_ref0 (_tmp0_);
1072 #line 216 "document_view.vala"
1073 spell_checker = _tmp1_;
1074 #line 217 "document_view.vala"
1075 g_return_if_fail (spell_checker != NULL);
1076 #line 219 "document_view.vala"
1077 _tmp2_ = gtk_widget_get_toplevel ((GtkWidget*) self);
1078 #line 219 "document_view.vala"
1079 _tmp3_ = gspell_checker_get_language (spell_checker);
1080 #line 219 "document_view.vala"
1081 _tmp4_ = (GspellLanguageChooserDialog*) gspell_language_chooser_dialog_new (G_TYPE_CHECK_INSTANCE_TYPE (_tmp2_, gtk_window_get_type ()) ? ((GtkWindow*) _tmp2_) : NULL, _tmp3_, (GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL) | GTK_DIALOG_USE_HEADER_BAR);
1082 #line 219 "document_view.vala"
1083 g_object_ref_sink (_tmp4_);
1084 #line 219 "document_view.vala"
1085 dialog = _tmp4_;
1086 #line 226 "document_view.vala"
1087 gtk_dialog_run ((GtkDialog*) dialog);
1088 #line 228 "document_view.vala"
1089 _tmp5_ = gspell_language_chooser_get_language ((GspellLanguageChooser*) dialog);
1090 #line 228 "document_view.vala"
1091 lang = _tmp5_;
1092 #line 229 "document_view.vala"
1093 gspell_checker_set_language (spell_checker, lang);
1094 #line 231 "document_view.vala"
1095 gtk_widget_destroy ((GtkWidget*) dialog);
1096 #line 214 "document_view.vala"
1097 _g_object_unref0 (dialog);
1098 #line 214 "document_view.vala"
1099 _g_object_unref0 (spell_checker);
1100 #line 1101 "document_view.c"
1101 }
1102
1103 void
document_view_save_spell_language_metadata(DocumentView * self)1104 document_view_save_spell_language_metadata (DocumentView* self)
1105 {
1106 GspellChecker* spell_checker = NULL;
1107 GspellChecker* _tmp0_;
1108 GspellChecker* _tmp1_;
1109 GspellChecker* _tmp2_;
1110 Document* doc = NULL;
1111 GtkTextBuffer* _tmp3_;
1112 Document* _tmp4_;
1113 GspellLanguage* lang = NULL;
1114 GspellChecker* _tmp5_;
1115 GspellLanguage* _tmp6_;
1116 GspellLanguage* _tmp7_;
1117 #line 234 "document_view.vala"
1118 g_return_if_fail (self != NULL);
1119 #line 236 "document_view.vala"
1120 _tmp0_ = document_view_get_spell_checker (self);
1121 #line 236 "document_view.vala"
1122 _tmp1_ = _g_object_ref0 (_tmp0_);
1123 #line 236 "document_view.vala"
1124 spell_checker = _tmp1_;
1125 #line 237 "document_view.vala"
1126 _tmp2_ = spell_checker;
1127 #line 237 "document_view.vala"
1128 g_return_if_fail (_tmp2_ != NULL);
1129 #line 239 "document_view.vala"
1130 _tmp3_ = gtk_text_view_get_buffer ((GtkTextView*) self);
1131 #line 239 "document_view.vala"
1132 _tmp4_ = _g_object_ref0 (IS_DOCUMENT (_tmp3_) ? ((Document*) _tmp3_) : NULL);
1133 #line 239 "document_view.vala"
1134 doc = _tmp4_;
1135 #line 241 "document_view.vala"
1136 _tmp5_ = spell_checker;
1137 #line 241 "document_view.vala"
1138 _tmp6_ = gspell_checker_get_language (_tmp5_);
1139 #line 241 "document_view.vala"
1140 lang = _tmp6_;
1141 #line 242 "document_view.vala"
1142 _tmp7_ = lang;
1143 #line 242 "document_view.vala"
1144 if (_tmp7_ != NULL) {
1145 #line 1146 "document_view.c"
1146 Document* _tmp8_;
1147 GspellLanguage* _tmp9_;
1148 const gchar* _tmp10_;
1149 #line 243 "document_view.vala"
1150 _tmp8_ = doc;
1151 #line 243 "document_view.vala"
1152 _tmp9_ = lang;
1153 #line 243 "document_view.vala"
1154 _tmp10_ = gspell_language_get_code (_tmp9_);
1155 #line 243 "document_view.vala"
1156 document_set_metadata (_tmp8_, DOCUMENT_VIEW_METADATA_KEY_SPELL_LANGUAGE, _tmp10_);
1157 #line 1158 "document_view.c"
1158 } else {
1159 Document* _tmp11_;
1160 #line 245 "document_view.vala"
1161 _tmp11_ = doc;
1162 #line 245 "document_view.vala"
1163 document_set_metadata (_tmp11_, DOCUMENT_VIEW_METADATA_KEY_SPELL_LANGUAGE, NULL);
1164 #line 1165 "document_view.c"
1165 }
1166 #line 234 "document_view.vala"
1167 _g_object_unref0 (doc);
1168 #line 234 "document_view.vala"
1169 _g_object_unref0 (spell_checker);
1170 #line 1171 "document_view.c"
1171 }
1172
1173 void
document_view_save_inline_spell_metadata(DocumentView * self)1174 document_view_save_inline_spell_metadata (DocumentView* self)
1175 {
1176 Document* doc = NULL;
1177 GtkTextBuffer* _tmp0_;
1178 Document* _tmp1_;
1179 GspellTextView* gspell_view = NULL;
1180 GspellTextView* _tmp2_;
1181 GspellTextView* _tmp3_;
1182 GspellTextView* _tmp4_;
1183 gboolean _tmp5_;
1184 gboolean _tmp6_;
1185 #line 248 "document_view.vala"
1186 g_return_if_fail (self != NULL);
1187 #line 250 "document_view.vala"
1188 _tmp0_ = gtk_text_view_get_buffer ((GtkTextView*) self);
1189 #line 250 "document_view.vala"
1190 _tmp1_ = _g_object_ref0 (IS_DOCUMENT (_tmp0_) ? ((Document*) _tmp0_) : NULL);
1191 #line 250 "document_view.vala"
1192 doc = _tmp1_;
1193 #line 252 "document_view.vala"
1194 _tmp2_ = gspell_text_view_get_from_gtk_text_view (G_TYPE_CHECK_INSTANCE_TYPE (self, gtk_text_view_get_type ()) ? ((GtkTextView*) self) : NULL);
1195 #line 252 "document_view.vala"
1196 _tmp3_ = _g_object_ref0 (_tmp2_);
1197 #line 252 "document_view.vala"
1198 gspell_view = _tmp3_;
1199 #line 255 "document_view.vala"
1200 _tmp4_ = gspell_view;
1201 #line 255 "document_view.vala"
1202 _tmp5_ = gspell_text_view_get_inline_spell_checking (_tmp4_);
1203 #line 255 "document_view.vala"
1204 _tmp6_ = _tmp5_;
1205 #line 255 "document_view.vala"
1206 if (_tmp6_) {
1207 #line 1208 "document_view.c"
1208 Document* _tmp7_;
1209 #line 257 "document_view.vala"
1210 _tmp7_ = doc;
1211 #line 257 "document_view.vala"
1212 document_set_metadata (_tmp7_, DOCUMENT_VIEW_METADATA_KEY_INLINE_SPELL, DOCUMENT_VIEW_INLINE_SPELL_ENABLED_STR);
1213 #line 1214 "document_view.c"
1214 } else {
1215 Document* _tmp8_;
1216 #line 261 "document_view.vala"
1217 _tmp8_ = doc;
1218 #line 261 "document_view.vala"
1219 document_set_metadata (_tmp8_, DOCUMENT_VIEW_METADATA_KEY_INLINE_SPELL, DOCUMENT_VIEW_INLINE_SPELL_DISABLED_STR);
1220 #line 1221 "document_view.c"
1221 }
1222 #line 248 "document_view.vala"
1223 _g_object_unref0 (gspell_view);
1224 #line 248 "document_view.vala"
1225 _g_object_unref0 (doc);
1226 #line 1227 "document_view.c"
1227 }
1228
1229 static void
document_view_inline_checker_enabled_notify_cb(DocumentView * self)1230 document_view_inline_checker_enabled_notify_cb (DocumentView* self)
1231 {
1232 GspellTextView* gspell_view = NULL;
1233 GspellTextView* _tmp0_;
1234 GspellTextView* _tmp1_;
1235 GspellTextView* _tmp2_;
1236 gboolean _tmp3_;
1237 gboolean _tmp4_;
1238 GspellChecker* spell_checker = NULL;
1239 GspellChecker* _tmp5_;
1240 GspellChecker* _tmp6_;
1241 GspellChecker* _tmp7_;
1242 GspellChecker* _tmp8_;
1243 GspellLanguage* _tmp9_;
1244 GspellTextView* _tmp10_;
1245 GtkMessageDialog* dialog = NULL;
1246 GtkWidget* _tmp11_;
1247 GtkMessageDialog* _tmp12_;
1248 GtkMessageDialog* _tmp13_;
1249 gint response = 0;
1250 GtkMessageDialog* _tmp14_;
1251 GtkMessageDialog* _tmp17_;
1252 GError* _inner_error0_ = NULL;
1253 #line 265 "document_view.vala"
1254 g_return_if_fail (self != NULL);
1255 #line 267 "document_view.vala"
1256 _tmp0_ = gspell_text_view_get_from_gtk_text_view (G_TYPE_CHECK_INSTANCE_TYPE (self, gtk_text_view_get_type ()) ? ((GtkTextView*) self) : NULL);
1257 #line 267 "document_view.vala"
1258 _tmp1_ = _g_object_ref0 (_tmp0_);
1259 #line 267 "document_view.vala"
1260 gspell_view = _tmp1_;
1261 #line 269 "document_view.vala"
1262 _tmp2_ = gspell_view;
1263 #line 269 "document_view.vala"
1264 _tmp3_ = gspell_text_view_get_inline_spell_checking (_tmp2_);
1265 #line 269 "document_view.vala"
1266 _tmp4_ = _tmp3_;
1267 #line 269 "document_view.vala"
1268 if (!_tmp4_) {
1269 #line 270 "document_view.vala"
1270 _g_object_unref0 (gspell_view);
1271 #line 270 "document_view.vala"
1272 return;
1273 #line 1274 "document_view.c"
1274 }
1275 #line 272 "document_view.vala"
1276 _tmp5_ = document_view_get_spell_checker (self);
1277 #line 272 "document_view.vala"
1278 _tmp6_ = _g_object_ref0 (_tmp5_);
1279 #line 272 "document_view.vala"
1280 spell_checker = _tmp6_;
1281 #line 273 "document_view.vala"
1282 _tmp7_ = spell_checker;
1283 #line 273 "document_view.vala"
1284 g_return_if_fail (_tmp7_ != NULL);
1285 #line 275 "document_view.vala"
1286 _tmp8_ = spell_checker;
1287 #line 275 "document_view.vala"
1288 _tmp9_ = gspell_checker_get_language (_tmp8_);
1289 #line 275 "document_view.vala"
1290 if (_tmp9_ != NULL) {
1291 #line 276 "document_view.vala"
1292 _g_object_unref0 (spell_checker);
1293 #line 276 "document_view.vala"
1294 _g_object_unref0 (gspell_view);
1295 #line 276 "document_view.vala"
1296 return;
1297 #line 1298 "document_view.c"
1298 }
1299 #line 278 "document_view.vala"
1300 _tmp10_ = gspell_view;
1301 #line 278 "document_view.vala"
1302 gspell_text_view_set_inline_spell_checking (_tmp10_, FALSE);
1303 #line 280 "document_view.vala"
1304 if (document_view__no_spell_language_dialog_shown) {
1305 #line 281 "document_view.vala"
1306 _g_object_unref0 (spell_checker);
1307 #line 281 "document_view.vala"
1308 _g_object_unref0 (gspell_view);
1309 #line 281 "document_view.vala"
1310 return;
1311 #line 1312 "document_view.c"
1312 }
1313 #line 283 "document_view.vala"
1314 document_view__no_spell_language_dialog_shown = TRUE;
1315 #line 285 "document_view.vala"
1316 _tmp11_ = gtk_widget_get_toplevel ((GtkWidget*) self);
1317 #line 285 "document_view.vala"
1318 _tmp12_ = (GtkMessageDialog*) gtk_message_dialog_new (G_TYPE_CHECK_INSTANCE_TYPE (_tmp11_, gtk_window_get_type ()) ? ((GtkWindow*) _tmp11_) : NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_NONE, "%s", _ ("No dictionaries available for the spell-checking."));
1319 #line 285 "document_view.vala"
1320 g_object_ref_sink (_tmp12_);
1321 #line 285 "document_view.vala"
1322 dialog = _tmp12_;
1323 #line 291 "document_view.vala"
1324 _tmp13_ = dialog;
1325 #line 291 "document_view.vala"
1326 gtk_dialog_add_buttons ((GtkDialog*) _tmp13_, _ ("_Help"), GTK_RESPONSE_HELP, _ ("_OK"), GTK_RESPONSE_OK, NULL, NULL);
1327 #line 295 "document_view.vala"
1328 _tmp14_ = dialog;
1329 #line 295 "document_view.vala"
1330 response = gtk_dialog_run ((GtkDialog*) _tmp14_);
1331 #line 297 "document_view.vala"
1332 if (response == ((gint) GTK_RESPONSE_HELP)) {
1333 #line 1334 "document_view.c"
1334 {
1335 #line 301 "document_view.vala"
1336 latexila_utils_show_uri ((GtkWidget*) self, "help:latexila/spell_checking", (guint32) GDK_CURRENT_TIME, &_inner_error0_);
1337 #line 301 "document_view.vala"
1338 if (G_UNLIKELY (_inner_error0_ != NULL)) {
1339 #line 1340 "document_view.c"
1340 goto __catch0_g_error;
1341 }
1342 }
1343 goto __finally0;
1344 __catch0_g_error:
1345 {
1346 GError* e = NULL;
1347 GError* _tmp15_;
1348 const gchar* _tmp16_;
1349 #line 299 "document_view.vala"
1350 e = _inner_error0_;
1351 #line 299 "document_view.vala"
1352 _inner_error0_ = NULL;
1353 #line 306 "document_view.vala"
1354 _tmp15_ = e;
1355 #line 306 "document_view.vala"
1356 _tmp16_ = _tmp15_->message;
1357 #line 306 "document_view.vala"
1358 g_warning ("document_view.vala:306: Impossible to open the documentation: %s", _tmp16_);
1359 #line 299 "document_view.vala"
1360 _g_error_free0 (e);
1361 #line 1362 "document_view.c"
1362 }
1363 __finally0:
1364 #line 299 "document_view.vala"
1365 if (G_UNLIKELY (_inner_error0_ != NULL)) {
1366 #line 299 "document_view.vala"
1367 _g_object_unref0 (dialog);
1368 #line 299 "document_view.vala"
1369 _g_object_unref0 (spell_checker);
1370 #line 299 "document_view.vala"
1371 _g_object_unref0 (gspell_view);
1372 #line 299 "document_view.vala"
1373 g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
1374 #line 299 "document_view.vala"
1375 g_clear_error (&_inner_error0_);
1376 #line 299 "document_view.vala"
1377 return;
1378 #line 1379 "document_view.c"
1379 }
1380 }
1381 #line 310 "document_view.vala"
1382 _tmp17_ = dialog;
1383 #line 310 "document_view.vala"
1384 gtk_widget_destroy ((GtkWidget*) _tmp17_);
1385 #line 265 "document_view.vala"
1386 _g_object_unref0 (dialog);
1387 #line 265 "document_view.vala"
1388 _g_object_unref0 (spell_checker);
1389 #line 265 "document_view.vala"
1390 _g_object_unref0 (gspell_view);
1391 #line 1392 "document_view.c"
1392 }
1393
1394 static void
document_view_class_init(DocumentViewClass * klass,gpointer klass_data)1395 document_view_class_init (DocumentViewClass * klass,
1396 gpointer klass_data)
1397 {
1398 #line 22 "document_view.vala"
1399 document_view_parent_class = g_type_class_peek_parent (klass);
1400 #line 22 "document_view.vala"
1401 g_type_class_adjust_private_offset (klass, &DocumentView_private_offset);
1402 #line 22 "document_view.vala"
1403 G_OBJECT_CLASS (klass)->finalize = document_view_finalize;
1404 #line 1405 "document_view.c"
1405 }
1406
1407 static void
document_view_instance_init(DocumentView * self,gpointer klass)1408 document_view_instance_init (DocumentView * self,
1409 gpointer klass)
1410 {
1411 #line 22 "document_view.vala"
1412 self->priv = document_view_get_instance_private (self);
1413 #line 1414 "document_view.c"
1414 }
1415
1416 static void
document_view_finalize(GObject * obj)1417 document_view_finalize (GObject * obj)
1418 {
1419 DocumentView * self;
1420 #line 22 "document_view.vala"
1421 self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_DOCUMENT_VIEW, DocumentView);
1422 #line 29 "document_view.vala"
1423 _g_object_unref0 (self->priv->_editor_settings);
1424 #line 30 "document_view.vala"
1425 __vala_PangoFontDescription_free0 (self->priv->_font_desc);
1426 #line 22 "document_view.vala"
1427 G_OBJECT_CLASS (document_view_parent_class)->finalize (obj);
1428 #line 1429 "document_view.c"
1429 }
1430
1431 static GType
document_view_get_type_once(void)1432 document_view_get_type_once (void)
1433 {
1434 static const GTypeInfo g_define_type_info = { sizeof (DocumentViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) document_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DocumentView), 0, (GInstanceInitFunc) document_view_instance_init, NULL };
1435 GType document_view_type_id;
1436 document_view_type_id = g_type_register_static (tepl_view_get_type (), "DocumentView", &g_define_type_info, 0);
1437 DocumentView_private_offset = g_type_add_instance_private (document_view_type_id, sizeof (DocumentViewPrivate));
1438 return document_view_type_id;
1439 }
1440
1441 GType
document_view_get_type(void)1442 document_view_get_type (void)
1443 {
1444 static volatile gsize document_view_type_id__volatile = 0;
1445 if (g_once_init_enter (&document_view_type_id__volatile)) {
1446 GType document_view_type_id;
1447 document_view_type_id = document_view_get_type_once ();
1448 g_once_init_leave (&document_view_type_id__volatile, document_view_type_id);
1449 }
1450 return document_view_type_id__volatile;
1451 }
1452
1453