run vala
[moonshot-ui.git] / src / moonshot-password-dialog.c
1 /* moonshot-password-dialog.c generated by valac 0.10.4, the Vala compiler
2  * generated from moonshot-password-dialog.vala, do not modify */
3
4
5 #include <glib.h>
6 #include <glib-object.h>
7 #include <gtk/gtk.h>
8 #include <glib/gi18n-lib.h>
9 #include <float.h>
10 #include <math.h>
11 #include <atk/atk.h>
12 #include <stdlib.h>
13 #include <string.h>
14
15
16 #define TYPE_ADD_PASSWORD_DIALOG (add_password_dialog_get_type ())
17 #define ADD_PASSWORD_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ADD_PASSWORD_DIALOG, AddPasswordDialog))
18 #define ADD_PASSWORD_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ADD_PASSWORD_DIALOG, AddPasswordDialogClass))
19 #define IS_ADD_PASSWORD_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ADD_PASSWORD_DIALOG))
20 #define IS_ADD_PASSWORD_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ADD_PASSWORD_DIALOG))
21 #define ADD_PASSWORD_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ADD_PASSWORD_DIALOG, AddPasswordDialogClass))
22
23 typedef struct _AddPasswordDialog AddPasswordDialog;
24 typedef struct _AddPasswordDialogClass AddPasswordDialogClass;
25 typedef struct _AddPasswordDialogPrivate AddPasswordDialogPrivate;
26 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
27
28 struct _AddPasswordDialog {
29         GtkDialog parent_instance;
30         AddPasswordDialogPrivate * priv;
31 };
32
33 struct _AddPasswordDialogClass {
34         GtkDialogClass parent_class;
35 };
36
37 struct _AddPasswordDialogPrivate {
38         GtkEntry* password_entry;
39         GtkCheckButton* remember_checkbutton;
40 };
41
42
43 static gpointer add_password_dialog_parent_class = NULL;
44
45 GType add_password_dialog_get_type (void) G_GNUC_CONST;
46 #define ADD_PASSWORD_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_ADD_PASSWORD_DIALOG, AddPasswordDialogPrivate))
47 enum  {
48         ADD_PASSWORD_DIALOG_DUMMY_PROPERTY,
49         ADD_PASSWORD_DIALOG_PASSWORD,
50         ADD_PASSWORD_DIALOG_REMEMBER
51 };
52 AddPasswordDialog* add_password_dialog_new (void);
53 AddPasswordDialog* add_password_dialog_construct (GType object_type);
54 static void add_password_dialog_set_atk_relation (AddPasswordDialog* self, GtkWidget* widget, GtkWidget* target_widget, AtkRelationType relationship);
55 const char* add_password_dialog_get_password (AddPasswordDialog* self);
56 gboolean add_password_dialog_get_remember (AddPasswordDialog* self);
57 static void add_password_dialog_finalize (GObject* obj);
58 static void add_password_dialog_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
59
60
61
62 static gpointer _g_object_ref0 (gpointer self) {
63         return self ? g_object_ref (self) : NULL;
64 }
65
66
67 AddPasswordDialog* add_password_dialog_construct (GType object_type) {
68         AddPasswordDialog * self;
69         GtkWidget* content_area;
70         GtkLabel* password_label;
71         GtkEntry* _tmp0_;
72         GtkCheckButton* _tmp1_;
73         GtkTable* table;
74         GtkVBox* vbox;
75         self = g_object_newv (object_type, 0, NULL);
76         gtk_window_set_title ((GtkWindow*) self, _ ("Please enter your password"));
77         gtk_window_set_modal ((GtkWindow*) self, TRUE);
78         gtk_dialog_add_buttons ((GtkDialog*) self, _ ("Send"), GTK_RESPONSE_OK, _ ("Return to application"), GTK_RESPONSE_CANCEL, NULL);
79         gtk_dialog_set_default_response ((GtkDialog*) self, (gint) GTK_RESPONSE_OK);
80         content_area = _g_object_ref0 (gtk_dialog_get_content_area ((GtkDialog*) self));
81         gtk_box_set_spacing (GTK_BOX (content_area), 12);
82         password_label = g_object_ref_sink ((GtkLabel*) gtk_label_new (_ ("Password:")));
83         gtk_misc_set_alignment ((GtkMisc*) password_label, (float) 1, (float) 0.5);
84         self->priv->password_entry = (_tmp0_ = g_object_ref_sink ((GtkEntry*) gtk_entry_new ()), _g_object_unref0 (self->priv->password_entry), _tmp0_);
85         gtk_entry_set_invisible_char (self->priv->password_entry, (gunichar) '*');
86         gtk_entry_set_visibility (self->priv->password_entry, FALSE);
87         gtk_entry_set_activates_default (self->priv->password_entry, TRUE);
88         self->priv->remember_checkbutton = (_tmp1_ = g_object_ref_sink ((GtkCheckButton*) gtk_check_button_new_with_label (_ ("Remember password"))), _g_object_unref0 (self->priv->remember_checkbutton), _tmp1_);
89         add_password_dialog_set_atk_relation (self, (GtkWidget*) self->priv->password_entry, (GtkWidget*) self->priv->password_entry, ATK_RELATION_LABEL_FOR);
90         table = g_object_ref_sink ((GtkTable*) gtk_table_new ((guint) 2, (guint) 2, FALSE));
91         gtk_table_set_col_spacings (table, (guint) 10);
92         gtk_table_set_row_spacings (table, (guint) 10);
93         gtk_table_attach_defaults (table, (GtkWidget*) password_label, (guint) 0, (guint) 1, (guint) 2, (guint) 3);
94         gtk_table_attach_defaults (table, (GtkWidget*) self->priv->password_entry, (guint) 1, (guint) 2, (guint) 2, (guint) 3);
95         gtk_table_attach_defaults (table, (GtkWidget*) self->priv->remember_checkbutton, (guint) 1, (guint) 2, (guint) 3, (guint) 4);
96         vbox = g_object_ref_sink ((GtkVBox*) gtk_vbox_new (FALSE, 0));
97         gtk_container_set_border_width ((GtkContainer*) vbox, (guint) 6);
98         gtk_box_pack_start ((GtkBox*) vbox, (GtkWidget*) table, FALSE, FALSE, (guint) 0);
99         gtk_container_add (GTK_CONTAINER (content_area), (GtkWidget*) vbox);
100         gtk_container_set_border_width ((GtkContainer*) self, (guint) 6);
101         gtk_window_set_resizable ((GtkWindow*) self, FALSE);
102         gtk_widget_show_all ((GtkWidget*) self);
103         _g_object_unref0 (vbox);
104         _g_object_unref0 (table);
105         _g_object_unref0 (password_label);
106         _g_object_unref0 (content_area);
107         return self;
108 }
109
110
111 AddPasswordDialog* add_password_dialog_new (void) {
112         return add_password_dialog_construct (TYPE_ADD_PASSWORD_DIALOG);
113 }
114
115
116 static void add_password_dialog_set_atk_relation (AddPasswordDialog* self, GtkWidget* widget, GtkWidget* target_widget, AtkRelationType relationship) {
117         AtkObject* atk_widget;
118         AtkObject* atk_target_widget;
119         g_return_if_fail (self != NULL);
120         g_return_if_fail (widget != NULL);
121         g_return_if_fail (target_widget != NULL);
122         atk_widget = _g_object_ref0 (gtk_widget_get_accessible (widget));
123         atk_target_widget = _g_object_ref0 (gtk_widget_get_accessible (target_widget));
124         atk_object_add_relationship (atk_widget, relationship, atk_target_widget);
125         _g_object_unref0 (atk_target_widget);
126         _g_object_unref0 (atk_widget);
127 }
128
129
130 const char* add_password_dialog_get_password (AddPasswordDialog* self) {
131         const char* result;
132         g_return_val_if_fail (self != NULL, NULL);
133         result = gtk_entry_get_text (self->priv->password_entry);
134         return result;
135 }
136
137
138 gboolean add_password_dialog_get_remember (AddPasswordDialog* self) {
139         gboolean result;
140         g_return_val_if_fail (self != NULL, FALSE);
141         result = gtk_toggle_button_get_active ((GtkToggleButton*) self->priv->remember_checkbutton);
142         return result;
143 }
144
145
146 static void add_password_dialog_class_init (AddPasswordDialogClass * klass) {
147         add_password_dialog_parent_class = g_type_class_peek_parent (klass);
148         g_type_class_add_private (klass, sizeof (AddPasswordDialogPrivate));
149         G_OBJECT_CLASS (klass)->get_property = add_password_dialog_get_property;
150         G_OBJECT_CLASS (klass)->finalize = add_password_dialog_finalize;
151         g_object_class_install_property (G_OBJECT_CLASS (klass), ADD_PASSWORD_DIALOG_PASSWORD, g_param_spec_string ("password", "password", "password", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
152         g_object_class_install_property (G_OBJECT_CLASS (klass), ADD_PASSWORD_DIALOG_REMEMBER, g_param_spec_boolean ("remember", "remember", "remember", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
153 }
154
155
156 static void add_password_dialog_instance_init (AddPasswordDialog * self) {
157         self->priv = ADD_PASSWORD_DIALOG_GET_PRIVATE (self);
158 }
159
160
161 static void add_password_dialog_finalize (GObject* obj) {
162         AddPasswordDialog * self;
163         self = ADD_PASSWORD_DIALOG (obj);
164         _g_object_unref0 (self->priv->password_entry);
165         _g_object_unref0 (self->priv->remember_checkbutton);
166         G_OBJECT_CLASS (add_password_dialog_parent_class)->finalize (obj);
167 }
168
169
170 GType add_password_dialog_get_type (void) {
171         static volatile gsize add_password_dialog_type_id__volatile = 0;
172         if (g_once_init_enter (&add_password_dialog_type_id__volatile)) {
173                 static const GTypeInfo g_define_type_info = { sizeof (AddPasswordDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) add_password_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (AddPasswordDialog), 0, (GInstanceInitFunc) add_password_dialog_instance_init, NULL };
174                 GType add_password_dialog_type_id;
175                 add_password_dialog_type_id = g_type_register_static (GTK_TYPE_DIALOG, "AddPasswordDialog", &g_define_type_info, 0);
176                 g_once_init_leave (&add_password_dialog_type_id__volatile, add_password_dialog_type_id);
177         }
178         return add_password_dialog_type_id__volatile;
179 }
180
181
182 static void add_password_dialog_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
183         AddPasswordDialog * self;
184         self = ADD_PASSWORD_DIALOG (object);
185         switch (property_id) {
186                 case ADD_PASSWORD_DIALOG_PASSWORD:
187                 g_value_set_string (value, add_password_dialog_get_password (self));
188                 break;
189                 case ADD_PASSWORD_DIALOG_REMEMBER:
190                 g_value_set_boolean (value, add_password_dialog_get_remember (self));
191                 break;
192                 default:
193                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
194                 break;
195         }
196 }
197
198
199
200