1 /* application.c generated by valac 0.48.6, the Vala compiler
2 * generated from application.vala, do not modify */
3
4 /*
5 * Notes - panel plugin for Xfce Desktop Environment
6 * Copyright (c) 2009-2010 Mike Massonnet <mmassonnet@xfce.org>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 */
22
23 #include <glib-object.h>
24 #include <glib.h>
25 #include <gtk/gtk.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <xfconf/xfconf.h>
29 #include <glib/gi18n-lib.h>
30 #include <glib/gstdio.h>
31 #include <errno.h>
32 #include <gio/gio.h>
33 #include <float.h>
34 #include <math.h>
35 #include <config.h>
36 #include <libxfce4util/libxfce4util.h>
37 #include <signal.h>
38
39 #define XNP_TYPE_APPLICATION (xnp_application_get_type ())
40 #define XNP_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XNP_TYPE_APPLICATION, XnpApplication))
41 #define XNP_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XNP_TYPE_APPLICATION, XnpApplicationClass))
42 #define XNP_IS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XNP_TYPE_APPLICATION))
43 #define XNP_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XNP_TYPE_APPLICATION))
44 #define XNP_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XNP_TYPE_APPLICATION, XnpApplicationClass))
45
46 typedef struct _XnpApplication XnpApplication;
47 typedef struct _XnpApplicationClass XnpApplicationClass;
48 typedef struct _XnpApplicationPrivate XnpApplicationPrivate;
49
50 #define XNP_TYPE_WINDOW_MONITOR (xnp_window_monitor_get_type ())
51 #define XNP_WINDOW_MONITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XNP_TYPE_WINDOW_MONITOR, XnpWindowMonitor))
52 #define XNP_WINDOW_MONITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XNP_TYPE_WINDOW_MONITOR, XnpWindowMonitorClass))
53 #define XNP_IS_WINDOW_MONITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XNP_TYPE_WINDOW_MONITOR))
54 #define XNP_IS_WINDOW_MONITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XNP_TYPE_WINDOW_MONITOR))
55 #define XNP_WINDOW_MONITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XNP_TYPE_WINDOW_MONITOR, XnpWindowMonitorClass))
56
57 typedef struct _XnpWindowMonitor XnpWindowMonitor;
58 typedef struct _XnpWindowMonitorClass XnpWindowMonitorClass;
59
60 #define XNP_TYPE_WINDOW (xnp_window_get_type ())
61 #define XNP_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XNP_TYPE_WINDOW, XnpWindow))
62 #define XNP_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XNP_TYPE_WINDOW, XnpWindowClass))
63 #define XNP_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XNP_TYPE_WINDOW))
64 #define XNP_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XNP_TYPE_WINDOW))
65 #define XNP_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XNP_TYPE_WINDOW, XnpWindowClass))
66
67 typedef struct _XnpWindow XnpWindow;
68 typedef struct _XnpWindowClass XnpWindowClass;
69 enum {
70 XNP_APPLICATION_0_PROPERTY,
71 XNP_APPLICATION_NOTES_PATH_PROPERTY,
72 XNP_APPLICATION_CONFIG_FILE_PROPERTY,
73 XNP_APPLICATION_NUM_PROPERTIES
74 };
75 static GParamSpec* xnp_application_properties[XNP_APPLICATION_NUM_PROPERTIES];
76 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
77 #define _g_free0(var) (var = (g_free (var), NULL))
78 #define _g_dir_close0(var) ((var == NULL) ? NULL : (var = (g_dir_close (var), NULL)))
79 #define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
80
81 #define XNP_TYPE_NOTE (xnp_note_get_type ())
82 #define XNP_NOTE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XNP_TYPE_NOTE, XnpNote))
83 #define XNP_NOTE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XNP_TYPE_NOTE, XnpNoteClass))
84 #define XNP_IS_NOTE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XNP_TYPE_NOTE))
85 #define XNP_IS_NOTE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XNP_TYPE_NOTE))
86 #define XNP_NOTE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XNP_TYPE_NOTE, XnpNoteClass))
87
88 typedef struct _XnpNote XnpNote;
89 typedef struct _XnpNoteClass XnpNoteClass;
90 typedef struct _XnpNotePrivate XnpNotePrivate;
91
92 #define XNP_TYPE_HYPERTEXT_VIEW (xnp_hypertext_view_get_type ())
93 #define XNP_HYPERTEXT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XNP_TYPE_HYPERTEXT_VIEW, XnpHypertextView))
94 #define XNP_HYPERTEXT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XNP_TYPE_HYPERTEXT_VIEW, XnpHypertextViewClass))
95 #define XNP_IS_HYPERTEXT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XNP_TYPE_HYPERTEXT_VIEW))
96 #define XNP_IS_HYPERTEXT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XNP_TYPE_HYPERTEXT_VIEW))
97 #define XNP_HYPERTEXT_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XNP_TYPE_HYPERTEXT_VIEW, XnpHypertextViewClass))
98
99 typedef struct _XnpHypertextView XnpHypertextView;
100 typedef struct _XnpHypertextViewClass XnpHypertextViewClass;
101 #define _g_key_file_unref0(var) ((var == NULL) ? NULL : (var = (g_key_file_unref (var), NULL)))
102 typedef struct _XnpWindowMonitorPrivate XnpWindowMonitorPrivate;
103 typedef struct _Block1Data Block1Data;
104
105 struct _XnpApplication {
106 GObject parent_instance;
107 XnpApplicationPrivate * priv;
108 };
109
110 struct _XnpApplicationClass {
111 GObjectClass parent_class;
112 };
113
114 struct _XnpApplicationPrivate {
115 GSList* window_monitor_list;
116 GSList* window_list;
117 gchar* _notes_path;
118 gchar* _config_file;
119 XfconfChannel* xfconf_channel;
120 };
121
122 struct _XnpNote {
123 GtkScrolledWindow parent_instance;
124 XnpNotePrivate * priv;
125 XnpHypertextView* text_view;
126 };
127
128 struct _XnpNoteClass {
129 GtkScrolledWindowClass parent_class;
130 };
131
132 struct _XnpWindowMonitor {
133 GObject parent_instance;
134 XnpWindowMonitorPrivate * priv;
135 XnpWindow* window;
136 };
137
138 struct _XnpWindowMonitorClass {
139 GObjectClass parent_class;
140 };
141
142 struct _Block1Data {
143 int _ref_count_;
144 XnpApplication* self;
145 GtkMenu* menu;
146 };
147
148 static gint XnpApplication_private_offset;
149 static gpointer xnp_application_parent_class = NULL;
150
151 GType xnp_application_get_type (void) G_GNUC_CONST;
152 G_DEFINE_AUTOPTR_CLEANUP_FUNC (XnpApplication, g_object_unref)
153 GType xnp_window_monitor_get_type (void) G_GNUC_CONST;
154 G_DEFINE_AUTOPTR_CLEANUP_FUNC (XnpWindowMonitor, g_object_unref)
155 GType xnp_window_get_type (void) G_GNUC_CONST;
156 G_DEFINE_AUTOPTR_CLEANUP_FUNC (XnpWindow, g_object_unref)
157 void xnp_application_save_windows_configuration (XnpApplication* self);
158 static void _g_object_unref0_ (gpointer var);
159 static inline void _g_slist_free__g_object_unref0_ (GSList* self);
160 XnpApplication* xnp_application_new (const gchar* config_file);
161 XnpApplication* xnp_application_construct (GType object_type,
162 const gchar* config_file);
163 XnpApplication* xnp_application_new_with_notes_path (const gchar* config_file,
164 const gchar* notes_path);
165 XnpApplication* xnp_application_construct_with_notes_path (GType object_type,
166 const gchar* config_file,
167 const gchar* notes_path);
168 static void xnp_application_update_notes_path (XnpApplication* self);
169 const gchar* xnp_application_get_notes_path (XnpApplication* self);
170 static void xnp_application_update_color (XnpApplication* self);
171 void xnp_theme_set_background_color (const gchar* color);
172 static void xnp_application_quit (XnpApplication* self);
173 void xnp_application_save_notes (XnpApplication* self);
174 XnpWindow* xnp_application_create_window (XnpApplication* self,
175 const gchar* name);
176 XnpWindow* xnp_window_new (void);
177 XnpWindow* xnp_window_construct (GType object_type);
178 void xnp_window_set_above (XnpWindow* self,
179 gboolean value);
180 void xnp_window_set_sticky (XnpWindow* self,
181 gboolean value);
182 static gboolean xnp_application_window_name_exists (XnpApplication* self,
183 const gchar* name);
184 void xnp_window_set_name (XnpWindow* self,
185 const gchar* value);
186 gint xnp_window_compare_func (XnpWindow* self,
187 XnpWindow* win2);
188 void xnp_window_set_window_list (XnpWindow* self,
189 GSList* list);
190 const gchar* xnp_window_get_name (XnpWindow* self);
191 static void xnp_application_load_window_data (XnpApplication* self,
192 XnpWindow* window);
193 static void xnp_application_window_monitor_list_add (XnpApplication* self,
194 XnpWindow* window);
195 static void __lambda25_ (XnpApplication* self,
196 XnpWindow* win,
197 const gchar* action);
198 static void xnp_application_rename_window (XnpApplication* self,
199 XnpWindow* window);
200 static void xnp_application_set_data_value (XnpApplication* self,
201 GObject* object,
202 const gchar* data,
203 gboolean val);
204 static void xnp_application_delete_window (XnpApplication* self,
205 XnpWindow* window);
206 static void xnp_application_refresh_notes (XnpApplication* self,
207 XnpWindow* window);
208 void xnp_application_open_settings_dialog (XnpApplication* self);
209 void xnp_application_open_about_dialog (XnpApplication* self);
210 static void ___lambda25__xnp_window_action (XnpWindow* _sender,
211 const gchar* action,
212 gpointer self);
213 GType xnp_note_get_type (void) G_GNUC_CONST;
214 G_DEFINE_AUTOPTR_CLEANUP_FUNC (XnpNote, g_object_unref)
215 static void __lambda26_ (XnpApplication* self,
216 XnpWindow* win,
217 XnpNote* note);
218 static gboolean xnp_application_get_data_value (XnpApplication* self,
219 GObject* object,
220 const gchar* data);
221 static void xnp_application_save_note (XnpApplication* self,
222 XnpWindow* window,
223 XnpNote* note);
224 static void ___lambda26__xnp_window_save_data (XnpWindow* _sender,
225 XnpNote* note,
226 gpointer self);
227 static void __lambda27_ (XnpApplication* self,
228 XnpWindow* win,
229 XnpNote* note);
230 GType xnp_hypertext_view_get_type (void) G_GNUC_CONST;
231 G_DEFINE_AUTOPTR_CLEANUP_FUNC (XnpHypertextView, g_object_unref)
232 const gchar* xnp_note_get_name (XnpNote* self);
233 static void ___lambda27__xnp_window_note_inserted (XnpWindow* _sender,
234 XnpNote* note,
235 gpointer self);
236 static void __lambda28_ (XnpApplication* self,
237 XnpWindow* win,
238 XnpNote* note);
239 static void ___lambda28__xnp_window_note_deleted (XnpWindow* _sender,
240 XnpNote* note,
241 gpointer self);
242 static void __lambda29_ (XnpApplication* self,
243 XnpWindow* win,
244 XnpNote* note,
245 const gchar* old_name);
246 static gboolean xnp_application_name_is_valid (XnpApplication* self,
247 const gchar* name);
248 void xnp_note_set_name (XnpNote* self,
249 const gchar* value);
250 static void ___lambda29__xnp_window_note_renamed (XnpWindow* _sender,
251 XnpNote* note,
252 const gchar* old_name,
253 gpointer self);
254 XnpNote* xnp_window_insert_note (XnpWindow* self);
255 const gchar* xnp_application_get_config_file (XnpApplication* self);
256 void xnp_window_move_note (XnpWindow* self,
257 const gchar* note_name,
258 gint page);
259 void xnp_window_set_current_page (XnpWindow* self,
260 gint page);
261 void xnp_window_get_geometry (XnpWindow* self,
262 gint* winx,
263 gint* winy,
264 gint* width,
265 gint* height);
266 gchar** xnp_window_get_note_names (XnpWindow* self,
267 gint* result_length1);
268 gint xnp_window_get_current_page (XnpWindow* self);
269 gboolean xnp_window_get_above (XnpWindow* self);
270 gboolean xnp_window_get_sticky (XnpWindow* self);
271 void xnp_window_save_notes (XnpWindow* self);
272 static void xnp_application_window_monitor_list_remove (XnpApplication* self,
273 XnpWindow* window);
274 gint xnp_window_get_n_pages (XnpWindow* self);
275 void xnp_window_set_show_refresh_button (XnpWindow* self,
276 gboolean value);
277 XnpWindowMonitor* xnp_window_monitor_new (XnpWindow* window,
278 GFile* file);
279 XnpWindowMonitor* xnp_window_monitor_construct (GType object_type,
280 XnpWindow* window,
281 GFile* file);
282 static void __lambda24_ (XnpApplication* self,
283 XnpWindow* window);
284 static void ___lambda24__xnp_window_monitor_window_updated (XnpWindowMonitor* _sender,
285 XnpWindow* window,
286 gpointer self);
287 static XnpWindowMonitor* xnp_application_window_monitor_list_lookup (XnpApplication* self,
288 XnpWindow* window);
289 void xnp_application_show_hide_notes (XnpApplication* self);
290 void xnp_window_hide (XnpWindow* self);
291 GtkMenu* xnp_application_context_menu (XnpApplication* self);
292 static Block1Data* block1_data_ref (Block1Data* _data1_);
293 static void block1_data_unref (void * _userdata_);
294 static void __lambda30_ (Block1Data* _data1_);
295 static void __lambda31_ (XnpApplication* self,
296 GtkWidget* w);
297 static void ___lambda31__gtk_callback (GtkWidget* widget,
298 gpointer self);
299 static void ____lambda32_ (XnpApplication* self,
300 GtkMenuItem* i);
301 static void _____lambda32__gtk_menu_item_activate (GtkMenuItem* _sender,
302 gpointer self);
303 static void __lambda33_ (XnpApplication* self);
304 static void ___lambda33__gtk_menu_item_activate (GtkMenuItem* _sender,
305 gpointer self);
306 static void ___lambda30__gtk_widget_show (GtkWidget* _sender,
307 gpointer self);
308 void xnp_application_set_notes_path (XnpApplication* self,
309 const gchar* value);
310 static void xnp_application_set_config_file (XnpApplication* self,
311 const gchar* value);
312 static GObject * xnp_application_constructor (GType type,
313 guint n_construct_properties,
314 GObjectConstructParam * construct_properties);
315 static void _xnp_application_quit_xfce_posix_signal_handler (gint signal,
316 gpointer self);
317 static void _xnp_application___lambda34_ (XnpApplication* self);
318 static void __xnp_application___lambda34__xfconf_g__channel_property_changed (XfconfChannel* _sender,
319 const gchar* property,
320 GValue* value,
321 gpointer self);
322 static void _xnp_application___lambda35_ (XnpApplication* self);
323 static void __xnp_application___lambda35__g_object_notify (GObject* _sender,
324 GParamSpec* pspec,
325 gpointer self);
326 static void _xnp_application___lambda36_ (XnpApplication* self);
327 static void __xnp_application___lambda36__xfconf_g__channel_property_changed (XfconfChannel* _sender,
328 const gchar* property,
329 GValue* value,
330 gpointer self);
331 static void xnp_application_finalize (GObject * obj);
332 static GType xnp_application_get_type_once (void);
333 static void _vala_xnp_application_get_property (GObject * object,
334 guint property_id,
335 GValue * value,
336 GParamSpec * pspec);
337 static void _vala_xnp_application_set_property (GObject * object,
338 guint property_id,
339 const GValue * value,
340 GParamSpec * pspec);
341 static void _vala_array_destroy (gpointer array,
342 gint array_length,
343 GDestroyNotify destroy_func);
344 static void _vala_array_free (gpointer array,
345 gint array_length,
346 GDestroyNotify destroy_func);
347
348 static inline gpointer
xnp_application_get_instance_private(XnpApplication * self)349 xnp_application_get_instance_private (XnpApplication* self)
350 {
351 return G_STRUCT_MEMBER_P (self, XnpApplication_private_offset);
352 }
353
354 static gpointer
_g_object_ref0(gpointer self)355 _g_object_ref0 (gpointer self)
356 {
357 return self ? g_object_ref (self) : NULL;
358 }
359
360 static void
_g_object_unref0_(gpointer var)361 _g_object_unref0_ (gpointer var)
362 {
363 (var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
364 }
365
366 static inline void
_g_slist_free__g_object_unref0_(GSList * self)367 _g_slist_free__g_object_unref0_ (GSList* self)
368 {
369 g_slist_free_full (self, (GDestroyNotify) _g_object_unref0_);
370 }
371
372 XnpApplication*
xnp_application_construct(GType object_type,const gchar * config_file)373 xnp_application_construct (GType object_type,
374 const gchar* config_file)
375 {
376 XnpApplication * self = NULL;
377 g_return_val_if_fail (config_file != NULL, NULL);
378 self = (XnpApplication*) g_object_new (object_type, "config-file", config_file, NULL);
379 return self;
380 }
381
382 XnpApplication*
xnp_application_new(const gchar * config_file)383 xnp_application_new (const gchar* config_file)
384 {
385 return xnp_application_construct (XNP_TYPE_APPLICATION, config_file);
386 }
387
388 XnpApplication*
xnp_application_construct_with_notes_path(GType object_type,const gchar * config_file,const gchar * notes_path)389 xnp_application_construct_with_notes_path (GType object_type,
390 const gchar* config_file,
391 const gchar* notes_path)
392 {
393 XnpApplication * self = NULL;
394 g_return_val_if_fail (config_file != NULL, NULL);
395 g_return_val_if_fail (notes_path != NULL, NULL);
396 self = (XnpApplication*) g_object_new (object_type, "config-file", config_file, "notes-path", notes_path, NULL);
397 return self;
398 }
399
400 XnpApplication*
xnp_application_new_with_notes_path(const gchar * config_file,const gchar * notes_path)401 xnp_application_new_with_notes_path (const gchar* config_file,
402 const gchar* notes_path)
403 {
404 return xnp_application_construct_with_notes_path (XNP_TYPE_APPLICATION, config_file, notes_path);
405 }
406
407 static void
xnp_application_update_notes_path(XnpApplication * self)408 xnp_application_update_notes_path (XnpApplication* self)
409 {
410 gchar* new_notes_path = NULL;
411 XfconfChannel* _tmp0_;
412 const gchar* _tmp1_;
413 gchar* _tmp2_;
414 const gchar* _tmp3_;
415 const gchar* _tmp4_;
416 gchar* dirname = NULL;
417 const gchar* _tmp16_;
418 gchar* _tmp17_;
419 gboolean _tmp18_ = FALSE;
420 const gchar* _tmp19_;
421 GError* _inner_error0_ = NULL;
422 g_return_if_fail (self != NULL);
423 _tmp0_ = self->priv->xfconf_channel;
424 _tmp1_ = self->priv->_notes_path;
425 _tmp2_ = xfconf_channel_get_string (_tmp0_, "/global/notes-path", _tmp1_);
426 new_notes_path = _tmp2_;
427 _tmp3_ = self->priv->_notes_path;
428 _tmp4_ = new_notes_path;
429 if (g_strcmp0 (_tmp3_, _tmp4_) == 0) {
430 _g_free0 (new_notes_path);
431 return;
432 }
433 {
434 GDir* dir = NULL;
435 const gchar* _tmp5_;
436 GDir* _tmp6_;
437 GDir* _tmp7_;
438 const gchar* _tmp8_;
439 _tmp5_ = new_notes_path;
440 _tmp6_ = g_dir_open (_tmp5_, (guint) 0, &_inner_error0_);
441 dir = _tmp6_;
442 if (G_UNLIKELY (_inner_error0_ != NULL)) {
443 goto __catch0_g_error;
444 }
445 _tmp7_ = dir;
446 _tmp8_ = g_dir_read_name (_tmp7_);
447 if (_tmp8_ != NULL) {
448 GtkMessageDialog* error_dialog = NULL;
449 GtkMessageDialog* _tmp9_;
450 GtkMessageDialog* _tmp10_;
451 const gchar* _tmp11_;
452 GtkMessageDialog* _tmp12_;
453 GtkMessageDialog* _tmp13_;
454 XfconfChannel* _tmp14_;
455 const gchar* _tmp15_;
456 _tmp9_ = (GtkMessageDialog*) gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", _ ("Select notes path"));
457 g_object_ref_sink (_tmp9_);
458 error_dialog = _tmp9_;
459 _tmp10_ = error_dialog;
460 _tmp11_ = new_notes_path;
461 gtk_message_dialog_format_secondary_text (_tmp10_, _ ("The selected directory (%s) for the new notes path already contains fi" \
462 "les. You must select or create an empty directory."), _tmp11_);
463 _tmp12_ = error_dialog;
464 gtk_dialog_run ((GtkDialog*) _tmp12_);
465 _tmp13_ = error_dialog;
466 gtk_widget_destroy ((GtkWidget*) _tmp13_);
467 _tmp14_ = self->priv->xfconf_channel;
468 _tmp15_ = self->priv->_notes_path;
469 xfconf_channel_set_string (_tmp14_, "/global/notes-path", _tmp15_);
470 _g_object_unref0 (error_dialog);
471 _g_dir_close0 (dir);
472 _g_free0 (new_notes_path);
473 return;
474 }
475 _g_dir_close0 (dir);
476 }
477 goto __finally0;
478 __catch0_g_error:
479 {
480 g_clear_error (&_inner_error0_);
481 }
482 __finally0:
483 if (G_UNLIKELY (_inner_error0_ != NULL)) {
484 _g_free0 (new_notes_path);
485 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);
486 g_clear_error (&_inner_error0_);
487 return;
488 }
489 _tmp16_ = new_notes_path;
490 _tmp17_ = g_path_get_dirname (_tmp16_);
491 dirname = _tmp17_;
492 _tmp19_ = dirname;
493 if (g_mkdir_with_parents (_tmp19_, 0700) != 0) {
494 _tmp18_ = TRUE;
495 } else {
496 const gchar* _tmp20_;
497 const gchar* _tmp21_;
498 _tmp20_ = self->priv->_notes_path;
499 _tmp21_ = new_notes_path;
500 _tmp18_ = g_rename (_tmp20_, _tmp21_) != 0;
501 }
502 if (_tmp18_) {
503 GtkMessageDialog* error_dialog = NULL;
504 GtkMessageDialog* _tmp22_;
505 GtkMessageDialog* _tmp23_;
506 const gchar* _tmp24_;
507 GtkMessageDialog* _tmp25_;
508 GtkMessageDialog* _tmp26_;
509 XfconfChannel* _tmp27_;
510 const gchar* _tmp28_;
511 _tmp22_ = (GtkMessageDialog*) gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", _ ("Select notes path"));
512 g_object_ref_sink (_tmp22_);
513 error_dialog = _tmp22_;
514 _tmp23_ = error_dialog;
515 _tmp24_ = g_strerror (errno);
516 gtk_message_dialog_format_secondary_text (_tmp23_, _ ("Unable to select directory for new notes path: %s"), _tmp24_);
517 _tmp25_ = error_dialog;
518 gtk_dialog_run ((GtkDialog*) _tmp25_);
519 _tmp26_ = error_dialog;
520 gtk_widget_destroy ((GtkWidget*) _tmp26_);
521 _tmp27_ = self->priv->xfconf_channel;
522 _tmp28_ = self->priv->_notes_path;
523 xfconf_channel_set_string (_tmp27_, "/global/notes-path", _tmp28_);
524 _g_object_unref0 (error_dialog);
525 _g_free0 (dirname);
526 _g_free0 (new_notes_path);
527 return;
528 }
529 _g_free0 (dirname);
530 _g_free0 (new_notes_path);
531 }
532
533 static void
xnp_application_update_color(XnpApplication * self)534 xnp_application_update_color (XnpApplication* self)
535 {
536 gchar* color = NULL;
537 XfconfChannel* _tmp0_;
538 gchar* _tmp1_;
539 const gchar* _tmp2_;
540 const gchar* _tmp3_;
541 g_return_if_fail (self != NULL);
542 _tmp0_ = self->priv->xfconf_channel;
543 _tmp1_ = xfconf_channel_get_string (_tmp0_, "/global/background-color", "#F7EB96");
544 color = _tmp1_;
545 _tmp2_ = color;
546 if (g_strcmp0 (_tmp2_, "GTK+") == 0) {
547 _g_free0 (color);
548 return;
549 }
550 _tmp3_ = color;
551 xnp_theme_set_background_color (_tmp3_);
552 _g_free0 (color);
553 }
554
555 static void
xnp_application_quit(XnpApplication * self)556 xnp_application_quit (XnpApplication* self)
557 {
558 g_return_if_fail (self != NULL);
559 xnp_application_save_notes (self);
560 gtk_main_quit ();
561 }
562
563 /**
564 * create_window:
565 *
566 * Creates a new Xnp.Window and stores it inside window_list.
567 * If a name is given, it assumes it can load existing notes.
568 */
569 static void
__lambda25_(XnpApplication * self,XnpWindow * win,const gchar * action)570 __lambda25_ (XnpApplication* self,
571 XnpWindow* win,
572 const gchar* action)
573 {
574 g_return_if_fail (win != NULL);
575 g_return_if_fail (action != NULL);
576 if (g_strcmp0 (action, "rename") == 0) {
577 xnp_application_rename_window (self, win);
578 xnp_application_set_data_value (self, (GObject*) win, "internal-change", TRUE);
579 } else {
580 if (g_strcmp0 (action, "delete") == 0) {
581 xnp_application_delete_window (self, win);
582 xnp_application_set_data_value (self, (GObject*) win, "internal-change", TRUE);
583 } else {
584 if (g_strcmp0 (action, "create-new-window") == 0) {
585 XnpWindow* new_win = NULL;
586 XnpWindow* _tmp0_;
587 XnpWindow* _tmp1_;
588 _tmp0_ = xnp_application_create_window (self, NULL);
589 new_win = _tmp0_;
590 _tmp1_ = new_win;
591 gtk_widget_show ((GtkWidget*) _tmp1_);
592 xnp_application_set_data_value (self, (GObject*) win, "internal-change", TRUE);
593 _g_object_unref0 (new_win);
594 } else {
595 if (g_strcmp0 (action, "refresh-notes") == 0) {
596 xnp_application_refresh_notes (self, win);
597 } else {
598 if (g_strcmp0 (action, "properties") == 0) {
599 xnp_application_open_settings_dialog (self);
600 } else {
601 if (g_strcmp0 (action, "about") == 0) {
602 xnp_application_open_about_dialog (self);
603 }
604 }
605 }
606 }
607 }
608 }
609 }
610
611 static void
___lambda25__xnp_window_action(XnpWindow * _sender,const gchar * action,gpointer self)612 ___lambda25__xnp_window_action (XnpWindow* _sender,
613 const gchar* action,
614 gpointer self)
615 {
616 __lambda25_ ((XnpApplication*) self, _sender, action);
617 }
618
619 static void
__lambda26_(XnpApplication * self,XnpWindow * win,XnpNote * note)620 __lambda26_ (XnpApplication* self,
621 XnpWindow* win,
622 XnpNote* note)
623 {
624 g_return_if_fail (win != NULL);
625 g_return_if_fail (note != NULL);
626 if (!xnp_application_get_data_value (self, (GObject*) win, "external-change")) {
627 xnp_application_set_data_value (self, (GObject*) win, "internal-change", TRUE);
628 xnp_application_save_note (self, win, note);
629 }
630 }
631
632 static void
___lambda26__xnp_window_save_data(XnpWindow * _sender,XnpNote * note,gpointer self)633 ___lambda26__xnp_window_save_data (XnpWindow* _sender,
634 XnpNote* note,
635 gpointer self)
636 {
637 __lambda26_ ((XnpApplication*) self, _sender, note);
638 }
639
640 static void
__lambda27_(XnpApplication * self,XnpWindow * win,XnpNote * note)641 __lambda27_ (XnpApplication* self,
642 XnpWindow* win,
643 XnpNote* note)
644 {
645 XfconfChannel* _tmp0_;
646 XnpHypertextView* _tmp1_;
647 gchar* path = NULL;
648 const gchar* _tmp2_;
649 const gchar* _tmp3_;
650 const gchar* _tmp4_;
651 const gchar* _tmp5_;
652 const gchar* _tmp6_;
653 gchar* _tmp7_;
654 GError* _inner_error0_ = NULL;
655 g_return_if_fail (win != NULL);
656 g_return_if_fail (note != NULL);
657 _tmp0_ = self->priv->xfconf_channel;
658 _tmp1_ = note->text_view;
659 xfconf_g_property_bind (_tmp0_, "/global/font-description", G_TYPE_STRING, _tmp1_, "font");
660 _tmp2_ = self->priv->_notes_path;
661 _tmp3_ = xnp_window_get_name (win);
662 _tmp4_ = _tmp3_;
663 _tmp5_ = xnp_note_get_name (note);
664 _tmp6_ = _tmp5_;
665 _tmp7_ = g_strdup_printf ("%s/%s/%s", _tmp2_, _tmp4_, _tmp6_);
666 path = _tmp7_;
667 {
668 g_file_set_contents (path, "", (gssize) -1, &_inner_error0_);
669 if (G_UNLIKELY (_inner_error0_ != NULL)) {
670 if (_inner_error0_->domain == G_FILE_ERROR) {
671 goto __catch0_g_file_error;
672 }
673 _g_free0 (path);
674 g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
675 g_clear_error (&_inner_error0_);
676 return;
677 }
678 xnp_application_set_data_value (self, (GObject*) win, "internal-change", TRUE);
679 }
680 goto __finally0;
681 __catch0_g_file_error:
682 {
683 g_clear_error (&_inner_error0_);
684 }
685 __finally0:
686 if (G_UNLIKELY (_inner_error0_ != NULL)) {
687 _g_free0 (path);
688 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);
689 g_clear_error (&_inner_error0_);
690 return;
691 }
692 _g_free0 (path);
693 }
694
695 static void
___lambda27__xnp_window_note_inserted(XnpWindow * _sender,XnpNote * note,gpointer self)696 ___lambda27__xnp_window_note_inserted (XnpWindow* _sender,
697 XnpNote* note,
698 gpointer self)
699 {
700 __lambda27_ ((XnpApplication*) self, _sender, note);
701 }
702
703 static void
__lambda28_(XnpApplication * self,XnpWindow * win,XnpNote * note)704 __lambda28_ (XnpApplication* self,
705 XnpWindow* win,
706 XnpNote* note)
707 {
708 gchar* path = NULL;
709 const gchar* _tmp0_;
710 const gchar* _tmp1_;
711 const gchar* _tmp2_;
712 const gchar* _tmp3_;
713 const gchar* _tmp4_;
714 gchar* _tmp5_;
715 g_return_if_fail (win != NULL);
716 g_return_if_fail (note != NULL);
717 _tmp0_ = self->priv->_notes_path;
718 _tmp1_ = xnp_window_get_name (win);
719 _tmp2_ = _tmp1_;
720 _tmp3_ = xnp_note_get_name (note);
721 _tmp4_ = _tmp3_;
722 _tmp5_ = g_strdup_printf ("%s/%s/%s", _tmp0_, _tmp2_, _tmp4_);
723 path = _tmp5_;
724 g_unlink (path);
725 xnp_application_set_data_value (self, (GObject*) win, "internal-change", TRUE);
726 _g_free0 (path);
727 }
728
729 static void
___lambda28__xnp_window_note_deleted(XnpWindow * _sender,XnpNote * note,gpointer self)730 ___lambda28__xnp_window_note_deleted (XnpWindow* _sender,
731 XnpNote* note,
732 gpointer self)
733 {
734 __lambda28_ ((XnpApplication*) self, _sender, note);
735 }
736
737 static void
__lambda29_(XnpApplication * self,XnpWindow * win,XnpNote * note,const gchar * old_name)738 __lambda29_ (XnpApplication* self,
739 XnpWindow* win,
740 XnpNote* note,
741 const gchar* old_name)
742 {
743 const gchar* _tmp0_;
744 const gchar* _tmp1_;
745 gchar* old_path = NULL;
746 const gchar* _tmp2_;
747 const gchar* _tmp3_;
748 const gchar* _tmp4_;
749 gchar* _tmp5_;
750 gchar* new_path = NULL;
751 const gchar* _tmp6_;
752 const gchar* _tmp7_;
753 const gchar* _tmp8_;
754 const gchar* _tmp9_;
755 const gchar* _tmp10_;
756 gchar* _tmp11_;
757 const gchar* _tmp12_;
758 const gchar* _tmp13_;
759 g_return_if_fail (win != NULL);
760 g_return_if_fail (note != NULL);
761 g_return_if_fail (old_name != NULL);
762 _tmp0_ = xnp_note_get_name (note);
763 _tmp1_ = _tmp0_;
764 if (!xnp_application_name_is_valid (self, _tmp1_)) {
765 xnp_note_set_name (note, old_name);
766 return;
767 }
768 _tmp2_ = self->priv->_notes_path;
769 _tmp3_ = xnp_window_get_name (win);
770 _tmp4_ = _tmp3_;
771 _tmp5_ = g_strdup_printf ("%s/%s/%s", _tmp2_, _tmp4_, old_name);
772 old_path = _tmp5_;
773 _tmp6_ = self->priv->_notes_path;
774 _tmp7_ = xnp_window_get_name (win);
775 _tmp8_ = _tmp7_;
776 _tmp9_ = xnp_note_get_name (note);
777 _tmp10_ = _tmp9_;
778 _tmp11_ = g_strdup_printf ("%s/%s/%s", _tmp6_, _tmp8_, _tmp10_);
779 new_path = _tmp11_;
780 _tmp12_ = old_path;
781 _tmp13_ = new_path;
782 g_rename (_tmp12_, _tmp13_);
783 xnp_application_set_data_value (self, (GObject*) win, "internal-change", TRUE);
784 _g_free0 (new_path);
785 _g_free0 (old_path);
786 }
787
788 static void
___lambda29__xnp_window_note_renamed(XnpWindow * _sender,XnpNote * note,const gchar * old_name,gpointer self)789 ___lambda29__xnp_window_note_renamed (XnpWindow* _sender,
790 XnpNote* note,
791 const gchar* old_name,
792 gpointer self)
793 {
794 __lambda29_ ((XnpApplication*) self, _sender, note, old_name);
795 }
796
797 XnpWindow*
xnp_application_create_window(XnpApplication * self,const gchar * name)798 xnp_application_create_window (XnpApplication* self,
799 const gchar* name)
800 {
801 XnpWindow* window = NULL;
802 XnpWindow* _tmp0_;
803 XnpWindow* _tmp18_;
804 XnpWindow* _tmp19_;
805 XnpWindow* _tmp20_;
806 GSList* _tmp21_;
807 gchar* window_path = NULL;
808 const gchar* _tmp25_;
809 XnpWindow* _tmp26_;
810 const gchar* _tmp27_;
811 const gchar* _tmp28_;
812 gchar* _tmp29_;
813 gboolean _tmp30_ = FALSE;
814 XnpWindow* _tmp40_;
815 XfconfChannel* _tmp41_;
816 XnpWindow* _tmp42_;
817 XfconfChannel* _tmp43_;
818 XnpWindow* _tmp44_;
819 XnpWindow* _tmp45_;
820 XnpWindow* _tmp46_;
821 XnpWindow* _tmp47_;
822 XnpWindow* _tmp48_;
823 XnpWindow* _tmp49_;
824 GError* _inner_error0_ = NULL;
825 XnpWindow* result = NULL;
826 g_return_val_if_fail (self != NULL, NULL);
827 _tmp0_ = xnp_window_new ();
828 g_object_ref_sink (_tmp0_);
829 window = _tmp0_;
830 if (name == NULL) {
831 XnpWindow* _tmp1_;
832 XfconfChannel* _tmp2_;
833 XnpWindow* _tmp3_;
834 XfconfChannel* _tmp4_;
835 gint width = 0;
836 XfconfChannel* _tmp5_;
837 gint height = 0;
838 XfconfChannel* _tmp6_;
839 gboolean _tmp7_ = FALSE;
840 _tmp1_ = window;
841 _tmp2_ = self->priv->xfconf_channel;
842 xnp_window_set_above (_tmp1_, xfconf_channel_get_bool (_tmp2_, "/new-window/always-on-top", FALSE));
843 _tmp3_ = window;
844 _tmp4_ = self->priv->xfconf_channel;
845 xnp_window_set_sticky (_tmp3_, xfconf_channel_get_bool (_tmp4_, "/new-window/sticky", TRUE));
846 _tmp5_ = self->priv->xfconf_channel;
847 width = (gint) xfconf_channel_get_int (_tmp5_, "/new-window/width", (gint32) 0);
848 _tmp6_ = self->priv->xfconf_channel;
849 height = (gint) xfconf_channel_get_int (_tmp6_, "/new-window/height", (gint32) 0);
850 if (width > 0) {
851 _tmp7_ = height > 0;
852 } else {
853 _tmp7_ = FALSE;
854 }
855 if (_tmp7_) {
856 XnpWindow* _tmp8_;
857 _tmp8_ = window;
858 gtk_window_resize ((GtkWindow*) _tmp8_, width, height);
859 }
860 }
861 if (name == NULL) {
862 gchar* window_name = NULL;
863 gchar* _tmp9_;
864 gint len = 0;
865 GSList* _tmp10_;
866 XnpWindow* _tmp15_;
867 const gchar* _tmp16_;
868 _tmp9_ = g_strdup (_ ("Notes"));
869 window_name = _tmp9_;
870 _tmp10_ = self->priv->window_list;
871 len = (gint) g_slist_length (_tmp10_);
872 {
873 gint id = 0;
874 id = 1;
875 {
876 gboolean _tmp11_ = FALSE;
877 _tmp11_ = TRUE;
878 while (TRUE) {
879 const gchar* _tmp14_;
880 if (!_tmp11_) {
881 gint _tmp12_;
882 _tmp12_ = id;
883 id = _tmp12_ + 1;
884 }
885 _tmp11_ = FALSE;
886 if (!(id <= (len + 1))) {
887 break;
888 }
889 if (id > 1) {
890 gchar* _tmp13_;
891 _tmp13_ = g_strdup_printf (_ ("Notes %d"), id);
892 _g_free0 (window_name);
893 window_name = _tmp13_;
894 }
895 _tmp14_ = window_name;
896 if (!xnp_application_window_name_exists (self, _tmp14_)) {
897 break;
898 }
899 }
900 }
901 }
902 _tmp15_ = window;
903 _tmp16_ = window_name;
904 xnp_window_set_name (_tmp15_, _tmp16_);
905 _g_free0 (window_name);
906 } else {
907 XnpWindow* _tmp17_;
908 _tmp17_ = window;
909 xnp_window_set_name (_tmp17_, name);
910 }
911 _tmp18_ = window;
912 _tmp19_ = _g_object_ref0 (_tmp18_);
913 _tmp20_ = window;
914 self->priv->window_list = g_slist_insert_sorted (self->priv->window_list, _tmp19_, (GCompareFunc) xnp_window_compare_func);
915 _tmp21_ = self->priv->window_list;
916 {
917 GSList* win_collection = NULL;
918 GSList* win_it = NULL;
919 win_collection = _tmp21_;
920 for (win_it = win_collection; win_it != NULL; win_it = win_it->next) {
921 XnpWindow* _tmp22_;
922 XnpWindow* win = NULL;
923 _tmp22_ = _g_object_ref0 ((XnpWindow*) win_it->data);
924 win = _tmp22_;
925 {
926 XnpWindow* _tmp23_;
927 GSList* _tmp24_;
928 _tmp23_ = win;
929 _tmp24_ = self->priv->window_list;
930 xnp_window_set_window_list (_tmp23_, _tmp24_);
931 _g_object_unref0 (win);
932 }
933 }
934 }
935 _tmp25_ = self->priv->_notes_path;
936 _tmp26_ = window;
937 _tmp27_ = xnp_window_get_name (_tmp26_);
938 _tmp28_ = _tmp27_;
939 _tmp29_ = g_strdup_printf ("%s/%s", _tmp25_, _tmp28_);
940 window_path = _tmp29_;
941 if (name == NULL) {
942 _tmp30_ = TRUE;
943 } else {
944 const gchar* _tmp31_;
945 _tmp31_ = window_path;
946 _tmp30_ = !g_file_test (_tmp31_, G_FILE_TEST_IS_DIR | G_FILE_TEST_EXISTS);
947 }
948 if (_tmp30_) {
949 {
950 const gchar* _tmp32_;
951 gchar* note_path = NULL;
952 const gchar* _tmp33_;
953 gchar* _tmp34_;
954 const gchar* _tmp35_;
955 XnpWindow* _tmp36_;
956 _tmp32_ = window_path;
957 g_mkdir_with_parents (_tmp32_, 0700);
958 _tmp33_ = window_path;
959 _tmp34_ = g_strdup_printf ("%s/%s", _tmp33_, _ ("Notes"));
960 note_path = _tmp34_;
961 _tmp35_ = note_path;
962 g_file_set_contents (_tmp35_, "", (gssize) -1, &_inner_error0_);
963 if (G_UNLIKELY (_inner_error0_ != NULL)) {
964 _g_free0 (note_path);
965 if (_inner_error0_->domain == G_FILE_ERROR) {
966 goto __catch0_g_file_error;
967 }
968 _g_free0 (window_path);
969 _g_object_unref0 (window);
970 g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
971 g_clear_error (&_inner_error0_);
972 return NULL;
973 }
974 _tmp36_ = window;
975 xnp_application_load_window_data (self, _tmp36_);
976 _g_free0 (note_path);
977 }
978 goto __finally0;
979 __catch0_g_file_error:
980 {
981 GError* e = NULL;
982 GError* _tmp37_;
983 const gchar* _tmp38_;
984 e = _inner_error0_;
985 _inner_error0_ = NULL;
986 _tmp37_ = e;
987 _tmp38_ = _tmp37_->message;
988 g_critical ("application.vala:213: Unable to initialize a notes group: %s", _tmp38_);
989 _g_error_free0 (e);
990 }
991 __finally0:
992 if (G_UNLIKELY (_inner_error0_ != NULL)) {
993 _g_free0 (window_path);
994 _g_object_unref0 (window);
995 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);
996 g_clear_error (&_inner_error0_);
997 return NULL;
998 }
999 } else {
1000 XnpWindow* _tmp39_;
1001 _tmp39_ = window;
1002 xnp_application_load_window_data (self, _tmp39_);
1003 }
1004 _tmp40_ = window;
1005 xnp_application_window_monitor_list_add (self, _tmp40_);
1006 _tmp41_ = self->priv->xfconf_channel;
1007 _tmp42_ = window;
1008 xfconf_g_property_bind (_tmp41_, "/global/skip-taskbar-hint", G_TYPE_BOOLEAN, _tmp42_, "skip-taskbar-hint");
1009 _tmp43_ = self->priv->xfconf_channel;
1010 _tmp44_ = window;
1011 xfconf_g_property_bind (_tmp43_, "/global/tabs-position", G_TYPE_INT, _tmp44_, "tabs-position");
1012 _tmp45_ = window;
1013 g_signal_connect_object (_tmp45_, "action", (GCallback) ___lambda25__xnp_window_action, self, 0);
1014 _tmp46_ = window;
1015 g_signal_connect_object (_tmp46_, "save-data", (GCallback) ___lambda26__xnp_window_save_data, self, 0);
1016 _tmp47_ = window;
1017 g_signal_connect_object (_tmp47_, "note-inserted", (GCallback) ___lambda27__xnp_window_note_inserted, self, 0);
1018 _tmp48_ = window;
1019 g_signal_connect_object (_tmp48_, "note-deleted", (GCallback) ___lambda28__xnp_window_note_deleted, self, 0);
1020 _tmp49_ = window;
1021 g_signal_connect_object (_tmp49_, "note-renamed", (GCallback) ___lambda29__xnp_window_note_renamed, self, 0);
1022 result = window;
1023 _g_free0 (window_path);
1024 return result;
1025 }
1026
1027 /**
1028 * load_window_data:
1029 *
1030 * Load existing notes and configuration inside the window.
1031 */
1032 static void
xnp_application_load_window_data(XnpApplication * self,XnpWindow * window)1033 xnp_application_load_window_data (XnpApplication* self,
1034 XnpWindow* window)
1035 {
1036 gchar* name = NULL;
1037 gchar* path = NULL;
1038 const gchar* _tmp0_;
1039 const gchar* _tmp1_;
1040 const gchar* _tmp2_;
1041 gchar* _tmp3_;
1042 GKeyFile* keyfile = NULL;
1043 GKeyFile* _tmp34_;
1044 GError* _inner_error0_ = NULL;
1045 g_return_if_fail (self != NULL);
1046 g_return_if_fail (window != NULL);
1047 _tmp0_ = self->priv->_notes_path;
1048 _tmp1_ = xnp_window_get_name (window);
1049 _tmp2_ = _tmp1_;
1050 _tmp3_ = g_strdup_printf ("%s/%s", _tmp0_, _tmp2_);
1051 path = _tmp3_;
1052 {
1053 GDir* dir = NULL;
1054 const gchar* _tmp4_;
1055 GDir* _tmp5_;
1056 _tmp4_ = path;
1057 _tmp5_ = g_dir_open (_tmp4_, (guint) 0, &_inner_error0_);
1058 dir = _tmp5_;
1059 if (G_UNLIKELY (_inner_error0_ != NULL)) {
1060 if (_inner_error0_->domain == G_FILE_ERROR) {
1061 goto __catch0_g_file_error;
1062 }
1063 _g_free0 (path);
1064 _g_free0 (name);
1065 g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
1066 g_clear_error (&_inner_error0_);
1067 return;
1068 }
1069 while (TRUE) {
1070 GDir* _tmp6_;
1071 const gchar* _tmp7_;
1072 gchar* _tmp8_;
1073 const gchar* _tmp9_;
1074 _tmp6_ = dir;
1075 _tmp7_ = g_dir_read_name (_tmp6_);
1076 _tmp8_ = g_strdup (_tmp7_);
1077 _g_free0 (name);
1078 name = _tmp8_;
1079 _tmp9_ = name;
1080 if (!(_tmp9_ != NULL)) {
1081 break;
1082 }
1083 {
1084 gchar* contents = NULL;
1085 GFile* file = NULL;
1086 const gchar* _tmp10_;
1087 const gchar* _tmp11_;
1088 gchar* _tmp12_;
1089 gchar* _tmp13_;
1090 GFile* _tmp14_;
1091 GFile* _tmp15_;
1092 GFile* _tmp16_;
1093 gchar* _tmp17_;
1094 gchar* _tmp18_;
1095 gchar* _tmp19_ = NULL;
1096 XnpNote* note = NULL;
1097 XnpNote* _tmp20_;
1098 XnpNote* _tmp21_;
1099 const gchar* _tmp22_;
1100 GtkTextBuffer* buffer = NULL;
1101 XnpNote* _tmp23_;
1102 XnpHypertextView* _tmp24_;
1103 GtkTextBuffer* _tmp25_;
1104 GtkTextBuffer* _tmp26_;
1105 GtkTextBuffer* _tmp27_;
1106 const gchar* _tmp28_;
1107 XfconfChannel* _tmp29_;
1108 XnpNote* _tmp30_;
1109 XnpHypertextView* _tmp31_;
1110 _tmp10_ = path;
1111 _tmp11_ = name;
1112 _tmp12_ = g_strdup_printf ("%s/%s", _tmp10_, _tmp11_);
1113 _tmp13_ = _tmp12_;
1114 _tmp14_ = g_file_new_for_path (_tmp13_);
1115 _tmp15_ = _tmp14_;
1116 _g_free0 (_tmp13_);
1117 file = _tmp15_;
1118 _tmp16_ = file;
1119 _tmp17_ = g_file_get_path (_tmp16_);
1120 _tmp18_ = _tmp17_;
1121 g_file_get_contents (_tmp18_, &_tmp19_, NULL, &_inner_error0_);
1122 _g_free0 (contents);
1123 contents = _tmp19_;
1124 _g_free0 (_tmp18_);
1125 if (G_UNLIKELY (_inner_error0_ != NULL)) {
1126 _g_object_unref0 (file);
1127 _g_free0 (contents);
1128 if (_inner_error0_->domain == G_FILE_ERROR) {
1129 goto __catch1_g_file_error;
1130 }
1131 _g_dir_close0 (dir);
1132 _g_free0 (path);
1133 _g_free0 (name);
1134 g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
1135 g_clear_error (&_inner_error0_);
1136 return;
1137 }
1138 _tmp20_ = xnp_window_insert_note (window);
1139 note = _tmp20_;
1140 _tmp21_ = note;
1141 _tmp22_ = name;
1142 xnp_note_set_name (_tmp21_, _tmp22_);
1143 _tmp23_ = note;
1144 _tmp24_ = _tmp23_->text_view;
1145 _tmp25_ = gtk_text_view_get_buffer ((GtkTextView*) _tmp24_);
1146 _tmp26_ = _g_object_ref0 (_tmp25_);
1147 buffer = _tmp26_;
1148 _tmp27_ = buffer;
1149 _tmp28_ = contents;
1150 gtk_text_buffer_set_text (_tmp27_, _tmp28_, -1);
1151 _tmp29_ = self->priv->xfconf_channel;
1152 _tmp30_ = note;
1153 _tmp31_ = _tmp30_->text_view;
1154 xfconf_g_property_bind (_tmp29_, "/global/font-description", G_TYPE_STRING, _tmp31_, "font");
1155 _g_object_unref0 (buffer);
1156 _g_object_unref0 (note);
1157 _g_object_unref0 (file);
1158 _g_free0 (contents);
1159 }
1160 goto __finally1;
1161 __catch1_g_file_error:
1162 {
1163 GError* e = NULL;
1164 GError* _tmp32_;
1165 const gchar* _tmp33_;
1166 e = _inner_error0_;
1167 _inner_error0_ = NULL;
1168 _tmp32_ = e;
1169 _tmp33_ = _tmp32_->message;
1170 g_warning ("application.vala:315: %s", _tmp33_);
1171 _g_error_free0 (e);
1172 }
1173 __finally1:
1174 if (G_UNLIKELY (_inner_error0_ != NULL)) {
1175 _g_dir_close0 (dir);
1176 if (_inner_error0_->domain == G_FILE_ERROR) {
1177 goto __catch0_g_file_error;
1178 }
1179 _g_free0 (path);
1180 _g_free0 (name);
1181 g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
1182 g_clear_error (&_inner_error0_);
1183 return;
1184 }
1185 }
1186 _g_dir_close0 (dir);
1187 }
1188 goto __finally0;
1189 __catch0_g_file_error:
1190 {
1191 g_clear_error (&_inner_error0_);
1192 }
1193 __finally0:
1194 if (G_UNLIKELY (_inner_error0_ != NULL)) {
1195 _g_free0 (path);
1196 _g_free0 (name);
1197 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);
1198 g_clear_error (&_inner_error0_);
1199 return;
1200 }
1201 _tmp34_ = g_key_file_new ();
1202 keyfile = _tmp34_;
1203 {
1204 GKeyFile* _tmp35_;
1205 const gchar* _tmp36_;
1206 gint winx = 0;
1207 GKeyFile* _tmp37_;
1208 const gchar* _tmp38_;
1209 const gchar* _tmp39_;
1210 gint winy = 0;
1211 GKeyFile* _tmp40_;
1212 const gchar* _tmp41_;
1213 const gchar* _tmp42_;
1214 gint width = 0;
1215 GKeyFile* _tmp43_;
1216 const gchar* _tmp44_;
1217 const gchar* _tmp45_;
1218 gint height = 0;
1219 GKeyFile* _tmp46_;
1220 const gchar* _tmp47_;
1221 const gchar* _tmp48_;
1222 gchar** tabs_order = NULL;
1223 GKeyFile* _tmp49_;
1224 const gchar* _tmp50_;
1225 const gchar* _tmp51_;
1226 gsize _tmp52_ = 0;
1227 gchar** _tmp53_;
1228 gint tabs_order_length1;
1229 gint _tabs_order_size_;
1230 gint last_page = 0;
1231 GKeyFile* _tmp54_;
1232 const gchar* _tmp55_;
1233 const gchar* _tmp56_;
1234 gboolean above = FALSE;
1235 GKeyFile* _tmp57_;
1236 const gchar* _tmp58_;
1237 const gchar* _tmp59_;
1238 gboolean sticky = FALSE;
1239 GKeyFile* _tmp60_;
1240 const gchar* _tmp61_;
1241 const gchar* _tmp62_;
1242 gint _tmp63_ = 0;
1243 GKeyFile* _tmp64_;
1244 const gchar* _tmp65_;
1245 const gchar* _tmp66_;
1246 gdouble opacity = 0.0;
1247 gboolean visible = FALSE;
1248 GKeyFile* _tmp67_;
1249 const gchar* _tmp68_;
1250 const gchar* _tmp69_;
1251 _tmp35_ = keyfile;
1252 _tmp36_ = self->priv->_config_file;
1253 g_key_file_load_from_file (_tmp35_, _tmp36_, G_KEY_FILE_NONE, &_inner_error0_);
1254 if (G_UNLIKELY (_inner_error0_ != NULL)) {
1255 goto __catch2_g_error;
1256 }
1257 _tmp37_ = keyfile;
1258 _tmp38_ = xnp_window_get_name (window);
1259 _tmp39_ = _tmp38_;
1260 winx = g_key_file_get_integer (_tmp37_, _tmp39_, "PosX", &_inner_error0_);
1261 if (G_UNLIKELY (_inner_error0_ != NULL)) {
1262 goto __catch2_g_error;
1263 }
1264 _tmp40_ = keyfile;
1265 _tmp41_ = xnp_window_get_name (window);
1266 _tmp42_ = _tmp41_;
1267 winy = g_key_file_get_integer (_tmp40_, _tmp42_, "PosY", &_inner_error0_);
1268 if (G_UNLIKELY (_inner_error0_ != NULL)) {
1269 goto __catch2_g_error;
1270 }
1271 _tmp43_ = keyfile;
1272 _tmp44_ = xnp_window_get_name (window);
1273 _tmp45_ = _tmp44_;
1274 width = g_key_file_get_integer (_tmp43_, _tmp45_, "Width", &_inner_error0_);
1275 if (G_UNLIKELY (_inner_error0_ != NULL)) {
1276 goto __catch2_g_error;
1277 }
1278 _tmp46_ = keyfile;
1279 _tmp47_ = xnp_window_get_name (window);
1280 _tmp48_ = _tmp47_;
1281 height = g_key_file_get_integer (_tmp46_, _tmp48_, "Height", &_inner_error0_);
1282 if (G_UNLIKELY (_inner_error0_ != NULL)) {
1283 goto __catch2_g_error;
1284 }
1285 _tmp49_ = keyfile;
1286 _tmp50_ = xnp_window_get_name (window);
1287 _tmp51_ = _tmp50_;
1288 _tmp53_ = g_key_file_get_string_list (_tmp49_, _tmp51_, "TabsOrder", &_tmp52_, &_inner_error0_);
1289 tabs_order = _tmp53_;
1290 tabs_order_length1 = _tmp52_;
1291 _tabs_order_size_ = tabs_order_length1;
1292 if (G_UNLIKELY (_inner_error0_ != NULL)) {
1293 goto __catch2_g_error;
1294 }
1295 _tmp54_ = keyfile;
1296 _tmp55_ = xnp_window_get_name (window);
1297 _tmp56_ = _tmp55_;
1298 last_page = g_key_file_get_integer (_tmp54_, _tmp56_, "LastTab", &_inner_error0_);
1299 if (G_UNLIKELY (_inner_error0_ != NULL)) {
1300 tabs_order = (_vala_array_free (tabs_order, tabs_order_length1, (GDestroyNotify) g_free), NULL);
1301 goto __catch2_g_error;
1302 }
1303 _tmp57_ = keyfile;
1304 _tmp58_ = xnp_window_get_name (window);
1305 _tmp59_ = _tmp58_;
1306 above = g_key_file_get_boolean (_tmp57_, _tmp59_, "Above", &_inner_error0_);
1307 if (G_UNLIKELY (_inner_error0_ != NULL)) {
1308 tabs_order = (_vala_array_free (tabs_order, tabs_order_length1, (GDestroyNotify) g_free), NULL);
1309 goto __catch2_g_error;
1310 }
1311 _tmp60_ = keyfile;
1312 _tmp61_ = xnp_window_get_name (window);
1313 _tmp62_ = _tmp61_;
1314 sticky = g_key_file_get_boolean (_tmp60_, _tmp62_, "Sticky", &_inner_error0_);
1315 if (G_UNLIKELY (_inner_error0_ != NULL)) {
1316 tabs_order = (_vala_array_free (tabs_order, tabs_order_length1, (GDestroyNotify) g_free), NULL);
1317 goto __catch2_g_error;
1318 }
1319 _tmp64_ = keyfile;
1320 _tmp65_ = xnp_window_get_name (window);
1321 _tmp66_ = _tmp65_;
1322 _tmp63_ = g_key_file_get_integer (_tmp64_, _tmp66_, "Transparency", &_inner_error0_);
1323 if (G_UNLIKELY (_inner_error0_ != NULL)) {
1324 tabs_order = (_vala_array_free (tabs_order, tabs_order_length1, (GDestroyNotify) g_free), NULL);
1325 goto __catch2_g_error;
1326 }
1327 opacity = 1 - (((gdouble) _tmp63_) / 100);
1328 _tmp67_ = keyfile;
1329 _tmp68_ = xnp_window_get_name (window);
1330 _tmp69_ = _tmp68_;
1331 visible = g_key_file_get_boolean (_tmp67_, _tmp69_, "Visible", &_inner_error0_);
1332 if (G_UNLIKELY (_inner_error0_ != NULL)) {
1333 tabs_order = (_vala_array_free (tabs_order, tabs_order_length1, (GDestroyNotify) g_free), NULL);
1334 goto __catch2_g_error;
1335 }
1336 gtk_window_move ((GtkWindow*) window, winx, winy);
1337 gtk_window_resize ((GtkWindow*) window, width, height);
1338 {
1339 gint i = 0;
1340 i = 0;
1341 {
1342 gboolean _tmp70_ = FALSE;
1343 _tmp70_ = TRUE;
1344 while (TRUE) {
1345 gchar** _tmp72_;
1346 gint _tmp72__length1;
1347 gchar** _tmp73_;
1348 gint _tmp73__length1;
1349 const gchar* _tmp74_;
1350 if (!_tmp70_) {
1351 gint _tmp71_;
1352 _tmp71_ = i;
1353 i = _tmp71_ + 1;
1354 }
1355 _tmp70_ = FALSE;
1356 _tmp72_ = tabs_order;
1357 _tmp72__length1 = tabs_order_length1;
1358 if (!(i < _tmp72__length1)) {
1359 break;
1360 }
1361 _tmp73_ = tabs_order;
1362 _tmp73__length1 = tabs_order_length1;
1363 _tmp74_ = _tmp73_[i];
1364 xnp_window_move_note (window, _tmp74_, i);
1365 }
1366 }
1367 }
1368 xnp_window_set_current_page (window, last_page);
1369 xnp_window_set_above (window, above);
1370 xnp_window_set_sticky (window, sticky);
1371 gtk_widget_set_opacity ((GtkWidget*) window, opacity);
1372 if (visible) {
1373 gtk_widget_show ((GtkWidget*) window);
1374 }
1375 tabs_order = (_vala_array_free (tabs_order, tabs_order_length1, (GDestroyNotify) g_free), NULL);
1376 }
1377 goto __finally2;
1378 __catch2_g_error:
1379 {
1380 g_clear_error (&_inner_error0_);
1381 gtk_widget_show ((GtkWidget*) window);
1382 }
1383 __finally2:
1384 if (G_UNLIKELY (_inner_error0_ != NULL)) {
1385 _g_key_file_unref0 (keyfile);
1386 _g_free0 (path);
1387 _g_free0 (name);
1388 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);
1389 g_clear_error (&_inner_error0_);
1390 return;
1391 }
1392 _g_key_file_unref0 (keyfile);
1393 _g_free0 (path);
1394 _g_free0 (name);
1395 }
1396
1397 /**
1398 * save_windows_configuration:
1399 *
1400 * Save window configuration inside rc file.
1401 */
1402 void
xnp_application_save_windows_configuration(XnpApplication * self)1403 xnp_application_save_windows_configuration (XnpApplication* self)
1404 {
1405 GKeyFile* keyfile = NULL;
1406 GKeyFile* _tmp0_;
1407 GError* _inner_error0_ = NULL;
1408 g_return_if_fail (self != NULL);
1409 _tmp0_ = g_key_file_new ();
1410 keyfile = _tmp0_;
1411 {
1412 GSList* _tmp1_;
1413 gchar* contents = NULL;
1414 GKeyFile* _tmp63_;
1415 gchar* _tmp64_;
1416 const gchar* _tmp65_;
1417 _tmp1_ = self->priv->window_list;
1418 {
1419 GSList* win_collection = NULL;
1420 GSList* win_it = NULL;
1421 win_collection = _tmp1_;
1422 for (win_it = win_collection; win_it != NULL; win_it = win_it->next) {
1423 XnpWindow* _tmp2_;
1424 XnpWindow* win = NULL;
1425 _tmp2_ = _g_object_ref0 ((XnpWindow*) win_it->data);
1426 win = _tmp2_;
1427 {
1428 gint winx = 0;
1429 gint winy = 0;
1430 gint width = 0;
1431 gint height = 0;
1432 XnpWindow* _tmp3_;
1433 gint _tmp4_ = 0;
1434 gint _tmp5_ = 0;
1435 gint _tmp6_ = 0;
1436 gint _tmp7_ = 0;
1437 gchar** tabs_order = NULL;
1438 XnpWindow* _tmp8_;
1439 gint _tmp9_ = 0;
1440 gchar** _tmp10_;
1441 gint tabs_order_length1;
1442 gint _tabs_order_size_;
1443 gint last_page = 0;
1444 XnpWindow* _tmp11_;
1445 gint transparency = 0;
1446 XnpWindow* _tmp12_;
1447 gdouble _tmp13_;
1448 gdouble _tmp14_;
1449 gboolean visible = FALSE;
1450 XnpWindow* _tmp15_;
1451 GKeyFile* _tmp16_;
1452 XnpWindow* _tmp17_;
1453 const gchar* _tmp18_;
1454 const gchar* _tmp19_;
1455 GKeyFile* _tmp20_;
1456 XnpWindow* _tmp21_;
1457 const gchar* _tmp22_;
1458 const gchar* _tmp23_;
1459 GKeyFile* _tmp24_;
1460 XnpWindow* _tmp25_;
1461 const gchar* _tmp26_;
1462 const gchar* _tmp27_;
1463 GKeyFile* _tmp28_;
1464 XnpWindow* _tmp29_;
1465 const gchar* _tmp30_;
1466 const gchar* _tmp31_;
1467 GKeyFile* _tmp32_;
1468 XnpWindow* _tmp33_;
1469 const gchar* _tmp34_;
1470 const gchar* _tmp35_;
1471 gchar** _tmp36_;
1472 gint _tmp36__length1;
1473 GKeyFile* _tmp37_;
1474 XnpWindow* _tmp38_;
1475 const gchar* _tmp39_;
1476 const gchar* _tmp40_;
1477 GKeyFile* _tmp41_;
1478 XnpWindow* _tmp42_;
1479 const gchar* _tmp43_;
1480 const gchar* _tmp44_;
1481 XnpWindow* _tmp45_;
1482 gboolean _tmp46_;
1483 gboolean _tmp47_;
1484 GKeyFile* _tmp48_;
1485 XnpWindow* _tmp49_;
1486 const gchar* _tmp50_;
1487 const gchar* _tmp51_;
1488 XnpWindow* _tmp52_;
1489 gboolean _tmp53_;
1490 gboolean _tmp54_;
1491 GKeyFile* _tmp55_;
1492 XnpWindow* _tmp56_;
1493 const gchar* _tmp57_;
1494 const gchar* _tmp58_;
1495 GKeyFile* _tmp59_;
1496 XnpWindow* _tmp60_;
1497 const gchar* _tmp61_;
1498 const gchar* _tmp62_;
1499 _tmp3_ = win;
1500 xnp_window_get_geometry (_tmp3_, &_tmp4_, &_tmp5_, &_tmp6_, &_tmp7_);
1501 winx = _tmp4_;
1502 winy = _tmp5_;
1503 width = _tmp6_;
1504 height = _tmp7_;
1505 _tmp8_ = win;
1506 _tmp10_ = xnp_window_get_note_names (_tmp8_, &_tmp9_);
1507 tabs_order = _tmp10_;
1508 tabs_order_length1 = _tmp9_;
1509 _tabs_order_size_ = tabs_order_length1;
1510 _tmp11_ = win;
1511 last_page = xnp_window_get_current_page (_tmp11_);
1512 _tmp12_ = win;
1513 _tmp13_ = gtk_widget_get_opacity ((GtkWidget*) _tmp12_);
1514 _tmp14_ = _tmp13_;
1515 transparency = (gint) ((1 - _tmp14_) * 100);
1516 _tmp15_ = win;
1517 visible = gtk_widget_get_visible ((GtkWidget*) _tmp15_);
1518 _tmp16_ = keyfile;
1519 _tmp17_ = win;
1520 _tmp18_ = xnp_window_get_name (_tmp17_);
1521 _tmp19_ = _tmp18_;
1522 g_key_file_set_integer (_tmp16_, _tmp19_, "PosX", winx);
1523 _tmp20_ = keyfile;
1524 _tmp21_ = win;
1525 _tmp22_ = xnp_window_get_name (_tmp21_);
1526 _tmp23_ = _tmp22_;
1527 g_key_file_set_integer (_tmp20_, _tmp23_, "PosY", winy);
1528 _tmp24_ = keyfile;
1529 _tmp25_ = win;
1530 _tmp26_ = xnp_window_get_name (_tmp25_);
1531 _tmp27_ = _tmp26_;
1532 g_key_file_set_integer (_tmp24_, _tmp27_, "Width", width);
1533 _tmp28_ = keyfile;
1534 _tmp29_ = win;
1535 _tmp30_ = xnp_window_get_name (_tmp29_);
1536 _tmp31_ = _tmp30_;
1537 g_key_file_set_integer (_tmp28_, _tmp31_, "Height", height);
1538 _tmp32_ = keyfile;
1539 _tmp33_ = win;
1540 _tmp34_ = xnp_window_get_name (_tmp33_);
1541 _tmp35_ = _tmp34_;
1542 _tmp36_ = tabs_order;
1543 _tmp36__length1 = tabs_order_length1;
1544 g_key_file_set_string_list (_tmp32_, _tmp35_, "TabsOrder", (const gchar* const*) _tmp36_, (gint) _tmp36__length1);
1545 _tmp37_ = keyfile;
1546 _tmp38_ = win;
1547 _tmp39_ = xnp_window_get_name (_tmp38_);
1548 _tmp40_ = _tmp39_;
1549 g_key_file_set_integer (_tmp37_, _tmp40_, "LastTab", last_page);
1550 _tmp41_ = keyfile;
1551 _tmp42_ = win;
1552 _tmp43_ = xnp_window_get_name (_tmp42_);
1553 _tmp44_ = _tmp43_;
1554 _tmp45_ = win;
1555 _tmp46_ = xnp_window_get_above (_tmp45_);
1556 _tmp47_ = _tmp46_;
1557 g_key_file_set_boolean (_tmp41_, _tmp44_, "Above", _tmp47_);
1558 _tmp48_ = keyfile;
1559 _tmp49_ = win;
1560 _tmp50_ = xnp_window_get_name (_tmp49_);
1561 _tmp51_ = _tmp50_;
1562 _tmp52_ = win;
1563 _tmp53_ = xnp_window_get_sticky (_tmp52_);
1564 _tmp54_ = _tmp53_;
1565 g_key_file_set_boolean (_tmp48_, _tmp51_, "Sticky", _tmp54_);
1566 _tmp55_ = keyfile;
1567 _tmp56_ = win;
1568 _tmp57_ = xnp_window_get_name (_tmp56_);
1569 _tmp58_ = _tmp57_;
1570 g_key_file_set_double (_tmp55_, _tmp58_, "Transparency", (gdouble) transparency);
1571 _tmp59_ = keyfile;
1572 _tmp60_ = win;
1573 _tmp61_ = xnp_window_get_name (_tmp60_);
1574 _tmp62_ = _tmp61_;
1575 g_key_file_set_boolean (_tmp59_, _tmp62_, "Visible", visible);
1576 tabs_order = (_vala_array_free (tabs_order, tabs_order_length1, (GDestroyNotify) g_free), NULL);
1577 _g_object_unref0 (win);
1578 }
1579 }
1580 }
1581 _tmp63_ = keyfile;
1582 _tmp64_ = g_key_file_to_data (_tmp63_, NULL, NULL);
1583 contents = _tmp64_;
1584 _tmp65_ = self->priv->_config_file;
1585 g_file_set_contents (_tmp65_, contents, (gssize) -1, &_inner_error0_);
1586 if (G_UNLIKELY (_inner_error0_ != NULL)) {
1587 _g_free0 (contents);
1588 if (_inner_error0_->domain == G_FILE_ERROR) {
1589 goto __catch0_g_file_error;
1590 }
1591 _g_key_file_unref0 (keyfile);
1592 g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
1593 g_clear_error (&_inner_error0_);
1594 return;
1595 }
1596 _g_free0 (contents);
1597 }
1598 goto __finally0;
1599 __catch0_g_file_error:
1600 {
1601 GError* e = NULL;
1602 const gchar* _tmp66_;
1603 GError* _tmp67_;
1604 const gchar* _tmp68_;
1605 e = _inner_error0_;
1606 _inner_error0_ = NULL;
1607 _tmp66_ = self->priv->_config_file;
1608 _tmp67_ = e;
1609 _tmp68_ = _tmp67_->message;
1610 g_message ("application.vala:384: Unable to save window configuration from %s: %s", _tmp66_, _tmp68_);
1611 _g_error_free0 (e);
1612 }
1613 __finally0:
1614 if (G_UNLIKELY (_inner_error0_ != NULL)) {
1615 _g_key_file_unref0 (keyfile);
1616 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);
1617 g_clear_error (&_inner_error0_);
1618 return;
1619 }
1620 _g_key_file_unref0 (keyfile);
1621 }
1622
1623 /**
1624 * save_notes:
1625 *
1626 * Save the contents of every existing notes.
1627 */
1628 void
xnp_application_save_notes(XnpApplication * self)1629 xnp_application_save_notes (XnpApplication* self)
1630 {
1631 GSList* _tmp0_;
1632 g_return_if_fail (self != NULL);
1633 _tmp0_ = self->priv->window_list;
1634 {
1635 GSList* win_collection = NULL;
1636 GSList* win_it = NULL;
1637 win_collection = _tmp0_;
1638 for (win_it = win_collection; win_it != NULL; win_it = win_it->next) {
1639 XnpWindow* _tmp1_;
1640 XnpWindow* win = NULL;
1641 _tmp1_ = _g_object_ref0 ((XnpWindow*) win_it->data);
1642 win = _tmp1_;
1643 {
1644 XnpWindow* _tmp2_;
1645 XnpWindow* _tmp3_;
1646 _tmp2_ = win;
1647 xnp_application_set_data_value (self, (GObject*) _tmp2_, "external-change", FALSE);
1648 _tmp3_ = win;
1649 xnp_window_save_notes (_tmp3_);
1650 _g_object_unref0 (win);
1651 }
1652 }
1653 }
1654 }
1655
1656 /**
1657 * save_note:
1658 *
1659 * Save the contents of the given note.
1660 */
1661 static void
xnp_application_save_note(XnpApplication * self,XnpWindow * window,XnpNote * note)1662 xnp_application_save_note (XnpApplication* self,
1663 XnpWindow* window,
1664 XnpNote* note)
1665 {
1666 gchar* path = NULL;
1667 const gchar* _tmp0_;
1668 const gchar* _tmp1_;
1669 const gchar* _tmp2_;
1670 const gchar* _tmp3_;
1671 const gchar* _tmp4_;
1672 gchar* _tmp5_;
1673 GError* _inner_error0_ = NULL;
1674 g_return_if_fail (self != NULL);
1675 g_return_if_fail (window != NULL);
1676 g_return_if_fail (note != NULL);
1677 _tmp0_ = self->priv->_notes_path;
1678 _tmp1_ = xnp_window_get_name (window);
1679 _tmp2_ = _tmp1_;
1680 _tmp3_ = xnp_note_get_name (note);
1681 _tmp4_ = _tmp3_;
1682 _tmp5_ = g_strdup_printf ("%s/%s/%s", _tmp0_, _tmp2_, _tmp4_);
1683 path = _tmp5_;
1684 {
1685 GtkTextIter start = {0};
1686 GtkTextIter end = {0};
1687 GtkTextBuffer* buffer = NULL;
1688 XnpHypertextView* _tmp6_;
1689 GtkTextBuffer* _tmp7_;
1690 GtkTextBuffer* _tmp8_;
1691 GtkTextIter _tmp9_ = {0};
1692 GtkTextIter _tmp10_ = {0};
1693 gchar* contents = NULL;
1694 GtkTextIter _tmp11_;
1695 GtkTextIter _tmp12_;
1696 gchar* _tmp13_;
1697 _tmp6_ = note->text_view;
1698 _tmp7_ = gtk_text_view_get_buffer ((GtkTextView*) _tmp6_);
1699 _tmp8_ = _g_object_ref0 (_tmp7_);
1700 buffer = _tmp8_;
1701 gtk_text_buffer_get_bounds (buffer, &_tmp9_, &_tmp10_);
1702 start = _tmp9_;
1703 end = _tmp10_;
1704 _tmp11_ = start;
1705 _tmp12_ = end;
1706 _tmp13_ = gtk_text_buffer_get_text (buffer, &_tmp11_, &_tmp12_, TRUE);
1707 contents = _tmp13_;
1708 g_file_set_contents (path, contents, (gssize) -1, &_inner_error0_);
1709 if (G_UNLIKELY (_inner_error0_ != NULL)) {
1710 _g_free0 (contents);
1711 _g_object_unref0 (buffer);
1712 if (_inner_error0_->domain == G_FILE_ERROR) {
1713 goto __catch0_g_file_error;
1714 }
1715 _g_free0 (path);
1716 g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
1717 g_clear_error (&_inner_error0_);
1718 return;
1719 }
1720 _g_free0 (contents);
1721 _g_object_unref0 (buffer);
1722 }
1723 goto __finally0;
1724 __catch0_g_file_error:
1725 {
1726 GError* e = NULL;
1727 GError* _tmp14_;
1728 const gchar* _tmp15_;
1729 e = _inner_error0_;
1730 _inner_error0_ = NULL;
1731 _tmp14_ = e;
1732 _tmp15_ = _tmp14_->message;
1733 g_warning ("application.vala:415: %s", _tmp15_);
1734 _g_error_free0 (e);
1735 }
1736 __finally0:
1737 if (G_UNLIKELY (_inner_error0_ != NULL)) {
1738 _g_free0 (path);
1739 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);
1740 g_clear_error (&_inner_error0_);
1741 return;
1742 }
1743 _g_free0 (path);
1744 }
1745
1746 /**
1747 * rename_window:
1748 *
1749 * Renames the window name.
1750 */
1751 static void
xnp_application_rename_window(XnpApplication * self,XnpWindow * window)1752 xnp_application_rename_window (XnpApplication* self,
1753 XnpWindow* window)
1754 {
1755 GtkDialog* dialog = NULL;
1756 GtkDialog* _tmp0_;
1757 GtkBox* content_area = NULL;
1758 GtkDialog* _tmp1_;
1759 GtkBox* _tmp2_;
1760 GtkBox* _tmp3_;
1761 GtkDialog* _tmp4_;
1762 GtkDialog* _tmp5_;
1763 GtkDialog* _tmp6_;
1764 GtkDialog* _tmp7_;
1765 GtkEntry* entry = NULL;
1766 GtkEntry* _tmp8_;
1767 GtkEntry* _tmp9_;
1768 const gchar* _tmp10_;
1769 const gchar* _tmp11_;
1770 GtkEntry* _tmp12_;
1771 GtkBox* _tmp13_;
1772 GtkEntry* _tmp14_;
1773 GtkBox* _tmp15_;
1774 gint res = 0;
1775 GtkDialog* _tmp16_;
1776 GtkDialog* _tmp17_;
1777 GtkDialog* _tmp37_;
1778 g_return_if_fail (self != NULL);
1779 g_return_if_fail (window != NULL);
1780 _tmp0_ = (GtkDialog*) gtk_dialog_new_with_buttons (_ ("Rename group"), (GtkWindow*) window, GTK_DIALOG_DESTROY_WITH_PARENT, "_Cancel", GTK_RESPONSE_CANCEL, "_OK", GTK_RESPONSE_OK, NULL);
1781 g_object_ref_sink (_tmp0_);
1782 dialog = _tmp0_;
1783 _tmp1_ = dialog;
1784 _tmp2_ = gtk_dialog_get_content_area (_tmp1_);
1785 _tmp3_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, gtk_box_get_type (), GtkBox));
1786 content_area = _tmp3_;
1787 _tmp4_ = dialog;
1788 gtk_dialog_set_default_response (_tmp4_, (gint) GTK_RESPONSE_OK);
1789 _tmp5_ = dialog;
1790 gtk_window_set_resizable ((GtkWindow*) _tmp5_, FALSE);
1791 _tmp6_ = dialog;
1792 gtk_window_set_icon_name ((GtkWindow*) _tmp6_, "gtk-edit");
1793 _tmp7_ = dialog;
1794 gtk_container_set_border_width ((GtkContainer*) _tmp7_, (guint) 4);
1795 _tmp8_ = (GtkEntry*) gtk_entry_new ();
1796 g_object_ref_sink (_tmp8_);
1797 entry = _tmp8_;
1798 _tmp9_ = entry;
1799 _tmp10_ = xnp_window_get_name (window);
1800 _tmp11_ = _tmp10_;
1801 gtk_entry_set_text (_tmp9_, _tmp11_);
1802 _tmp12_ = entry;
1803 gtk_entry_set_activates_default (_tmp12_, TRUE);
1804 _tmp13_ = content_area;
1805 _tmp14_ = entry;
1806 gtk_container_add ((GtkContainer*) _tmp13_, (GtkWidget*) _tmp14_);
1807 _tmp15_ = content_area;
1808 gtk_widget_show_all ((GtkWidget*) _tmp15_);
1809 _tmp16_ = dialog;
1810 res = gtk_dialog_run (_tmp16_);
1811 _tmp17_ = dialog;
1812 gtk_widget_hide ((GtkWidget*) _tmp17_);
1813 if (res == ((gint) GTK_RESPONSE_OK)) {
1814 const gchar* name = NULL;
1815 GtkEntry* _tmp18_;
1816 const gchar* _tmp19_;
1817 const gchar* _tmp20_;
1818 const gchar* _tmp21_;
1819 _tmp18_ = entry;
1820 _tmp19_ = gtk_entry_get_text (_tmp18_);
1821 _tmp20_ = _tmp19_;
1822 name = _tmp20_;
1823 _tmp21_ = name;
1824 if (xnp_application_window_name_exists (self, _tmp21_)) {
1825 GtkMessageDialog* error_dialog = NULL;
1826 const gchar* _tmp22_;
1827 GtkMessageDialog* _tmp23_;
1828 GtkMessageDialog* _tmp24_;
1829 GtkMessageDialog* _tmp25_;
1830 _tmp22_ = name;
1831 _tmp23_ = (GtkMessageDialog*) gtk_message_dialog_new ((GtkWindow*) window, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _ ("The name %s is already in use"), _tmp22_);
1832 g_object_ref_sink (_tmp23_);
1833 error_dialog = _tmp23_;
1834 _tmp24_ = error_dialog;
1835 gtk_dialog_run ((GtkDialog*) _tmp24_);
1836 _tmp25_ = error_dialog;
1837 gtk_widget_destroy ((GtkWidget*) _tmp25_);
1838 _g_object_unref0 (error_dialog);
1839 } else {
1840 const gchar* _tmp26_;
1841 gchar* old_path = NULL;
1842 const gchar* _tmp27_;
1843 const gchar* _tmp28_;
1844 const gchar* _tmp29_;
1845 gchar* _tmp30_;
1846 gchar* new_path = NULL;
1847 const gchar* _tmp31_;
1848 const gchar* _tmp32_;
1849 gchar* _tmp33_;
1850 const gchar* _tmp34_;
1851 const gchar* _tmp35_;
1852 const gchar* _tmp36_;
1853 _tmp26_ = name;
1854 if (!xnp_application_name_is_valid (self, _tmp26_)) {
1855 _g_object_unref0 (entry);
1856 _g_object_unref0 (content_area);
1857 _g_object_unref0 (dialog);
1858 return;
1859 }
1860 _tmp27_ = self->priv->_notes_path;
1861 _tmp28_ = xnp_window_get_name (window);
1862 _tmp29_ = _tmp28_;
1863 _tmp30_ = g_strdup_printf ("%s/%s", _tmp27_, _tmp29_);
1864 old_path = _tmp30_;
1865 _tmp31_ = self->priv->_notes_path;
1866 _tmp32_ = name;
1867 _tmp33_ = g_strdup_printf ("%s/%s", _tmp31_, _tmp32_);
1868 new_path = _tmp33_;
1869 _tmp34_ = name;
1870 xnp_window_set_name (window, _tmp34_);
1871 _tmp35_ = old_path;
1872 _tmp36_ = new_path;
1873 g_rename (_tmp35_, _tmp36_);
1874 self->priv->window_list = g_slist_sort (self->priv->window_list, (GCompareFunc) xnp_window_compare_func);
1875 xnp_application_window_monitor_list_remove (self, window);
1876 xnp_application_window_monitor_list_add (self, window);
1877 _g_free0 (new_path);
1878 _g_free0 (old_path);
1879 }
1880 }
1881 _tmp37_ = dialog;
1882 gtk_widget_destroy ((GtkWidget*) _tmp37_);
1883 _g_object_unref0 (entry);
1884 _g_object_unref0 (content_area);
1885 _g_object_unref0 (dialog);
1886 }
1887
1888 /**
1889 * delete_window:
1890 *
1891 * Delete the window.
1892 */
1893 static void
xnp_application_delete_window(XnpApplication * self,XnpWindow * window)1894 xnp_application_delete_window (XnpApplication* self,
1895 XnpWindow* window)
1896 {
1897 gint _tmp0_;
1898 gint _tmp1_;
1899 gchar* name = NULL;
1900 gchar* path = NULL;
1901 const gchar* _tmp5_;
1902 const gchar* _tmp6_;
1903 const gchar* _tmp7_;
1904 gchar* _tmp8_;
1905 GSList* _tmp20_;
1906 GError* _inner_error0_ = NULL;
1907 g_return_if_fail (self != NULL);
1908 g_return_if_fail (window != NULL);
1909 _tmp0_ = xnp_window_get_n_pages (window);
1910 _tmp1_ = _tmp0_;
1911 if (_tmp1_ >= 1) {
1912 GtkMessageDialog* dialog = NULL;
1913 GtkMessageDialog* _tmp2_;
1914 gint res = 0;
1915 GtkMessageDialog* _tmp3_;
1916 GtkMessageDialog* _tmp4_;
1917 _tmp2_ = (GtkMessageDialog*) gtk_message_dialog_new ((GtkWindow*) window, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "%s", _ ("Are you sure you want to delete this group?"));
1918 g_object_ref_sink (_tmp2_);
1919 dialog = _tmp2_;
1920 _tmp3_ = dialog;
1921 res = gtk_dialog_run ((GtkDialog*) _tmp3_);
1922 _tmp4_ = dialog;
1923 gtk_widget_destroy ((GtkWidget*) _tmp4_);
1924 if (res != ((gint) GTK_RESPONSE_YES)) {
1925 _g_object_unref0 (dialog);
1926 return;
1927 }
1928 _g_object_unref0 (dialog);
1929 }
1930 _tmp5_ = self->priv->_notes_path;
1931 _tmp6_ = xnp_window_get_name (window);
1932 _tmp7_ = _tmp6_;
1933 _tmp8_ = g_strdup_printf ("%s/%s", _tmp5_, _tmp7_);
1934 path = _tmp8_;
1935 {
1936 GDir* dir = NULL;
1937 const gchar* _tmp9_;
1938 GDir* _tmp10_;
1939 const gchar* _tmp19_;
1940 _tmp9_ = path;
1941 _tmp10_ = g_dir_open (_tmp9_, (guint) 0, &_inner_error0_);
1942 dir = _tmp10_;
1943 if (G_UNLIKELY (_inner_error0_ != NULL)) {
1944 if (_inner_error0_->domain == G_FILE_ERROR) {
1945 goto __catch0_g_file_error;
1946 }
1947 _g_free0 (path);
1948 _g_free0 (name);
1949 g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
1950 g_clear_error (&_inner_error0_);
1951 return;
1952 }
1953 while (TRUE) {
1954 GDir* _tmp11_;
1955 const gchar* _tmp12_;
1956 gchar* _tmp13_;
1957 const gchar* _tmp14_;
1958 gchar* filename = NULL;
1959 const gchar* _tmp15_;
1960 const gchar* _tmp16_;
1961 gchar* _tmp17_;
1962 const gchar* _tmp18_;
1963 _tmp11_ = dir;
1964 _tmp12_ = g_dir_read_name (_tmp11_);
1965 _tmp13_ = g_strdup (_tmp12_);
1966 _g_free0 (name);
1967 name = _tmp13_;
1968 _tmp14_ = name;
1969 if (!(_tmp14_ != NULL)) {
1970 break;
1971 }
1972 _tmp15_ = path;
1973 _tmp16_ = name;
1974 _tmp17_ = g_strdup_printf ("%s/%s", _tmp15_, _tmp16_);
1975 filename = _tmp17_;
1976 _tmp18_ = filename;
1977 g_unlink (_tmp18_);
1978 _g_free0 (filename);
1979 }
1980 _tmp19_ = path;
1981 g_rmdir (_tmp19_);
1982 _g_dir_close0 (dir);
1983 }
1984 goto __finally0;
1985 __catch0_g_file_error:
1986 {
1987 g_clear_error (&_inner_error0_);
1988 }
1989 __finally0:
1990 if (G_UNLIKELY (_inner_error0_ != NULL)) {
1991 _g_free0 (path);
1992 _g_free0 (name);
1993 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);
1994 g_clear_error (&_inner_error0_);
1995 return;
1996 }
1997 xnp_application_window_monitor_list_remove (self, window);
1998 self->priv->window_list = g_slist_remove (self->priv->window_list, window);
1999 gtk_widget_destroy ((GtkWidget*) window);
2000 _tmp20_ = self->priv->window_list;
2001 if (g_slist_length (_tmp20_) >= ((guint) 1)) {
2002 GSList* _tmp21_;
2003 _tmp21_ = self->priv->window_list;
2004 {
2005 GSList* win_collection = NULL;
2006 GSList* win_it = NULL;
2007 win_collection = _tmp21_;
2008 for (win_it = win_collection; win_it != NULL; win_it = win_it->next) {
2009 XnpWindow* _tmp22_;
2010 XnpWindow* win = NULL;
2011 _tmp22_ = _g_object_ref0 ((XnpWindow*) win_it->data);
2012 win = _tmp22_;
2013 {
2014 XnpWindow* _tmp23_;
2015 GSList* _tmp24_;
2016 _tmp23_ = win;
2017 _tmp24_ = self->priv->window_list;
2018 xnp_window_set_window_list (_tmp23_, _tmp24_);
2019 _g_object_unref0 (win);
2020 }
2021 }
2022 }
2023 } else {
2024 XnpWindow* new_win = NULL;
2025 XnpWindow* _tmp25_;
2026 XnpWindow* _tmp26_;
2027 _tmp25_ = xnp_application_create_window (self, NULL);
2028 new_win = _tmp25_;
2029 _tmp26_ = new_win;
2030 gtk_widget_show ((GtkWidget*) _tmp26_);
2031 _g_object_unref0 (new_win);
2032 }
2033 _g_free0 (path);
2034 _g_free0 (name);
2035 }
2036
2037 /**
2038 * refresh_notes:
2039 *
2040 * Prompt for reloading notes from disk.
2041 */
2042 static void
xnp_application_refresh_notes(XnpApplication * self,XnpWindow * window)2043 xnp_application_refresh_notes (XnpApplication* self,
2044 XnpWindow* window)
2045 {
2046 GtkMessageDialog* dialog = NULL;
2047 const gchar* _tmp0_;
2048 const gchar* _tmp1_;
2049 GtkMessageDialog* _tmp2_;
2050 GtkMessageDialog* _tmp3_;
2051 const gchar* _tmp4_;
2052 const gchar* _tmp5_;
2053 GtkMessageDialog* _tmp6_;
2054 GtkMessageDialog* _tmp7_;
2055 gint res = 0;
2056 GtkMessageDialog* _tmp8_;
2057 GtkMessageDialog* _tmp9_;
2058 g_return_if_fail (self != NULL);
2059 g_return_if_fail (window != NULL);
2060 _tmp0_ = xnp_window_get_name (window);
2061 _tmp1_ = _tmp0_;
2062 _tmp2_ = (GtkMessageDialog*) gtk_message_dialog_new ((GtkWindow*) window, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, _ ("The group \"%s\" has been modified on the disk"), _tmp1_);
2063 g_object_ref_sink (_tmp2_);
2064 dialog = _tmp2_;
2065 _tmp3_ = dialog;
2066 _tmp4_ = xnp_window_get_name (window);
2067 _tmp5_ = _tmp4_;
2068 gtk_window_set_title ((GtkWindow*) _tmp3_, _tmp5_);
2069 _tmp6_ = dialog;
2070 gtk_window_set_icon_name ((GtkWindow*) _tmp6_, "xfce4-notes-plugin");
2071 _tmp7_ = dialog;
2072 gtk_message_dialog_format_secondary_text (_tmp7_, "%s", _ ("Do you want to reload the group?"));
2073 _tmp8_ = dialog;
2074 res = gtk_dialog_run ((GtkDialog*) _tmp8_);
2075 _tmp9_ = dialog;
2076 gtk_widget_destroy ((GtkWidget*) _tmp9_);
2077 if (res == ((gint) GTK_RESPONSE_YES)) {
2078 gchar* name = NULL;
2079 const gchar* _tmp10_;
2080 const gchar* _tmp11_;
2081 gchar* _tmp12_;
2082 XnpWindow* win = NULL;
2083 const gchar* _tmp13_;
2084 XnpWindow* _tmp14_;
2085 XnpWindow* _tmp15_;
2086 _tmp10_ = xnp_window_get_name (window);
2087 _tmp11_ = _tmp10_;
2088 _tmp12_ = g_strdup (_tmp11_);
2089 name = _tmp12_;
2090 xnp_application_window_monitor_list_remove (self, window);
2091 self->priv->window_list = g_slist_remove (self->priv->window_list, window);
2092 gtk_widget_destroy ((GtkWidget*) window);
2093 _tmp13_ = name;
2094 _tmp14_ = xnp_application_create_window (self, _tmp13_);
2095 win = _tmp14_;
2096 _tmp15_ = win;
2097 gtk_widget_show ((GtkWidget*) _tmp15_);
2098 _g_object_unref0 (win);
2099 _g_free0 (name);
2100 } else {
2101 xnp_application_set_data_value (self, (GObject*) window, "external-change", FALSE);
2102 xnp_window_set_show_refresh_button (window, FALSE);
2103 xnp_window_save_notes (window);
2104 }
2105 _g_object_unref0 (dialog);
2106 }
2107
2108 /**
2109 * window_monitor_list_add:
2110 *
2111 * Creates an Xnp.WindowMonitor object and stores it inside window_monitor_list.
2112 */
2113 static void
__lambda24_(XnpApplication * self,XnpWindow * window)2114 __lambda24_ (XnpApplication* self,
2115 XnpWindow* window)
2116 {
2117 g_return_if_fail (window != NULL);
2118 if (xnp_application_get_data_value (self, (GObject*) window, "internal-change")) {
2119 xnp_application_set_data_value (self, (GObject*) window, "internal-change", FALSE);
2120 } else {
2121 xnp_application_set_data_value (self, (GObject*) window, "external-change", TRUE);
2122 xnp_window_set_show_refresh_button (window, TRUE);
2123 }
2124 }
2125
2126 static void
___lambda24__xnp_window_monitor_window_updated(XnpWindowMonitor * _sender,XnpWindow * window,gpointer self)2127 ___lambda24__xnp_window_monitor_window_updated (XnpWindowMonitor* _sender,
2128 XnpWindow* window,
2129 gpointer self)
2130 {
2131 __lambda24_ ((XnpApplication*) self, window);
2132 }
2133
2134 static void
xnp_application_window_monitor_list_add(XnpApplication * self,XnpWindow * window)2135 xnp_application_window_monitor_list_add (XnpApplication* self,
2136 XnpWindow* window)
2137 {
2138 GFile* file = NULL;
2139 const gchar* _tmp0_;
2140 const gchar* _tmp1_;
2141 const gchar* _tmp2_;
2142 gchar* _tmp3_;
2143 gchar* _tmp4_;
2144 GFile* _tmp5_;
2145 GFile* _tmp6_;
2146 XnpWindowMonitor* monitor = NULL;
2147 XnpWindowMonitor* _tmp7_;
2148 XnpWindowMonitor* _tmp8_;
2149 g_return_if_fail (self != NULL);
2150 g_return_if_fail (window != NULL);
2151 _tmp0_ = self->priv->_notes_path;
2152 _tmp1_ = xnp_window_get_name (window);
2153 _tmp2_ = _tmp1_;
2154 _tmp3_ = g_strdup_printf ("%s/%s", _tmp0_, _tmp2_);
2155 _tmp4_ = _tmp3_;
2156 _tmp5_ = g_file_new_for_path (_tmp4_);
2157 _tmp6_ = _tmp5_;
2158 _g_free0 (_tmp4_);
2159 file = _tmp6_;
2160 _tmp7_ = xnp_window_monitor_new (window, file);
2161 monitor = _tmp7_;
2162 g_signal_connect_object (monitor, "window-updated", (GCallback) ___lambda24__xnp_window_monitor_window_updated, self, 0);
2163 _tmp8_ = _g_object_ref0 (monitor);
2164 self->priv->window_monitor_list = g_slist_prepend (self->priv->window_monitor_list, _tmp8_);
2165 _g_object_unref0 (monitor);
2166 _g_object_unref0 (file);
2167 }
2168
2169 /**
2170 * window_monitor_list_remove:
2171 *
2172 * Removes a monitor from window_monitor_list matching @window.
2173 */
2174 static void
xnp_application_window_monitor_list_remove(XnpApplication * self,XnpWindow * window)2175 xnp_application_window_monitor_list_remove (XnpApplication* self,
2176 XnpWindow* window)
2177 {
2178 XnpWindowMonitor* monitor = NULL;
2179 XnpWindowMonitor* _tmp0_;
2180 XnpWindowMonitor* _tmp1_;
2181 g_return_if_fail (self != NULL);
2182 g_return_if_fail (window != NULL);
2183 _tmp0_ = xnp_application_window_monitor_list_lookup (self, window);
2184 monitor = _tmp0_;
2185 _tmp1_ = monitor;
2186 if (_tmp1_ != NULL) {
2187 XnpWindowMonitor* _tmp2_;
2188 XnpWindowMonitor* _tmp3_;
2189 _tmp2_ = monitor;
2190 self->priv->window_monitor_list = g_slist_remove (self->priv->window_monitor_list, _tmp2_);
2191 _tmp3_ = monitor;
2192 g_object_unref ((GObject*) _tmp3_);
2193 _g_object_unref0 (monitor);
2194 monitor = NULL;
2195 }
2196 _g_object_unref0 (monitor);
2197 }
2198
2199 /**
2200 * window_monitor_list_lookup:
2201 *
2202 * Returns the window_monitor object that contains @window from the window_monitor_list.
2203 */
2204 static XnpWindowMonitor*
xnp_application_window_monitor_list_lookup(XnpApplication * self,XnpWindow * window)2205 xnp_application_window_monitor_list_lookup (XnpApplication* self,
2206 XnpWindow* window)
2207 {
2208 XnpWindowMonitor* window_monitor = NULL;
2209 GSList* _tmp0_;
2210 XnpWindowMonitor* result = NULL;
2211 g_return_val_if_fail (self != NULL, NULL);
2212 g_return_val_if_fail (window != NULL, NULL);
2213 window_monitor = NULL;
2214 _tmp0_ = self->priv->window_monitor_list;
2215 {
2216 GSList* monitor_collection = NULL;
2217 GSList* monitor_it = NULL;
2218 monitor_collection = _tmp0_;
2219 for (monitor_it = monitor_collection; monitor_it != NULL; monitor_it = monitor_it->next) {
2220 XnpWindowMonitor* _tmp1_;
2221 XnpWindowMonitor* monitor = NULL;
2222 _tmp1_ = _g_object_ref0 ((XnpWindowMonitor*) monitor_it->data);
2223 monitor = _tmp1_;
2224 {
2225 XnpWindowMonitor* _tmp2_;
2226 XnpWindow* _tmp3_;
2227 _tmp2_ = monitor;
2228 _tmp3_ = _tmp2_->window;
2229 if (_tmp3_ == window) {
2230 XnpWindowMonitor* _tmp4_;
2231 XnpWindowMonitor* _tmp5_;
2232 _tmp4_ = monitor;
2233 _tmp5_ = _g_object_ref0 (_tmp4_);
2234 _g_object_unref0 (window_monitor);
2235 window_monitor = _tmp5_;
2236 _g_object_unref0 (monitor);
2237 break;
2238 }
2239 _g_object_unref0 (monitor);
2240 }
2241 }
2242 }
2243 result = window_monitor;
2244 return result;
2245 }
2246
2247 /**
2248 * get_data_value:
2249 *
2250 * Convenience function to return a GObject data boolean value.
2251 */
2252 static gboolean
xnp_application_get_data_value(XnpApplication * self,GObject * object,const gchar * data)2253 xnp_application_get_data_value (XnpApplication* self,
2254 GObject* object,
2255 const gchar* data)
2256 {
2257 gconstpointer _tmp0_;
2258 gboolean result = FALSE;
2259 g_return_val_if_fail (self != NULL, FALSE);
2260 g_return_val_if_fail (object != NULL, FALSE);
2261 g_return_val_if_fail (data != NULL, FALSE);
2262 _tmp0_ = g_object_get_data (object, data);
2263 result = (gboolean) ((gintptr) _tmp0_);
2264 return result;
2265 }
2266
2267 /**
2268 * set_data_value:
2269 *
2270 * Convenience function to set a GObject data boolean value.
2271 */
2272 static void
xnp_application_set_data_value(XnpApplication * self,GObject * object,const gchar * data,gboolean val)2273 xnp_application_set_data_value (XnpApplication* self,
2274 GObject* object,
2275 const gchar* data,
2276 gboolean val)
2277 {
2278 void* _tmp0_;
2279 g_return_if_fail (self != NULL);
2280 g_return_if_fail (object != NULL);
2281 g_return_if_fail (data != NULL);
2282 _tmp0_ = GINT_TO_POINTER ((gint) val);
2283 g_object_set_data_full (object, data, _tmp0_, NULL);
2284 }
2285
2286 /**
2287 * window_name_exists:
2288 *
2289 * Verify if the given name already exists in the window list.
2290 */
2291 static gboolean
xnp_application_window_name_exists(XnpApplication * self,const gchar * name)2292 xnp_application_window_name_exists (XnpApplication* self,
2293 const gchar* name)
2294 {
2295 GSList* _tmp0_;
2296 gboolean result = FALSE;
2297 g_return_val_if_fail (self != NULL, FALSE);
2298 g_return_val_if_fail (name != NULL, FALSE);
2299 _tmp0_ = self->priv->window_list;
2300 {
2301 GSList* win_collection = NULL;
2302 GSList* win_it = NULL;
2303 win_collection = _tmp0_;
2304 for (win_it = win_collection; win_it != NULL; win_it = win_it->next) {
2305 XnpWindow* _tmp1_;
2306 XnpWindow* win = NULL;
2307 _tmp1_ = _g_object_ref0 ((XnpWindow*) win_it->data);
2308 win = _tmp1_;
2309 {
2310 XnpWindow* _tmp2_;
2311 const gchar* _tmp3_;
2312 const gchar* _tmp4_;
2313 _tmp2_ = win;
2314 _tmp3_ = xnp_window_get_name (_tmp2_);
2315 _tmp4_ = _tmp3_;
2316 if (g_strcmp0 (_tmp4_, name) == 0) {
2317 result = TRUE;
2318 _g_object_unref0 (win);
2319 return result;
2320 }
2321 _g_object_unref0 (win);
2322 }
2323 }
2324 }
2325 result = FALSE;
2326 return result;
2327 }
2328
2329 /**
2330 * name_is_valid:
2331 *
2332 * Verify if the given name is valid for window and notes.
2333 */
2334 static gboolean
xnp_application_name_is_valid(XnpApplication * self,const gchar * name)2335 xnp_application_name_is_valid (XnpApplication* self,
2336 const gchar* name)
2337 {
2338 gboolean res = FALSE;
2339 gboolean result = FALSE;
2340 g_return_val_if_fail (self != NULL, FALSE);
2341 g_return_val_if_fail (name != NULL, FALSE);
2342 res = g_regex_match_simple ("^[^*|/\\:\"<>?]+$", name, 0, 0);
2343 if (!res) {
2344 GtkMessageDialog* error_dialog = NULL;
2345 GtkMessageDialog* _tmp0_;
2346 GtkMessageDialog* _tmp1_;
2347 gchar* _tmp2_;
2348 gchar* _tmp3_;
2349 GtkMessageDialog* _tmp4_;
2350 GtkMessageDialog* _tmp5_;
2351 _tmp0_ = (GtkMessageDialog*) gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _ ("The name \"%s\" is invalid."), name);
2352 g_object_ref_sink (_tmp0_);
2353 error_dialog = _tmp0_;
2354 _tmp1_ = error_dialog;
2355 _tmp2_ = g_strdup_printf (_ ("The invalid characters are: %s"), "<tt>*|/\\:\"<>?</tt>");
2356 _tmp3_ = _tmp2_;
2357 gtk_message_dialog_format_secondary_markup (_tmp1_, "%s", _tmp3_);
2358 _g_free0 (_tmp3_);
2359 _tmp4_ = error_dialog;
2360 gtk_dialog_run ((GtkDialog*) _tmp4_);
2361 _tmp5_ = error_dialog;
2362 gtk_widget_destroy ((GtkWidget*) _tmp5_);
2363 _g_object_unref0 (error_dialog);
2364 }
2365 result = res;
2366 return result;
2367 }
2368
2369 /**
2370 * show_hide_notes:
2371 *
2372 * Show all the notes or hide them if they are all shown.
2373 */
2374 void
xnp_application_show_hide_notes(XnpApplication * self)2375 xnp_application_show_hide_notes (XnpApplication* self)
2376 {
2377 gboolean invisible_found = FALSE;
2378 gboolean visible_found = FALSE;
2379 gboolean active_found = FALSE;
2380 GSList* _tmp0_;
2381 GSList* _tmp6_;
2382 g_return_if_fail (self != NULL);
2383 invisible_found = FALSE;
2384 visible_found = FALSE;
2385 active_found = FALSE;
2386 _tmp0_ = self->priv->window_list;
2387 {
2388 GSList* win_collection = NULL;
2389 GSList* win_it = NULL;
2390 win_collection = _tmp0_;
2391 for (win_it = win_collection; win_it != NULL; win_it = win_it->next) {
2392 XnpWindow* _tmp1_;
2393 XnpWindow* win = NULL;
2394 _tmp1_ = _g_object_ref0 ((XnpWindow*) win_it->data);
2395 win = _tmp1_;
2396 {
2397 XnpWindow* _tmp2_;
2398 gboolean _tmp3_;
2399 gboolean _tmp4_;
2400 XnpWindow* _tmp5_;
2401 _tmp2_ = win;
2402 g_object_get ((GtkWindow*) _tmp2_, "is-active", &_tmp3_, NULL);
2403 _tmp4_ = _tmp3_;
2404 if (_tmp4_) {
2405 active_found = TRUE;
2406 }
2407 _tmp5_ = win;
2408 if (!gtk_widget_get_visible ((GtkWidget*) _tmp5_)) {
2409 invisible_found = TRUE;
2410 } else {
2411 visible_found = TRUE;
2412 }
2413 _g_object_unref0 (win);
2414 }
2415 }
2416 }
2417 _tmp6_ = self->priv->window_list;
2418 {
2419 GSList* win_collection = NULL;
2420 GSList* win_it = NULL;
2421 win_collection = _tmp6_;
2422 for (win_it = win_collection; win_it != NULL; win_it = win_it->next) {
2423 XnpWindow* _tmp7_;
2424 XnpWindow* win = NULL;
2425 _tmp7_ = _g_object_ref0 ((XnpWindow*) win_it->data);
2426 win = _tmp7_;
2427 {
2428 gboolean _tmp8_ = FALSE;
2429 if (!active_found) {
2430 _tmp8_ = visible_found;
2431 } else {
2432 _tmp8_ = FALSE;
2433 }
2434 if (_tmp8_) {
2435 XnpWindow* _tmp9_;
2436 _tmp9_ = win;
2437 if (gtk_widget_get_visible ((GtkWidget*) _tmp9_)) {
2438 XnpWindow* _tmp10_;
2439 _tmp10_ = win;
2440 gtk_window_present ((GtkWindow*) _tmp10_);
2441 }
2442 } else {
2443 if (invisible_found) {
2444 XnpWindow* _tmp11_;
2445 _tmp11_ = win;
2446 gtk_widget_show ((GtkWidget*) _tmp11_);
2447 } else {
2448 XnpWindow* _tmp12_;
2449 _tmp12_ = win;
2450 xnp_window_hide (_tmp12_);
2451 }
2452 }
2453 _g_object_unref0 (win);
2454 }
2455 }
2456 }
2457 }
2458
2459 /**
2460 * open_settings_dialog:
2461 *
2462 * Open the settings dialog.
2463 */
2464 void
xnp_application_open_settings_dialog(XnpApplication * self)2465 xnp_application_open_settings_dialog (XnpApplication* self)
2466 {
2467 GError* _inner_error0_ = NULL;
2468 g_return_if_fail (self != NULL);
2469 {
2470 g_spawn_command_line_async ("xfce4-notes-settings", &_inner_error0_);
2471 if (G_UNLIKELY (_inner_error0_ != NULL)) {
2472 goto __catch0_g_error;
2473 }
2474 }
2475 goto __finally0;
2476 __catch0_g_error:
2477 {
2478 GError* e = NULL;
2479 GtkMessageDialog* error_dialog = NULL;
2480 GtkMessageDialog* _tmp0_;
2481 GtkMessageDialog* _tmp1_;
2482 GError* _tmp2_;
2483 const gchar* _tmp3_;
2484 GtkMessageDialog* _tmp4_;
2485 GtkMessageDialog* _tmp5_;
2486 e = _inner_error0_;
2487 _inner_error0_ = NULL;
2488 _tmp0_ = (GtkMessageDialog*) gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", _ ("Unable to open the settings dialog"));
2489 g_object_ref_sink (_tmp0_);
2490 error_dialog = _tmp0_;
2491 _tmp1_ = error_dialog;
2492 _tmp2_ = e;
2493 _tmp3_ = _tmp2_->message;
2494 gtk_message_dialog_format_secondary_text (_tmp1_, "%s", _tmp3_);
2495 _tmp4_ = error_dialog;
2496 gtk_dialog_run ((GtkDialog*) _tmp4_);
2497 _tmp5_ = error_dialog;
2498 gtk_widget_destroy ((GtkWidget*) _tmp5_);
2499 _g_object_unref0 (error_dialog);
2500 _g_error_free0 (e);
2501 }
2502 __finally0:
2503 if (G_UNLIKELY (_inner_error0_ != NULL)) {
2504 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);
2505 g_clear_error (&_inner_error0_);
2506 return;
2507 }
2508 }
2509
2510 /**
2511 * open_about_dialog:
2512 *
2513 * Open the about dialog.
2514 */
2515 void
xnp_application_open_about_dialog(XnpApplication * self)2516 xnp_application_open_about_dialog (XnpApplication* self)
2517 {
2518 gchar** authors = NULL;
2519 gchar* _tmp0_;
2520 gchar* _tmp1_;
2521 gchar** _tmp2_;
2522 gint authors_length1;
2523 gint _authors_size_;
2524 const gchar* _tmp3_;
2525 g_return_if_fail (self != NULL);
2526 _tmp0_ = g_strdup ("(c) 2006-2010 Mike Massonnet");
2527 _tmp1_ = g_strdup ("(c) 2003 Jakob Henriksson");
2528 _tmp2_ = g_new0 (gchar*, 3 + 1);
2529 _tmp2_[0] = _tmp0_;
2530 _tmp2_[1] = _tmp1_;
2531 _tmp2_[2] = NULL;
2532 authors = _tmp2_;
2533 authors_length1 = 3;
2534 _authors_size_ = authors_length1;
2535 _tmp3_ = xfce_get_license_text (XFCE_LICENSE_TEXT_GPL);
2536 gtk_show_about_dialog (NULL, "program-name", _ ("Notes"), "logo-icon-name", "xfce4-notes-plugin", "comments", _ ("Ideal for your quick notes"), "version", PACKAGE_VERSION, "copyright", "Copyright © 2003-2020 The Xfce development team", "license", _tmp3_, "website", "https://docs.xfce.org/panel-plugins/xfce4-notes-plugin", "website-label", "docs.xfce.org", "authors", authors, "translator-credits", _ ("translator-credits"), NULL, NULL);
2537 authors = (_vala_array_free (authors, authors_length1, (GDestroyNotify) g_free), NULL);
2538 }
2539
2540 /**
2541 * context_menu:
2542 *
2543 * Provides a GtkMenu to be used for right click context menus
2544 * like in trayicons. Its items are destroyed/refreshed every
2545 * time the menu is shown.
2546 */
2547 static Block1Data*
block1_data_ref(Block1Data * _data1_)2548 block1_data_ref (Block1Data* _data1_)
2549 {
2550 g_atomic_int_inc (&_data1_->_ref_count_);
2551 return _data1_;
2552 }
2553
2554 static void
block1_data_unref(void * _userdata_)2555 block1_data_unref (void * _userdata_)
2556 {
2557 Block1Data* _data1_;
2558 _data1_ = (Block1Data*) _userdata_;
2559 if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
2560 XnpApplication* self;
2561 self = _data1_->self;
2562 _g_object_unref0 (_data1_->menu);
2563 _g_object_unref0 (self);
2564 g_slice_free (Block1Data, _data1_);
2565 }
2566 }
2567
2568 static void
__lambda31_(XnpApplication * self,GtkWidget * w)2569 __lambda31_ (XnpApplication* self,
2570 GtkWidget* w)
2571 {
2572 g_return_if_fail (w != NULL);
2573 gtk_widget_destroy (w);
2574 }
2575
2576 static void
___lambda31__gtk_callback(GtkWidget * widget,gpointer self)2577 ___lambda31__gtk_callback (GtkWidget* widget,
2578 gpointer self)
2579 {
2580 __lambda31_ ((XnpApplication*) self, widget);
2581 }
2582
2583 static void
____lambda32_(XnpApplication * self,GtkMenuItem * i)2584 ____lambda32_ (XnpApplication* self,
2585 GtkMenuItem* i)
2586 {
2587 XnpWindow* w = NULL;
2588 gconstpointer _tmp0_;
2589 XnpWindow* _tmp1_;
2590 g_return_if_fail (i != NULL);
2591 _tmp0_ = g_object_get_data ((GObject*) i, "window");
2592 _tmp1_ = _g_object_ref0 ((XnpWindow*) _tmp0_);
2593 w = _tmp1_;
2594 gtk_window_present ((GtkWindow*) w);
2595 _g_object_unref0 (w);
2596 }
2597
2598 static void
_____lambda32__gtk_menu_item_activate(GtkMenuItem * _sender,gpointer self)2599 _____lambda32__gtk_menu_item_activate (GtkMenuItem* _sender,
2600 gpointer self)
2601 {
2602 ____lambda32_ ((XnpApplication*) self, _sender);
2603 }
2604
2605 static void
__lambda33_(XnpApplication * self)2606 __lambda33_ (XnpApplication* self)
2607 {
2608 XnpWindow* new_win = NULL;
2609 XnpWindow* _tmp0_;
2610 _tmp0_ = xnp_application_create_window (self, NULL);
2611 new_win = _tmp0_;
2612 gtk_widget_show ((GtkWidget*) new_win);
2613 _g_object_unref0 (new_win);
2614 }
2615
2616 static void
___lambda33__gtk_menu_item_activate(GtkMenuItem * _sender,gpointer self)2617 ___lambda33__gtk_menu_item_activate (GtkMenuItem* _sender,
2618 gpointer self)
2619 {
2620 __lambda33_ ((XnpApplication*) self);
2621 }
2622
2623 static void
__lambda30_(Block1Data * _data1_)2624 __lambda30_ (Block1Data* _data1_)
2625 {
2626 XnpApplication* self;
2627 GSList* _tmp0_;
2628 GtkSeparatorMenuItem* mi_sep = NULL;
2629 GtkSeparatorMenuItem* _tmp10_;
2630 GtkMenuItem* mi_add = NULL;
2631 GtkMenuItem* _tmp11_;
2632 self = _data1_->self;
2633 gtk_container_foreach ((GtkContainer*) _data1_->menu, ___lambda31__gtk_callback, self);
2634 _tmp0_ = self->priv->window_list;
2635 {
2636 GSList* win_collection = NULL;
2637 GSList* win_it = NULL;
2638 win_collection = _tmp0_;
2639 for (win_it = win_collection; win_it != NULL; win_it = win_it->next) {
2640 XnpWindow* _tmp1_;
2641 XnpWindow* win = NULL;
2642 _tmp1_ = _g_object_ref0 ((XnpWindow*) win_it->data);
2643 win = _tmp1_;
2644 {
2645 GtkMenuItem* mi = NULL;
2646 XnpWindow* _tmp2_;
2647 const gchar* _tmp3_;
2648 const gchar* _tmp4_;
2649 GtkMenuItem* _tmp5_;
2650 GtkMenuItem* _tmp6_;
2651 XnpWindow* _tmp7_;
2652 GtkMenuItem* _tmp8_;
2653 GtkMenuItem* _tmp9_;
2654 _tmp2_ = win;
2655 _tmp3_ = xnp_window_get_name (_tmp2_);
2656 _tmp4_ = _tmp3_;
2657 _tmp5_ = (GtkMenuItem*) gtk_menu_item_new_with_label (_tmp4_);
2658 g_object_ref_sink (_tmp5_);
2659 mi = _tmp5_;
2660 _tmp6_ = mi;
2661 _tmp7_ = win;
2662 g_object_set_data_full ((GObject*) _tmp6_, "window", (void*) _tmp7_, NULL);
2663 _tmp8_ = mi;
2664 g_signal_connect_object (_tmp8_, "activate", (GCallback) _____lambda32__gtk_menu_item_activate, self, 0);
2665 _tmp9_ = mi;
2666 gtk_menu_shell_append ((GtkMenuShell*) _data1_->menu, _tmp9_);
2667 _g_object_unref0 (mi);
2668 _g_object_unref0 (win);
2669 }
2670 }
2671 }
2672 _tmp10_ = (GtkSeparatorMenuItem*) gtk_separator_menu_item_new ();
2673 g_object_ref_sink (_tmp10_);
2674 mi_sep = _tmp10_;
2675 gtk_menu_shell_append ((GtkMenuShell*) _data1_->menu, (GtkMenuItem*) mi_sep);
2676 _tmp11_ = (GtkMenuItem*) gtk_menu_item_new_with_mnemonic (_ ("_Add a new group"));
2677 g_object_ref_sink (_tmp11_);
2678 mi_add = _tmp11_;
2679 g_signal_connect_object (mi_add, "activate", (GCallback) ___lambda33__gtk_menu_item_activate, self, 0);
2680 gtk_menu_shell_append ((GtkMenuShell*) _data1_->menu, mi_add);
2681 gtk_widget_show_all ((GtkWidget*) _data1_->menu);
2682 _g_object_unref0 (mi_add);
2683 _g_object_unref0 (mi_sep);
2684 }
2685
2686 static void
___lambda30__gtk_widget_show(GtkWidget * _sender,gpointer self)2687 ___lambda30__gtk_widget_show (GtkWidget* _sender,
2688 gpointer self)
2689 {
2690 __lambda30_ (self);
2691 }
2692
2693 GtkMenu*
xnp_application_context_menu(XnpApplication * self)2694 xnp_application_context_menu (XnpApplication* self)
2695 {
2696 Block1Data* _data1_;
2697 GtkMenu* _tmp0_;
2698 GtkMenu* _tmp1_;
2699 GtkMenu* result = NULL;
2700 g_return_val_if_fail (self != NULL, NULL);
2701 _data1_ = g_slice_new0 (Block1Data);
2702 _data1_->_ref_count_ = 1;
2703 _data1_->self = g_object_ref (self);
2704 _tmp0_ = (GtkMenu*) gtk_menu_new ();
2705 g_object_ref_sink (_tmp0_);
2706 _data1_->menu = _tmp0_;
2707 g_signal_connect_data ((GtkWidget*) _data1_->menu, "show", (GCallback) ___lambda30__gtk_widget_show, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0);
2708 _tmp1_ = _g_object_ref0 (_data1_->menu);
2709 result = _tmp1_;
2710 block1_data_unref (_data1_);
2711 _data1_ = NULL;
2712 return result;
2713 }
2714
2715 const gchar*
xnp_application_get_notes_path(XnpApplication * self)2716 xnp_application_get_notes_path (XnpApplication* self)
2717 {
2718 const gchar* result;
2719 const gchar* _tmp0_;
2720 g_return_val_if_fail (self != NULL, NULL);
2721 _tmp0_ = self->priv->_notes_path;
2722 result = _tmp0_;
2723 return result;
2724 }
2725
2726 void
xnp_application_set_notes_path(XnpApplication * self,const gchar * value)2727 xnp_application_set_notes_path (XnpApplication* self,
2728 const gchar* value)
2729 {
2730 g_return_if_fail (self != NULL);
2731 if (g_strcmp0 (value, xnp_application_get_notes_path (self)) != 0) {
2732 gchar* _tmp0_;
2733 _tmp0_ = g_strdup (value);
2734 _g_free0 (self->priv->_notes_path);
2735 self->priv->_notes_path = _tmp0_;
2736 g_object_notify_by_pspec ((GObject *) self, xnp_application_properties[XNP_APPLICATION_NOTES_PATH_PROPERTY]);
2737 }
2738 }
2739
2740 const gchar*
xnp_application_get_config_file(XnpApplication * self)2741 xnp_application_get_config_file (XnpApplication* self)
2742 {
2743 const gchar* result;
2744 const gchar* _tmp0_;
2745 g_return_val_if_fail (self != NULL, NULL);
2746 _tmp0_ = self->priv->_config_file;
2747 result = _tmp0_;
2748 return result;
2749 }
2750
2751 static void
xnp_application_set_config_file(XnpApplication * self,const gchar * value)2752 xnp_application_set_config_file (XnpApplication* self,
2753 const gchar* value)
2754 {
2755 g_return_if_fail (self != NULL);
2756 if (g_strcmp0 (value, xnp_application_get_config_file (self)) != 0) {
2757 gchar* _tmp0_;
2758 _tmp0_ = g_strdup (value);
2759 _g_free0 (self->priv->_config_file);
2760 self->priv->_config_file = _tmp0_;
2761 g_object_notify_by_pspec ((GObject *) self, xnp_application_properties[XNP_APPLICATION_CONFIG_FILE_PROPERTY]);
2762 }
2763 }
2764
2765 static void
_xnp_application_quit_xfce_posix_signal_handler(gint signal,gpointer self)2766 _xnp_application_quit_xfce_posix_signal_handler (gint signal,
2767 gpointer self)
2768 {
2769 xnp_application_quit ((XnpApplication*) self);
2770 }
2771
2772 static void
_xnp_application___lambda34_(XnpApplication * self)2773 _xnp_application___lambda34_ (XnpApplication* self)
2774 {
2775 xnp_application_update_color (self);
2776 }
2777
2778 static void
__xnp_application___lambda34__xfconf_g__channel_property_changed(XfconfChannel * _sender,const gchar * property,GValue * value,gpointer self)2779 __xnp_application___lambda34__xfconf_g__channel_property_changed (XfconfChannel* _sender,
2780 const gchar* property,
2781 GValue* value,
2782 gpointer self)
2783 {
2784 _xnp_application___lambda34_ ((XnpApplication*) self);
2785 }
2786
2787 static void
_xnp_application___lambda35_(XnpApplication * self)2788 _xnp_application___lambda35_ (XnpApplication* self)
2789 {
2790 xnp_application_update_color (self);
2791 }
2792
2793 static void
__xnp_application___lambda35__g_object_notify(GObject * _sender,GParamSpec * pspec,gpointer self)2794 __xnp_application___lambda35__g_object_notify (GObject* _sender,
2795 GParamSpec* pspec,
2796 gpointer self)
2797 {
2798 _xnp_application___lambda35_ ((XnpApplication*) self);
2799 }
2800
2801 static void
_xnp_application___lambda36_(XnpApplication * self)2802 _xnp_application___lambda36_ (XnpApplication* self)
2803 {
2804 xnp_application_update_notes_path (self);
2805 }
2806
2807 static void
__xnp_application___lambda36__xfconf_g__channel_property_changed(XfconfChannel * _sender,const gchar * property,GValue * value,gpointer self)2808 __xnp_application___lambda36__xfconf_g__channel_property_changed (XfconfChannel* _sender,
2809 const gchar* property,
2810 GValue* value,
2811 gpointer self)
2812 {
2813 _xnp_application___lambda36_ ((XnpApplication*) self);
2814 }
2815
2816 static GObject *
xnp_application_constructor(GType type,guint n_construct_properties,GObjectConstructParam * construct_properties)2817 xnp_application_constructor (GType type,
2818 guint n_construct_properties,
2819 GObjectConstructParam * construct_properties)
2820 {
2821 GObject * obj;
2822 GObjectClass * parent_class;
2823 XnpApplication * self;
2824 XfconfChannel* _tmp4_;
2825 XfconfChannel* _tmp5_;
2826 GtkSettings* _tmp6_;
2827 const gchar* _tmp7_;
2828 XfconfChannel* _tmp14_;
2829 gchar* name = NULL;
2830 gboolean found = FALSE;
2831 GError* _inner_error0_ = NULL;
2832 parent_class = G_OBJECT_CLASS (xnp_application_parent_class);
2833 obj = parent_class->constructor (type, n_construct_properties, construct_properties);
2834 self = G_TYPE_CHECK_INSTANCE_CAST (obj, XNP_TYPE_APPLICATION, XnpApplication);
2835 {
2836 xfce_posix_signal_handler_init (&_inner_error0_);
2837 if (G_UNLIKELY (_inner_error0_ != NULL)) {
2838 goto __catch0_g_error;
2839 }
2840 xfce_posix_signal_handler_set_handler ((gint) SIGTERM, _xnp_application_quit_xfce_posix_signal_handler, self, &_inner_error0_);
2841 if (G_UNLIKELY (_inner_error0_ != NULL)) {
2842 goto __catch0_g_error;
2843 }
2844 xfce_posix_signal_handler_set_handler ((gint) SIGINT, _xnp_application_quit_xfce_posix_signal_handler, self, &_inner_error0_);
2845 if (G_UNLIKELY (_inner_error0_ != NULL)) {
2846 goto __catch0_g_error;
2847 }
2848 }
2849 goto __finally0;
2850 __catch0_g_error:
2851 {
2852 GError* e = NULL;
2853 GError* _tmp0_;
2854 const gchar* _tmp1_;
2855 e = _inner_error0_;
2856 _inner_error0_ = NULL;
2857 _tmp0_ = e;
2858 _tmp1_ = _tmp0_->message;
2859 g_critical ("application.vala:40: Unable to connect to UNIX signals. %s", _tmp1_);
2860 _g_error_free0 (e);
2861 }
2862 __finally0:
2863 if (G_UNLIKELY (_inner_error0_ != NULL)) {
2864 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);
2865 g_clear_error (&_inner_error0_);
2866 }
2867 {
2868 xfconf_init (&_inner_error0_);
2869 if (G_UNLIKELY (_inner_error0_ != NULL)) {
2870 goto __catch1_g_error;
2871 }
2872 }
2873 goto __finally1;
2874 __catch1_g_error:
2875 {
2876 GError* e = NULL;
2877 GError* _tmp2_;
2878 const gchar* _tmp3_;
2879 e = _inner_error0_;
2880 _inner_error0_ = NULL;
2881 _tmp2_ = e;
2882 _tmp3_ = _tmp2_->message;
2883 g_critical ("application.vala:47: %s", _tmp3_);
2884 _g_error_free0 (e);
2885 }
2886 __finally1:
2887 if (G_UNLIKELY (_inner_error0_ != NULL)) {
2888 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);
2889 g_clear_error (&_inner_error0_);
2890 }
2891 _tmp4_ = xfconf_channel_new_with_property_base ("xfce4-panel", "/plugins/notes");
2892 _g_object_unref0 (self->priv->xfconf_channel);
2893 self->priv->xfconf_channel = _tmp4_;
2894 xnp_application_update_color (self);
2895 _tmp5_ = self->priv->xfconf_channel;
2896 g_signal_connect_object (_tmp5_, "property-changed::/global/background-color", (GCallback) __xnp_application___lambda34__xfconf_g__channel_property_changed, self, 0);
2897 _tmp6_ = gtk_settings_get_default ();
2898 g_signal_connect_object ((GObject*) _tmp6_, "notify::gtk-theme-name", (GCallback) __xnp_application___lambda35__g_object_notify, self, 0);
2899 _tmp7_ = self->priv->_notes_path;
2900 if (_tmp7_ == NULL) {
2901 gchar* default_path = NULL;
2902 const gchar* _tmp8_;
2903 gchar* _tmp9_;
2904 XfconfChannel* _tmp10_;
2905 const gchar* _tmp11_;
2906 gchar* _tmp12_;
2907 gchar* _tmp13_;
2908 _tmp8_ = g_get_user_data_dir ();
2909 _tmp9_ = g_strdup_printf ("%s/notes", _tmp8_);
2910 default_path = _tmp9_;
2911 _tmp10_ = self->priv->xfconf_channel;
2912 _tmp11_ = default_path;
2913 _tmp12_ = xfconf_channel_get_string (_tmp10_, "/global/notes-path", _tmp11_);
2914 _tmp13_ = _tmp12_;
2915 xnp_application_set_notes_path (self, _tmp13_);
2916 _g_free0 (_tmp13_);
2917 _g_free0 (default_path);
2918 }
2919 _tmp14_ = self->priv->xfconf_channel;
2920 g_signal_connect_object (_tmp14_, "property-changed::/global/notes-path", (GCallback) __xnp_application___lambda36__xfconf_g__channel_property_changed, self, 0);
2921 found = FALSE;
2922 {
2923 GDir* dir = NULL;
2924 const gchar* _tmp15_;
2925 GDir* _tmp16_;
2926 _tmp15_ = self->priv->_notes_path;
2927 _tmp16_ = g_dir_open (_tmp15_, (guint) 0, &_inner_error0_);
2928 dir = _tmp16_;
2929 if (G_UNLIKELY (_inner_error0_ != NULL)) {
2930 goto __catch2_g_error;
2931 }
2932 while (TRUE) {
2933 GDir* _tmp17_;
2934 const gchar* _tmp18_;
2935 gchar* _tmp19_;
2936 const gchar* _tmp20_;
2937 const gchar* _tmp21_;
2938 XnpWindow* _tmp22_;
2939 XnpWindow* _tmp23_;
2940 _tmp17_ = dir;
2941 _tmp18_ = g_dir_read_name (_tmp17_);
2942 _tmp19_ = g_strdup (_tmp18_);
2943 _g_free0 (name);
2944 name = _tmp19_;
2945 _tmp20_ = name;
2946 if (!(_tmp20_ != NULL)) {
2947 break;
2948 }
2949 _tmp21_ = name;
2950 _tmp22_ = xnp_application_create_window (self, _tmp21_);
2951 _tmp23_ = _tmp22_;
2952 _g_object_unref0 (_tmp23_);
2953 found = TRUE;
2954 }
2955 _g_dir_close0 (dir);
2956 }
2957 goto __finally2;
2958 __catch2_g_error:
2959 {
2960 const gchar* _tmp24_;
2961 g_clear_error (&_inner_error0_);
2962 _tmp24_ = self->priv->_notes_path;
2963 g_mkdir_with_parents (_tmp24_, 0700);
2964 }
2965 __finally2:
2966 if (G_UNLIKELY (_inner_error0_ != NULL)) {
2967 _g_free0 (name);
2968 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);
2969 g_clear_error (&_inner_error0_);
2970 }
2971 if (found == FALSE) {
2972 XnpWindow* _tmp25_;
2973 XnpWindow* _tmp26_;
2974 _tmp25_ = xnp_application_create_window (self, NULL);
2975 _tmp26_ = _tmp25_;
2976 _g_object_unref0 (_tmp26_);
2977 }
2978 _g_free0 (name);
2979 return obj;
2980 }
2981
2982 static void
xnp_application_class_init(XnpApplicationClass * klass,gpointer klass_data)2983 xnp_application_class_init (XnpApplicationClass * klass,
2984 gpointer klass_data)
2985 {
2986 xnp_application_parent_class = g_type_class_peek_parent (klass);
2987 g_type_class_adjust_private_offset (klass, &XnpApplication_private_offset);
2988 G_OBJECT_CLASS (klass)->get_property = _vala_xnp_application_get_property;
2989 G_OBJECT_CLASS (klass)->set_property = _vala_xnp_application_set_property;
2990 G_OBJECT_CLASS (klass)->constructor = xnp_application_constructor;
2991 G_OBJECT_CLASS (klass)->finalize = xnp_application_finalize;
2992 g_object_class_install_property (G_OBJECT_CLASS (klass), XNP_APPLICATION_NOTES_PATH_PROPERTY, xnp_application_properties[XNP_APPLICATION_NOTES_PATH_PROPERTY] = g_param_spec_string ("notes-path", "notes-path", "notes-path", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
2993 g_object_class_install_property (G_OBJECT_CLASS (klass), XNP_APPLICATION_CONFIG_FILE_PROPERTY, xnp_application_properties[XNP_APPLICATION_CONFIG_FILE_PROPERTY] = g_param_spec_string ("config-file", "config-file", "config-file", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
2994 }
2995
2996 static void
xnp_application_instance_init(XnpApplication * self,gpointer klass)2997 xnp_application_instance_init (XnpApplication * self,
2998 gpointer klass)
2999 {
3000 self->priv = xnp_application_get_instance_private (self);
3001 }
3002
3003 static void
xnp_application_finalize(GObject * obj)3004 xnp_application_finalize (GObject * obj)
3005 {
3006 XnpApplication * self;
3007 GSList* _tmp0_;
3008 self = G_TYPE_CHECK_INSTANCE_CAST (obj, XNP_TYPE_APPLICATION, XnpApplication);
3009 xnp_application_save_windows_configuration (self);
3010 _g_object_unref0 (self->priv->xfconf_channel);
3011 self->priv->xfconf_channel = NULL;
3012 xfconf_shutdown ();
3013 _tmp0_ = self->priv->window_list;
3014 {
3015 GSList* win_collection = NULL;
3016 GSList* win_it = NULL;
3017 win_collection = _tmp0_;
3018 for (win_it = win_collection; win_it != NULL; win_it = win_it->next) {
3019 XnpWindow* _tmp1_;
3020 XnpWindow* win = NULL;
3021 _tmp1_ = _g_object_ref0 ((XnpWindow*) win_it->data);
3022 win = _tmp1_;
3023 {
3024 XnpWindow* _tmp2_;
3025 _tmp2_ = win;
3026 gtk_widget_destroy ((GtkWidget*) _tmp2_);
3027 _g_object_unref0 (win);
3028 win = NULL;
3029 _g_object_unref0 (win);
3030 }
3031 }
3032 }
3033 (self->priv->window_monitor_list == NULL) ? NULL : (self->priv->window_monitor_list = (_g_slist_free__g_object_unref0_ (self->priv->window_monitor_list), NULL));
3034 (self->priv->window_list == NULL) ? NULL : (self->priv->window_list = (_g_slist_free__g_object_unref0_ (self->priv->window_list), NULL));
3035 _g_free0 (self->priv->_notes_path);
3036 _g_free0 (self->priv->_config_file);
3037 _g_object_unref0 (self->priv->xfconf_channel);
3038 G_OBJECT_CLASS (xnp_application_parent_class)->finalize (obj);
3039 }
3040
3041 static GType
xnp_application_get_type_once(void)3042 xnp_application_get_type_once (void)
3043 {
3044 static const GTypeInfo g_define_type_info = { sizeof (XnpApplicationClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xnp_application_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XnpApplication), 0, (GInstanceInitFunc) xnp_application_instance_init, NULL };
3045 GType xnp_application_type_id;
3046 xnp_application_type_id = g_type_register_static (G_TYPE_OBJECT, "XnpApplication", &g_define_type_info, 0);
3047 XnpApplication_private_offset = g_type_add_instance_private (xnp_application_type_id, sizeof (XnpApplicationPrivate));
3048 return xnp_application_type_id;
3049 }
3050
3051 GType
xnp_application_get_type(void)3052 xnp_application_get_type (void)
3053 {
3054 static volatile gsize xnp_application_type_id__volatile = 0;
3055 if (g_once_init_enter (&xnp_application_type_id__volatile)) {
3056 GType xnp_application_type_id;
3057 xnp_application_type_id = xnp_application_get_type_once ();
3058 g_once_init_leave (&xnp_application_type_id__volatile, xnp_application_type_id);
3059 }
3060 return xnp_application_type_id__volatile;
3061 }
3062
3063 static void
_vala_xnp_application_get_property(GObject * object,guint property_id,GValue * value,GParamSpec * pspec)3064 _vala_xnp_application_get_property (GObject * object,
3065 guint property_id,
3066 GValue * value,
3067 GParamSpec * pspec)
3068 {
3069 XnpApplication * self;
3070 self = G_TYPE_CHECK_INSTANCE_CAST (object, XNP_TYPE_APPLICATION, XnpApplication);
3071 switch (property_id) {
3072 case XNP_APPLICATION_NOTES_PATH_PROPERTY:
3073 g_value_set_string (value, xnp_application_get_notes_path (self));
3074 break;
3075 case XNP_APPLICATION_CONFIG_FILE_PROPERTY:
3076 g_value_set_string (value, xnp_application_get_config_file (self));
3077 break;
3078 default:
3079 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
3080 break;
3081 }
3082 }
3083
3084 static void
_vala_xnp_application_set_property(GObject * object,guint property_id,const GValue * value,GParamSpec * pspec)3085 _vala_xnp_application_set_property (GObject * object,
3086 guint property_id,
3087 const GValue * value,
3088 GParamSpec * pspec)
3089 {
3090 XnpApplication * self;
3091 self = G_TYPE_CHECK_INSTANCE_CAST (object, XNP_TYPE_APPLICATION, XnpApplication);
3092 switch (property_id) {
3093 case XNP_APPLICATION_NOTES_PATH_PROPERTY:
3094 xnp_application_set_notes_path (self, g_value_get_string (value));
3095 break;
3096 case XNP_APPLICATION_CONFIG_FILE_PROPERTY:
3097 xnp_application_set_config_file (self, g_value_get_string (value));
3098 break;
3099 default:
3100 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
3101 break;
3102 }
3103 }
3104
3105 static void
_vala_array_destroy(gpointer array,gint array_length,GDestroyNotify destroy_func)3106 _vala_array_destroy (gpointer array,
3107 gint array_length,
3108 GDestroyNotify destroy_func)
3109 {
3110 if ((array != NULL) && (destroy_func != NULL)) {
3111 gint i;
3112 for (i = 0; i < array_length; i = i + 1) {
3113 if (((gpointer*) array)[i] != NULL) {
3114 destroy_func (((gpointer*) array)[i]);
3115 }
3116 }
3117 }
3118 }
3119
3120 static void
_vala_array_free(gpointer array,gint array_length,GDestroyNotify destroy_func)3121 _vala_array_free (gpointer array,
3122 gint array_length,
3123 GDestroyNotify destroy_func)
3124 {
3125 _vala_array_destroy (array, array_length, destroy_func);
3126 g_free (array);
3127 }
3128
3129