1 /* plugin.c generated by valac 0.34.9, the Vala compiler
2  * generated from plugin.vala, do not modify */
3 
4 /*
5  * plugin.vala - This file is part of the Geany MultiTerm plugin
6  *
7  * Copyright (c) 2012 Matthew Brush <matt@geany.org>.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22  * MA 02110-1301, USA.
23  */
24 
25 #include <glib.h>
26 #include <glib-object.h>
27 #include "multiterm.h"
28 #include <gtk/gtk.h>
29 #include <geanyplugin.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <glib/gi18n-lib.h>
33 #include <glib/gstdio.h>
34 
35 #define __g_list_free__g_object_unref0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__g_object_unref0_ (var), NULL)))
36 #define _g_free0(var) (var = (g_free (var), NULL))
37 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
38 #define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
39 
40 
41 GeanyPlugin* geany_plugin = NULL;
42 GeanyData* geany_data = NULL;
43 GeanyFunctions* geany_functions = NULL;
44 extern GList* toplevel_widgets;
45 GList* toplevel_widgets = NULL;
46 
47 static void _g_object_unref0_ (gpointer var);
48 static void _g_list_free__g_object_unref0_ (GList* self);
49 
50 
geany_vala_plugin_VERSION_CHECK(gint abi_version,gint api_required)51 static gint geany_vala_plugin_VERSION_CHECK (gint abi_version, gint api_required) {
52 	gint result = 0;
53 	gint _tmp0_ = 0;
54 	gint _tmp1_ = 0;
55 	gint _tmp2_ = 0;
56 	_tmp0_ = abi_version;
57 	_tmp1_ = GEANY_ABI_VERSION;
58 	if (_tmp0_ != _tmp1_) {
59 		result = -1;
60 		return result;
61 	}
62 	_tmp2_ = api_required;
63 	result = _tmp2_;
64 	return result;
65 }
66 
67 
plugin_version_check(gint abi_version)68 gint plugin_version_check (gint abi_version) {
69 	gint result = 0;
70 	gint _tmp0_ = 0;
71 	gint _tmp1_ = 0;
72 	_tmp0_ = abi_version;
73 	_tmp1_ = geany_vala_plugin_VERSION_CHECK (_tmp0_, 185);
74 	result = _tmp1_;
75 	return result;
76 }
77 
78 
geany_vala_plugin_SET_INFO(PluginInfo * self,const gchar * name,const gchar * description,const gchar * version,const gchar * author)79 static void geany_vala_plugin_SET_INFO (PluginInfo* self, const gchar* name, const gchar* description, const gchar* version, const gchar* author) {
80 	const gchar* _tmp0_ = NULL;
81 	const gchar* _tmp1_ = NULL;
82 	const gchar* _tmp2_ = NULL;
83 	const gchar* _tmp3_ = NULL;
84 	g_return_if_fail (self != NULL);
85 	g_return_if_fail (name != NULL);
86 	_tmp0_ = name;
87 	self->name = _tmp0_;
88 	_tmp1_ = description;
89 	self->description = _tmp1_;
90 	_tmp2_ = version;
91 	self->version = _tmp2_;
92 	_tmp3_ = author;
93 	self->author = _tmp3_;
94 }
95 
96 
plugin_set_info(PluginInfo * info)97 void plugin_set_info (PluginInfo* info) {
98 	PluginInfo* _tmp0_ = NULL;
99 	const gchar* _tmp1_ = NULL;
100 	const gchar* _tmp2_ = NULL;
101 	g_return_if_fail (info != NULL);
102 	main_locale_init (LOCALEDIR, GETTEXT_PACKAGE);
103 	_tmp0_ = info;
104 	_tmp1_ = _ ("MultiTerm");
105 	_tmp2_ = _ ("Multi-tabbed virtual terminal emulator.");
106 	geany_vala_plugin_SET_INFO (_tmp0_, _tmp1_, _tmp2_, "0.1", "Matthew Brush <matt@geany.org>");
107 }
108 
109 
_g_object_unref0_(gpointer var)110 static void _g_object_unref0_ (gpointer var) {
111 	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
112 }
113 
114 
_g_list_free__g_object_unref0_(GList * self)115 static void _g_list_free__g_object_unref0_ (GList* self) {
116 	g_list_foreach (self, (GFunc) _g_object_unref0_, NULL);
117 	g_list_free (self);
118 }
119 
120 
_g_object_ref0(gpointer self)121 static gpointer _g_object_ref0 (gpointer self) {
122 	return self ? g_object_ref (self) : NULL;
123 }
124 
125 
geany_vala_plugin_main_widgets_get_message_window_notebook(GeanyMainWidgets * self)126 static GtkNotebook* geany_vala_plugin_main_widgets_get_message_window_notebook (GeanyMainWidgets* self) {
127 	GtkNotebook* result;
128 	GtkWidget* _tmp0_ = NULL;
129 	g_return_val_if_fail (self != NULL, NULL);
130 	_tmp0_ = self->message_window_notebook;
131 	result = G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, GTK_TYPE_NOTEBOOK) ? ((GtkNotebook*) _tmp0_) : NULL;
132 	return result;
133 }
134 
135 
geany_vala_plugin_main_widgets_get_sidebar_notebook(GeanyMainWidgets * self)136 static GtkNotebook* geany_vala_plugin_main_widgets_get_sidebar_notebook (GeanyMainWidgets* self) {
137 	GtkNotebook* result;
138 	GtkWidget* _tmp0_ = NULL;
139 	g_return_val_if_fail (self != NULL, NULL);
140 	_tmp0_ = self->sidebar_notebook;
141 	result = G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, GTK_TYPE_NOTEBOOK) ? ((GtkNotebook*) _tmp0_) : NULL;
142 	return result;
143 }
144 
145 
plugin_init(GeanyData * data)146 void plugin_init (GeanyData* data) {
147 	gchar* config_file = NULL;
148 	gchar* config_dir = NULL;
149 	GtkLabel* label = NULL;
150 	GtkAlignment* align = NULL;
151 	MultiTermNotebook* notebook = NULL;
152 	GeanyPlugin* _tmp0_ = NULL;
153 	GeanyData* _tmp1_ = NULL;
154 	GeanyApp* _tmp2_ = NULL;
155 	const gchar* _tmp3_ = NULL;
156 	gchar* _tmp4_ = NULL;
157 	const gchar* _tmp5_ = NULL;
158 	gchar* _tmp6_ = NULL;
159 	const gchar* _tmp7_ = NULL;
160 	GtkAlignment* _tmp14_ = NULL;
161 	const gchar* _tmp15_ = NULL;
162 	MultiTermNotebook* _tmp16_ = NULL;
163 	GtkAlignment* _tmp17_ = NULL;
164 	MultiTermNotebook* _tmp18_ = NULL;
165 	GtkAlignment* _tmp19_ = NULL;
166 	GtkAlignment* _tmp20_ = NULL;
167 	GtkWidget* _tmp21_ = NULL;
168 	const gchar* _tmp22_ = NULL;
169 	GtkLabel* _tmp23_ = NULL;
170 	MultiTermNotebook* _tmp24_ = NULL;
171 	GtkLabel* _tmp25_ = NULL;
172 	GtkLabel* _tmp26_ = NULL;
173 	MultiTermNotebook* _tmp27_ = NULL;
174 	GeanyData* _tmp28_ = NULL;
175 	GeanyMainWidgets* _tmp29_ = NULL;
176 	GtkNotebook* _tmp30_ = NULL;
177 	GtkNotebook* _tmp31_ = NULL;
178 	GtkNotebook* _tmp32_ = NULL;
179 	MultiTermNotebook* _tmp33_ = NULL;
180 	GeanyData* _tmp34_ = NULL;
181 	GeanyMainWidgets* _tmp35_ = NULL;
182 	GtkNotebook* _tmp36_ = NULL;
183 	GtkNotebook* _tmp37_ = NULL;
184 	GtkNotebook* _tmp38_ = NULL;
185 	MultiTermNotebook* _tmp39_ = NULL;
186 	MultiTermConfig* _tmp40_ = NULL;
187 	gchar* _tmp41_ = NULL;
188 	gchar* _tmp42_ = NULL;
189 	gchar* _tmp43_ = NULL;
190 	gboolean _tmp44_ = FALSE;
191 	GError * _inner_error_ = NULL;
192 	g_return_if_fail (data != NULL);
193 	_tmp0_ = geany_plugin;
194 	plugin_module_make_resident (_tmp0_);
195 	__g_list_free__g_object_unref0_0 (toplevel_widgets);
196 	toplevel_widgets = NULL;
197 	_tmp1_ = geany_data;
198 	_tmp2_ = _tmp1_->app;
199 	_tmp3_ = _tmp2_->configdir;
200 	_tmp4_ = g_build_filename (_tmp3_, "plugins", "multiterm", NULL);
201 	_g_free0 (config_dir);
202 	config_dir = _tmp4_;
203 	_tmp5_ = config_dir;
204 	_tmp6_ = g_build_filename (_tmp5_, "multiterm.conf", NULL);
205 	_g_free0 (config_file);
206 	config_file = _tmp6_;
207 	_tmp7_ = config_dir;
208 	g_mkdir_with_parents (_tmp7_, 0755);
209 	{
210 		const gchar* _tmp8_ = NULL;
211 		gboolean _tmp9_ = FALSE;
212 		_tmp8_ = config_file;
213 		_tmp9_ = g_file_test (_tmp8_, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR);
214 		if (!_tmp9_) {
215 			const gchar* _tmp10_ = NULL;
216 			_tmp10_ = config_file;
217 			g_file_set_contents (_tmp10_, MULTI_TERM_default_config, (gssize) -1, &_inner_error_);
218 			if (G_UNLIKELY (_inner_error_ != NULL)) {
219 				if (_inner_error_->domain == G_FILE_ERROR) {
220 					goto __catch6_g_file_error;
221 				}
222 				_g_object_unref0 (notebook);
223 				_g_object_unref0 (align);
224 				_g_object_unref0 (label);
225 				_g_free0 (config_dir);
226 				_g_free0 (config_file);
227 				g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
228 				g_clear_error (&_inner_error_);
229 				return;
230 			}
231 		}
232 	}
233 	goto __finally6;
234 	__catch6_g_file_error:
235 	{
236 		GError* err = NULL;
237 		const gchar* _tmp11_ = NULL;
238 		GError* _tmp12_ = NULL;
239 		const gchar* _tmp13_ = NULL;
240 		err = _inner_error_;
241 		_inner_error_ = NULL;
242 		_tmp11_ = _ ("Unable to write default config file: %s");
243 		_tmp12_ = err;
244 		_tmp13_ = _tmp12_->message;
245 		g_warning (_tmp11_, _tmp13_);
246 		_g_error_free0 (err);
247 	}
248 	__finally6:
249 	if (G_UNLIKELY (_inner_error_ != NULL)) {
250 		_g_object_unref0 (notebook);
251 		_g_object_unref0 (align);
252 		_g_object_unref0 (label);
253 		_g_free0 (config_dir);
254 		_g_free0 (config_file);
255 		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
256 		g_clear_error (&_inner_error_);
257 		return;
258 	}
259 	_tmp14_ = (GtkAlignment*) gtk_alignment_new (0.5f, 0.5f, 1.0f, 1.0f);
260 	g_object_ref_sink (_tmp14_);
261 	_g_object_unref0 (align);
262 	align = _tmp14_;
263 	_tmp15_ = config_file;
264 	_tmp16_ = multi_term_notebook_new (_tmp15_);
265 	g_object_ref_sink (_tmp16_);
266 	_g_object_unref0 (notebook);
267 	notebook = _tmp16_;
268 	_tmp17_ = align;
269 	_tmp18_ = notebook;
270 	gtk_container_add ((GtkContainer*) _tmp17_, (GtkWidget*) (G_TYPE_CHECK_INSTANCE_TYPE (_tmp18_, GTK_TYPE_NOTEBOOK) ? ((GtkNotebook*) _tmp18_) : NULL));
271 	_tmp19_ = align;
272 	gtk_widget_show_all ((GtkWidget*) _tmp19_);
273 	_tmp20_ = align;
274 	_tmp21_ = _g_object_ref0 ((GtkWidget*) _tmp20_);
275 	toplevel_widgets = g_list_append (toplevel_widgets, _tmp21_);
276 	_tmp22_ = _ ("MultiTerm");
277 	_tmp23_ = (GtkLabel*) gtk_label_new (_tmp22_);
278 	g_object_ref_sink (_tmp23_);
279 	_g_object_unref0 (label);
280 	label = _tmp23_;
281 	_tmp24_ = notebook;
282 	_tmp25_ = label;
283 	_tmp26_ = _g_object_ref0 (_tmp25_);
284 	g_object_set_data_full ((GObject*) _tmp24_, "label", _tmp26_, g_object_unref);
285 	_tmp27_ = notebook;
286 	_tmp28_ = data;
287 	_tmp29_ = _tmp28_->main_widgets;
288 	_tmp30_ = geany_vala_plugin_main_widgets_get_message_window_notebook (_tmp29_);
289 	_tmp31_ = _tmp30_;
290 	_tmp32_ = _g_object_ref0 (_tmp31_);
291 	g_object_set_data_full ((GObject*) _tmp27_, "msgwin_notebook", _tmp32_, g_object_unref);
292 	_tmp33_ = notebook;
293 	_tmp34_ = data;
294 	_tmp35_ = _tmp34_->main_widgets;
295 	_tmp36_ = geany_vala_plugin_main_widgets_get_sidebar_notebook (_tmp35_);
296 	_tmp37_ = _tmp36_;
297 	_tmp38_ = _g_object_ref0 (_tmp37_);
298 	g_object_set_data_full ((GObject*) _tmp33_, "sidebar_notebook", _tmp38_, g_object_unref);
299 	_tmp39_ = notebook;
300 	_tmp40_ = _tmp39_->cfg;
301 	_tmp41_ = multi_term_config_get_location (_tmp40_);
302 	_tmp42_ = _tmp41_;
303 	_tmp43_ = _tmp42_;
304 	_tmp44_ = g_strcmp0 (_tmp43_, "msgwin") == 0;
305 	_g_free0 (_tmp43_);
306 	if (_tmp44_) {
307 		GeanyData* _tmp45_ = NULL;
308 		GeanyMainWidgets* _tmp46_ = NULL;
309 		GtkNotebook* _tmp47_ = NULL;
310 		GtkNotebook* _tmp48_ = NULL;
311 		GtkAlignment* _tmp49_ = NULL;
312 		GtkLabel* _tmp50_ = NULL;
313 		GeanyData* _tmp51_ = NULL;
314 		GeanyMainWidgets* _tmp52_ = NULL;
315 		GtkNotebook* _tmp53_ = NULL;
316 		GtkNotebook* _tmp54_ = NULL;
317 		GeanyData* _tmp55_ = NULL;
318 		GeanyMainWidgets* _tmp56_ = NULL;
319 		GtkNotebook* _tmp57_ = NULL;
320 		GtkNotebook* _tmp58_ = NULL;
321 		GtkAlignment* _tmp59_ = NULL;
322 		gint _tmp60_ = 0;
323 		_tmp45_ = data;
324 		_tmp46_ = _tmp45_->main_widgets;
325 		_tmp47_ = geany_vala_plugin_main_widgets_get_message_window_notebook (_tmp46_);
326 		_tmp48_ = _tmp47_;
327 		_tmp49_ = align;
328 		_tmp50_ = label;
329 		gtk_notebook_append_page (_tmp48_, (GtkWidget*) _tmp49_, (GtkWidget*) _tmp50_);
330 		_tmp51_ = data;
331 		_tmp52_ = _tmp51_->main_widgets;
332 		_tmp53_ = geany_vala_plugin_main_widgets_get_message_window_notebook (_tmp52_);
333 		_tmp54_ = _tmp53_;
334 		_tmp55_ = data;
335 		_tmp56_ = _tmp55_->main_widgets;
336 		_tmp57_ = geany_vala_plugin_main_widgets_get_message_window_notebook (_tmp56_);
337 		_tmp58_ = _tmp57_;
338 		_tmp59_ = align;
339 		_tmp60_ = gtk_notebook_page_num (_tmp58_, (GtkWidget*) _tmp59_);
340 		gtk_notebook_set_current_page (_tmp54_, _tmp60_);
341 	} else {
342 		GeanyData* _tmp61_ = NULL;
343 		GeanyMainWidgets* _tmp62_ = NULL;
344 		GtkNotebook* _tmp63_ = NULL;
345 		GtkNotebook* _tmp64_ = NULL;
346 		GtkAlignment* _tmp65_ = NULL;
347 		GtkLabel* _tmp66_ = NULL;
348 		GeanyData* _tmp67_ = NULL;
349 		GeanyMainWidgets* _tmp68_ = NULL;
350 		GtkNotebook* _tmp69_ = NULL;
351 		GtkNotebook* _tmp70_ = NULL;
352 		GeanyData* _tmp71_ = NULL;
353 		GeanyMainWidgets* _tmp72_ = NULL;
354 		GtkNotebook* _tmp73_ = NULL;
355 		GtkNotebook* _tmp74_ = NULL;
356 		GtkAlignment* _tmp75_ = NULL;
357 		gint _tmp76_ = 0;
358 		_tmp61_ = data;
359 		_tmp62_ = _tmp61_->main_widgets;
360 		_tmp63_ = geany_vala_plugin_main_widgets_get_sidebar_notebook (_tmp62_);
361 		_tmp64_ = _tmp63_;
362 		_tmp65_ = align;
363 		_tmp66_ = label;
364 		gtk_notebook_append_page (_tmp64_, (GtkWidget*) _tmp65_, (GtkWidget*) _tmp66_);
365 		_tmp67_ = data;
366 		_tmp68_ = _tmp67_->main_widgets;
367 		_tmp69_ = geany_vala_plugin_main_widgets_get_sidebar_notebook (_tmp68_);
368 		_tmp70_ = _tmp69_;
369 		_tmp71_ = data;
370 		_tmp72_ = _tmp71_->main_widgets;
371 		_tmp73_ = geany_vala_plugin_main_widgets_get_sidebar_notebook (_tmp72_);
372 		_tmp74_ = _tmp73_;
373 		_tmp75_ = align;
374 		_tmp76_ = gtk_notebook_page_num (_tmp74_, (GtkWidget*) _tmp75_);
375 		gtk_notebook_set_current_page (_tmp70_, _tmp76_);
376 	}
377 	_g_object_unref0 (notebook);
378 	_g_object_unref0 (align);
379 	_g_object_unref0 (label);
380 	_g_free0 (config_dir);
381 	_g_free0 (config_file);
382 }
383 
384 
plugin_cleanup(void)385 void plugin_cleanup (void) {
386 	GList* _tmp0_ = NULL;
387 	_tmp0_ = toplevel_widgets;
388 	{
389 		GList* wid_collection = NULL;
390 		GList* wid_it = NULL;
391 		wid_collection = _tmp0_;
392 		for (wid_it = wid_collection; wid_it != NULL; wid_it = wid_it->next) {
393 			GtkWidget* _tmp1_ = NULL;
394 			GtkWidget* wid = NULL;
395 			_tmp1_ = _g_object_ref0 ((GtkWidget*) wid_it->data);
396 			wid = _tmp1_;
397 			{
398 				GtkWidget* _tmp2_ = NULL;
399 				_tmp2_ = wid;
400 				gtk_object_destroy ((GtkObject*) _tmp2_);
401 				_g_object_unref0 (wid);
402 			}
403 		}
404 	}
405 	__g_list_free__g_object_unref0_0 (toplevel_widgets);
406 	toplevel_widgets = NULL;
407 }
408 
409 
410 
411