1 /* trackinformation.c generated by valac, the Vala compiler
2 * generated from trackinformation.vala, do not modify */
4 /* Copyright 2009 Yorba Foundation
6 * This software is licensed under the GNU Lesser General Public License
7 * (version 2.1 or later). See the COPYING file in this distribution.
11 #include <glib-object.h>
12 #include <hildon/hildon.h>
18 #define UI_TYPE_TRACK_INFORMATION (ui_track_information_get_type ())
19 #define UI_TRACK_INFORMATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UI_TYPE_TRACK_INFORMATION, UITrackInformation))
20 #define UI_TRACK_INFORMATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UI_TYPE_TRACK_INFORMATION, UITrackInformationClass))
21 #define UI_IS_TRACK_INFORMATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UI_TYPE_TRACK_INFORMATION))
22 #define UI_IS_TRACK_INFORMATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UI_TYPE_TRACK_INFORMATION))
23 #define UI_TRACK_INFORMATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UI_TYPE_TRACK_INFORMATION, UITrackInformationClass))
25 typedef struct _UITrackInformation UITrackInformation;
26 typedef struct _UITrackInformationClass UITrackInformationClass;
27 typedef struct _UITrackInformationPrivate UITrackInformationPrivate;
28 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
29 #define _g_free0(var) (var = (g_free (var), NULL))
31 struct _UITrackInformation {
32 HildonDialog parent_instance;
33 UITrackInformationPrivate * priv;
36 struct _UITrackInformationClass {
37 HildonDialogClass parent_class;
40 struct _UITrackInformationPrivate {
45 static gpointer ui_track_information_parent_class = NULL;
47 GType ui_track_information_get_type (void);
48 #define UI_TRACK_INFORMATION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UI_TYPE_TRACK_INFORMATION, UITrackInformationPrivate))
50 UI_TRACK_INFORMATION_DUMMY_PROPERTY
52 void ui_track_information_set_track_name (UITrackInformation* self, const char* new_name);
53 char* ui_track_information_get_track_name (UITrackInformation* self);
54 static void ui_track_information_on_entry_changed (UITrackInformation* self);
55 UITrackInformation* ui_track_information_new (void);
56 UITrackInformation* ui_track_information_construct (GType object_type);
57 static void _ui_track_information_on_entry_changed_gtk_editable_changed (GtkEditable* _sender, gpointer self);
58 static GObject * ui_track_information_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
59 static void ui_track_information_finalize (GObject* obj);
63 #line 34 "trackinformation.vala"
64 void ui_track_information_set_track_name (UITrackInformation* self, const char* new_name) {
65 #line 34 "trackinformation.vala"
66 g_return_if_fail (UI_IS_TRACK_INFORMATION (self));
67 #line 34 "trackinformation.vala"
68 g_return_if_fail (new_name != NULL);
69 #line 35 "trackinformation.vala"
70 hildon_entry_set_text (self->priv->entry, new_name);
71 #line 36 "trackinformation.vala"
72 gtk_editable_select_region (GTK_EDITABLE (self->priv->entry), 0, -1);
73 #line 74 "trackinformation.c"
77 #line 1018 "glib-2.0.vapi"
78 static char* string_strip (const char* self) {
79 #line 80 "trackinformation.c"
82 #line 1018 "glib-2.0.vapi"
83 g_return_val_if_fail (self != NULL, NULL);
84 #line 1019 "glib-2.0.vapi"
85 _result_ = g_strdup (self);
86 #line 1020 "glib-2.0.vapi"
87 g_strstrip (_result_);
88 #line 89 "trackinformation.c"
90 #line 1021 "glib-2.0.vapi"
92 #line 93 "trackinformation.c"
96 #line 39 "trackinformation.vala"
97 char* ui_track_information_get_track_name (UITrackInformation* self) {
98 #line 99 "trackinformation.c"
100 #line 39 "trackinformation.vala"
101 g_return_val_if_fail (UI_IS_TRACK_INFORMATION (self), NULL);
102 #line 103 "trackinformation.c"
103 result = string_strip (hildon_entry_get_text (self->priv->entry));
104 #line 40 "trackinformation.vala"
106 #line 107 "trackinformation.c"
110 static glong string_get_length (const char* self) {
112 g_return_val_if_fail (self != NULL, 0L);
113 result = g_utf8_strlen (self, -1);
114 #line 1158 "glib-2.0.vapi"
116 #line 117 "trackinformation.c"
120 #line 43 "trackinformation.vala"
121 static void ui_track_information_on_entry_changed (UITrackInformation* self) {
122 #line 123 "trackinformation.c"
126 #line 43 "trackinformation.vala"
127 g_return_if_fail (UI_IS_TRACK_INFORMATION (self));
128 #line 44 "trackinformation.vala"
129 is_valid = (_tmp1_ = string_get_length (_tmp0_ = ui_track_information_get_track_name (self)) > 0, _g_free0 (_tmp0_), _tmp1_);
130 #line 45 "trackinformation.vala"
131 gtk_dialog_set_response_sensitive (GTK_DIALOG (self), (gint) GTK_RESPONSE_OK, is_valid);
132 #line 133 "trackinformation.c"
136 #line 8 "trackinformation.vala"
137 UITrackInformation* ui_track_information_construct (GType object_type) {
138 #line 139 "trackinformation.c"
139 UITrackInformation * self;
140 self = g_object_newv (object_type, 0, NULL);
145 #line 8 "trackinformation.vala"
146 UITrackInformation* ui_track_information_new (void) {
147 #line 8 "trackinformation.vala"
148 return ui_track_information_construct (UI_TYPE_TRACK_INFORMATION);
149 #line 150 "trackinformation.c"
153 #line 43 "trackinformation.vala"
154 static void _ui_track_information_on_entry_changed_gtk_editable_changed (GtkEditable* _sender, gpointer self) {
155 #line 156 "trackinformation.c"
156 ui_track_information_on_entry_changed (self);
160 static GObject * ui_track_information_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
162 GObjectClass * parent_class;
163 UITrackInformation * self;
164 parent_class = G_OBJECT_CLASS (ui_track_information_parent_class);
165 obj = parent_class->constructor (type, n_construct_properties, construct_properties);
166 self = UI_TRACK_INFORMATION (obj);
171 #line 13 "trackinformation.vala"
172 gtk_window_set_title (GTK_WINDOW (self), "New Track");
173 #line 14 "trackinformation.vala"
174 gtk_window_set_modal (GTK_WINDOW (self), TRUE);
175 #line 15 "trackinformation.vala"
176 hildon_dialog_add_buttons (HILDON_DIALOG (self), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL, NULL);
177 #line 18 "trackinformation.vala"
178 label = g_object_ref_sink ((GtkLabel*) gtk_label_new ("Track name:"));
179 #line 19 "trackinformation.vala"
180 self->priv->entry = (_tmp0_ = g_object_ref_sink ((HildonEntry*) hildon_entry_new (HILDON_SIZE_HALFSCREEN_WIDTH | HILDON_SIZE_FINGER_HEIGHT)), _g_object_unref0 (self->priv->entry), _tmp0_);
181 #line 20 "trackinformation.vala"
182 gtk_entry_set_activates_default (GTK_ENTRY (self->priv->entry), TRUE);
183 #line 21 "trackinformation.vala"
184 g_signal_connect_object (GTK_EDITABLE (self->priv->entry), "changed", (GCallback) _ui_track_information_on_entry_changed_gtk_editable_changed, self, 0);
185 #line 23 "trackinformation.vala"
186 table = g_object_ref_sink ((GtkTable*) gtk_table_new ((guint) 1, (guint) 2, FALSE));
187 #line 24 "trackinformation.vala"
188 gtk_table_attach_defaults (table, GTK_WIDGET (label), (guint) 0, (guint) 1, (guint) 0, (guint) 1);
189 #line 25 "trackinformation.vala"
190 gtk_table_attach_defaults (table, GTK_WIDGET (self->priv->entry), (guint) 1, (guint) 2, (guint) 0, (guint) 1);
191 #line 26 "trackinformation.vala"
192 gtk_table_set_col_spacing (table, (guint) 0, (guint) 12);
193 #line 27 "trackinformation.vala"
194 gtk_container_set_border_width (GTK_CONTAINER (table), (guint) 12);
195 #line 29 "trackinformation.vala"
196 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (self)->vbox), GTK_WIDGET (table), TRUE, TRUE, (guint) 0);
197 #line 30 "trackinformation.vala"
198 gtk_widget_show_all (GTK_WIDGET (self));
199 #line 31 "trackinformation.vala"
200 gtk_dialog_set_default_response (GTK_DIALOG (self), (gint) GTK_RESPONSE_OK);
201 #line 202 "trackinformation.c"
202 _g_object_unref0 (label);
203 _g_object_unref0 (table);
209 static void ui_track_information_class_init (UITrackInformationClass * klass) {
210 ui_track_information_parent_class = g_type_class_peek_parent (klass);
211 g_type_class_add_private (klass, sizeof (UITrackInformationPrivate));
212 G_OBJECT_CLASS (klass)->constructor = ui_track_information_constructor;
213 G_OBJECT_CLASS (klass)->finalize = ui_track_information_finalize;
217 static void ui_track_information_instance_init (UITrackInformation * self) {
218 self->priv = UI_TRACK_INFORMATION_GET_PRIVATE (self);
222 static void ui_track_information_finalize (GObject* obj) {
223 UITrackInformation * self;
224 self = UI_TRACK_INFORMATION (obj);
225 _g_object_unref0 (self->priv->entry);
226 G_OBJECT_CLASS (ui_track_information_parent_class)->finalize (obj);
230 GType ui_track_information_get_type (void) {
231 static volatile gsize ui_track_information_type_id__volatile = 0;
232 if (g_once_init_enter (&ui_track_information_type_id__volatile)) {
233 static const GTypeInfo g_define_type_info = { sizeof (UITrackInformationClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ui_track_information_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UITrackInformation), 0, (GInstanceInitFunc) ui_track_information_instance_init, NULL };
234 GType ui_track_information_type_id;
235 ui_track_information_type_id = g_type_register_static (HILDON_TYPE_DIALOG, "UITrackInformation", &g_define_type_info, 0);
236 g_once_init_leave (&ui_track_information_type_id__volatile, ui_track_information_type_id);
238 return ui_track_information_type_id__volatile;