1 /* tab-label.c generated by valac 0.34.9, the Vala compiler
2 * generated from tab-label.vala, do not modify */
3
4 /*
5 * tab-label.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 <stdlib.h>
30 #include <string.h>
31 #include <pango/pango.h>
32 #include <glib/gi18n-lib.h>
33
34 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
35
36 struct _MultiTermTabLabelPrivate {
37 GtkButton* btn;
38 };
39
40
41 static gpointer multi_term_tab_label_parent_class = NULL;
42
43 #define MULTI_TERM_TAB_LABEL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MULTI_TERM_TYPE_TAB_LABEL, MultiTermTabLabelPrivate))
44 enum {
45 MULTI_TERM_TAB_LABEL_DUMMY_PROPERTY,
46 MULTI_TERM_TAB_LABEL_TEXT,
47 MULTI_TERM_TAB_LABEL_BUTTON
48 };
49 static void multi_term_tab_label_on_button_clicked (MultiTermTabLabel* self);
50 static void multi_term_tab_label_on_button_style_set (MultiTermTabLabel* self, GtkStyle* previous_style);
51 static void _multi_term_tab_label_on_button_clicked_gtk_button_clicked (GtkButton* _sender, gpointer self);
52 static void _multi_term_tab_label_on_button_style_set_gtk_widget_style_set (GtkWidget* _sender, GtkStyle* previous_style, gpointer self);
53 static void multi_term_tab_label_finalize (GObject* obj);
54 static void _vala_multi_term_tab_label_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
55 static void _vala_multi_term_tab_label_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
56
57
_g_object_ref0(gpointer self)58 static gpointer _g_object_ref0 (gpointer self) {
59 return self ? g_object_ref (self) : NULL;
60 }
61
62
multi_term_tab_label_on_button_clicked(MultiTermTabLabel * self)63 static void multi_term_tab_label_on_button_clicked (MultiTermTabLabel* self) {
64 MultiTermTerminal* term = NULL;
65 gconstpointer _tmp0_ = NULL;
66 MultiTermTerminal* _tmp1_ = NULL;
67 MultiTermNotebook* nb = NULL;
68 GtkContainer* _tmp2_ = NULL;
69 MultiTermNotebook* _tmp3_ = NULL;
70 gint page_num = 0;
71 gint _tmp4_ = 0;
72 g_return_if_fail (self != NULL);
73 _tmp0_ = g_object_get_data ((GObject*) self, "terminal");
74 _tmp1_ = _g_object_ref0 ((MultiTermTerminal*) _tmp0_);
75 term = _tmp1_;
76 _tmp2_ = (GtkContainer*) gtk_widget_get_parent ((GtkWidget*) term);
77 _tmp3_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, MULTI_TERM_TYPE_NOTEBOOK, MultiTermNotebook));
78 nb = _tmp3_;
79 _tmp4_ = gtk_notebook_page_num ((GtkNotebook*) nb, (GtkWidget*) term);
80 page_num = _tmp4_;
81 g_signal_emit_by_name (self, "close-clicked", page_num);
82 _g_object_unref0 (nb);
83 _g_object_unref0 (term);
84 }
85
86
multi_term_tab_label_on_button_style_set(MultiTermTabLabel * self,GtkStyle * previous_style)87 static void multi_term_tab_label_on_button_style_set (MultiTermTabLabel* self, GtkStyle* previous_style) {
88 gint w = 0;
89 gint h = 0;
90 GtkButton* _tmp0_ = NULL;
91 GtkSettings* _tmp1_ = NULL;
92 gint _tmp2_ = 0;
93 gint _tmp3_ = 0;
94 GtkButton* _tmp4_ = NULL;
95 g_return_if_fail (self != NULL);
96 _tmp0_ = self->priv->btn;
97 _tmp1_ = gtk_widget_get_settings ((GtkWidget*) _tmp0_);
98 gtk_icon_size_lookup_for_settings (_tmp1_, GTK_ICON_SIZE_MENU, &_tmp2_, &_tmp3_);
99 w = _tmp2_;
100 h = _tmp3_;
101 _tmp4_ = self->priv->btn;
102 gtk_widget_set_size_request ((GtkWidget*) _tmp4_, w + 2, h + 2);
103 }
104
105
_multi_term_tab_label_on_button_clicked_gtk_button_clicked(GtkButton * _sender,gpointer self)106 static void _multi_term_tab_label_on_button_clicked_gtk_button_clicked (GtkButton* _sender, gpointer self) {
107 multi_term_tab_label_on_button_clicked ((MultiTermTabLabel*) self);
108 }
109
110
_multi_term_tab_label_on_button_style_set_gtk_widget_style_set(GtkWidget * _sender,GtkStyle * previous_style,gpointer self)111 static void _multi_term_tab_label_on_button_style_set_gtk_widget_style_set (GtkWidget* _sender, GtkStyle* previous_style, gpointer self) {
112 multi_term_tab_label_on_button_style_set ((MultiTermTabLabel*) self, previous_style);
113 }
114
115
multi_term_tab_label_construct(GType object_type,const gchar * text)116 MultiTermTabLabel* multi_term_tab_label_construct (GType object_type, const gchar* text) {
117 MultiTermTabLabel * self = NULL;
118 GtkImage* img = NULL;
119 const gchar* _tmp0_ = NULL;
120 GtkLabel* _tmp1_ = NULL;
121 GtkLabel* _tmp2_ = NULL;
122 GtkLabel* _tmp3_ = NULL;
123 GtkLabel* _tmp4_ = NULL;
124 GtkImage* _tmp5_ = NULL;
125 GtkRcStyle* style = NULL;
126 GtkRcStyle* _tmp6_ = NULL;
127 GtkButton* _tmp7_ = NULL;
128 GtkButton* _tmp8_ = NULL;
129 GtkButton* _tmp9_ = NULL;
130 GtkButton* _tmp10_ = NULL;
131 const gchar* _tmp11_ = NULL;
132 GtkButton* _tmp12_ = NULL;
133 GtkButton* _tmp13_ = NULL;
134 GtkButton* _tmp14_ = NULL;
135 GtkButton* _tmp15_ = NULL;
136 GtkButton* _tmp16_ = NULL;
137 g_return_val_if_fail (text != NULL, NULL);
138 self = (MultiTermTabLabel*) g_object_new (object_type, "homogeneous", FALSE, "spacing", 2, NULL);
139 gtk_container_set_border_width ((GtkContainer*) self, (guint) 0);
140 _tmp0_ = text;
141 _tmp1_ = (GtkLabel*) gtk_label_new (_tmp0_);
142 g_object_ref_sink (_tmp1_);
143 _g_object_unref0 (self->label);
144 self->label = _tmp1_;
145 _tmp2_ = self->label;
146 gtk_misc_set_alignment ((GtkMisc*) _tmp2_, 0.0f, 0.5f);
147 _tmp3_ = self->label;
148 gtk_label_set_ellipsize (_tmp3_, PANGO_ELLIPSIZE_END);
149 _tmp4_ = self->label;
150 gtk_box_pack_start ((GtkBox*) self, (GtkWidget*) _tmp4_, TRUE, TRUE, (guint) 0);
151 _tmp5_ = (GtkImage*) gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
152 g_object_ref_sink (_tmp5_);
153 _g_object_unref0 (img);
154 img = _tmp5_;
155 _tmp6_ = gtk_rc_style_new ();
156 style = _tmp6_;
157 style->xthickness = 0;
158 style->ythickness = 0;
159 _tmp7_ = (GtkButton*) gtk_button_new ();
160 g_object_ref_sink (_tmp7_);
161 _g_object_unref0 (self->priv->btn);
162 self->priv->btn = _tmp7_;
163 _tmp8_ = self->priv->btn;
164 gtk_widget_modify_style ((GtkWidget*) _tmp8_, style);
165 _tmp9_ = self->priv->btn;
166 gtk_container_add ((GtkContainer*) _tmp9_, (GtkWidget*) img);
167 _tmp10_ = self->priv->btn;
168 _tmp11_ = _ ("Close terminal");
169 gtk_widget_set_tooltip_text ((GtkWidget*) _tmp10_, _tmp11_);
170 _tmp12_ = self->priv->btn;
171 g_signal_connect_object (_tmp12_, "clicked", (GCallback) _multi_term_tab_label_on_button_clicked_gtk_button_clicked, self, 0);
172 _tmp13_ = self->priv->btn;
173 gtk_button_set_relief (_tmp13_, GTK_RELIEF_NONE);
174 _tmp14_ = self->priv->btn;
175 gtk_button_set_focus_on_click (_tmp14_, FALSE);
176 _tmp15_ = self->priv->btn;
177 g_signal_connect_object ((GtkWidget*) _tmp15_, "style-set", (GCallback) _multi_term_tab_label_on_button_style_set_gtk_widget_style_set, self, 0);
178 _tmp16_ = self->priv->btn;
179 gtk_box_pack_start ((GtkBox*) self, (GtkWidget*) _tmp16_, FALSE, FALSE, (guint) 0);
180 _g_object_unref0 (style);
181 _g_object_unref0 (img);
182 return self;
183 }
184
185
multi_term_tab_label_new(const gchar * text)186 MultiTermTabLabel* multi_term_tab_label_new (const gchar* text) {
187 return multi_term_tab_label_construct (MULTI_TERM_TYPE_TAB_LABEL, text);
188 }
189
190
multi_term_tab_label_get_text(MultiTermTabLabel * self)191 const gchar* multi_term_tab_label_get_text (MultiTermTabLabel* self) {
192 const gchar* result;
193 GtkLabel* _tmp0_ = NULL;
194 const gchar* _tmp1_ = NULL;
195 g_return_val_if_fail (self != NULL, NULL);
196 _tmp0_ = self->label;
197 _tmp1_ = gtk_label_get_label (_tmp0_);
198 result = _tmp1_;
199 return result;
200 }
201
202
multi_term_tab_label_set_text(MultiTermTabLabel * self,const gchar * value)203 void multi_term_tab_label_set_text (MultiTermTabLabel* self, const gchar* value) {
204 GtkLabel* _tmp0_ = NULL;
205 const gchar* _tmp1_ = NULL;
206 g_return_if_fail (self != NULL);
207 _tmp0_ = self->label;
208 _tmp1_ = value;
209 gtk_label_set_label (_tmp0_, _tmp1_);
210 g_object_notify ((GObject *) self, "text");
211 }
212
213
multi_term_tab_label_get_button(MultiTermTabLabel * self)214 GtkButton* multi_term_tab_label_get_button (MultiTermTabLabel* self) {
215 GtkButton* result;
216 GtkButton* _tmp0_ = NULL;
217 g_return_val_if_fail (self != NULL, NULL);
218 _tmp0_ = self->priv->btn;
219 result = _tmp0_;
220 return result;
221 }
222
223
multi_term_tab_label_class_init(MultiTermTabLabelClass * klass)224 static void multi_term_tab_label_class_init (MultiTermTabLabelClass * klass) {
225 multi_term_tab_label_parent_class = g_type_class_peek_parent (klass);
226 g_type_class_add_private (klass, sizeof (MultiTermTabLabelPrivate));
227 G_OBJECT_CLASS (klass)->get_property = _vala_multi_term_tab_label_get_property;
228 G_OBJECT_CLASS (klass)->set_property = _vala_multi_term_tab_label_set_property;
229 G_OBJECT_CLASS (klass)->finalize = multi_term_tab_label_finalize;
230 g_object_class_install_property (G_OBJECT_CLASS (klass), MULTI_TERM_TAB_LABEL_TEXT, g_param_spec_string ("text", "text", "text", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
231 g_object_class_install_property (G_OBJECT_CLASS (klass), MULTI_TERM_TAB_LABEL_BUTTON, g_param_spec_object ("button", "button", "button", GTK_TYPE_BUTTON, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
232 g_signal_new ("close_clicked", MULTI_TERM_TYPE_TAB_LABEL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
233 }
234
235
multi_term_tab_label_instance_init(MultiTermTabLabel * self)236 static void multi_term_tab_label_instance_init (MultiTermTabLabel * self) {
237 self->priv = MULTI_TERM_TAB_LABEL_GET_PRIVATE (self);
238 }
239
240
multi_term_tab_label_finalize(GObject * obj)241 static void multi_term_tab_label_finalize (GObject* obj) {
242 MultiTermTabLabel * self;
243 self = G_TYPE_CHECK_INSTANCE_CAST (obj, MULTI_TERM_TYPE_TAB_LABEL, MultiTermTabLabel);
244 _g_object_unref0 (self->priv->btn);
245 _g_object_unref0 (self->label);
246 G_OBJECT_CLASS (multi_term_tab_label_parent_class)->finalize (obj);
247 }
248
249
multi_term_tab_label_get_type(void)250 GType multi_term_tab_label_get_type (void) {
251 static volatile gsize multi_term_tab_label_type_id__volatile = 0;
252 if (g_once_init_enter (&multi_term_tab_label_type_id__volatile)) {
253 static const GTypeInfo g_define_type_info = { sizeof (MultiTermTabLabelClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) multi_term_tab_label_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MultiTermTabLabel), 0, (GInstanceInitFunc) multi_term_tab_label_instance_init, NULL };
254 GType multi_term_tab_label_type_id;
255 multi_term_tab_label_type_id = g_type_register_static (GTK_TYPE_HBOX, "MultiTermTabLabel", &g_define_type_info, 0);
256 g_once_init_leave (&multi_term_tab_label_type_id__volatile, multi_term_tab_label_type_id);
257 }
258 return multi_term_tab_label_type_id__volatile;
259 }
260
261
_vala_multi_term_tab_label_get_property(GObject * object,guint property_id,GValue * value,GParamSpec * pspec)262 static void _vala_multi_term_tab_label_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
263 MultiTermTabLabel * self;
264 self = G_TYPE_CHECK_INSTANCE_CAST (object, MULTI_TERM_TYPE_TAB_LABEL, MultiTermTabLabel);
265 switch (property_id) {
266 case MULTI_TERM_TAB_LABEL_TEXT:
267 g_value_set_string (value, multi_term_tab_label_get_text (self));
268 break;
269 case MULTI_TERM_TAB_LABEL_BUTTON:
270 g_value_set_object (value, multi_term_tab_label_get_button (self));
271 break;
272 default:
273 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
274 break;
275 }
276 }
277
278
_vala_multi_term_tab_label_set_property(GObject * object,guint property_id,const GValue * value,GParamSpec * pspec)279 static void _vala_multi_term_tab_label_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
280 MultiTermTabLabel * self;
281 self = G_TYPE_CHECK_INSTANCE_CAST (object, MULTI_TERM_TYPE_TAB_LABEL, MultiTermTabLabel);
282 switch (property_id) {
283 case MULTI_TERM_TAB_LABEL_TEXT:
284 multi_term_tab_label_set_text (self, g_value_get_string (value));
285 break;
286 default:
287 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
288 break;
289 }
290 }
291
292
293
294