| 38 N_PROPERTIES, |
36 N_PROPERTIES, |
| 39 }; |
37 }; |
| 40 |
38 |
| 41 static GParamSpec *properties[N_PROPERTIES] = {0, }; |
39 static GParamSpec *properties[N_PROPERTIES] = {0, }; |
| 42 |
40 |
| 43 G_DEFINE_TYPE_WITH_PRIVATE(PidginInviteDialog, pidgin_invite_dialog, GTK_TYPE_DIALOG); |
41 G_DEFINE_TYPE(PidginInviteDialog, pidgin_invite_dialog, GTK_TYPE_DIALOG); |
| 44 |
42 |
| 45 /****************************************************************************** |
43 /****************************************************************************** |
| 46 * Helpers |
44 * Helpers |
| 47 *****************************************************************************/ |
45 *****************************************************************************/ |
| 48 static void |
46 static void |
| 49 pidgin_invite_dialog_set_conversation(PidginInviteDialog *dialog, |
47 pidgin_invite_dialog_set_conversation(PidginInviteDialog *dialog, |
| 50 PurpleChatConversation *conversation) |
48 PurpleChatConversation *conversation) |
| 51 { |
49 { |
| 52 PidginInviteDialogPrivate *priv = NULL; |
|
| 53 |
|
| 54 g_return_if_fail(PIDGIN_IS_INVITE_DIALOG(dialog)); |
50 g_return_if_fail(PIDGIN_IS_INVITE_DIALOG(dialog)); |
| 55 |
51 |
| 56 priv = pidgin_invite_dialog_get_instance_private(dialog); |
52 dialog->conversation = g_object_ref(conversation); |
| 57 |
|
| 58 priv->conversation = g_object_ref(conversation); |
|
| 59 |
53 |
| 60 g_object_notify_by_pspec(G_OBJECT(dialog), properties[PROP_CONVERSATION]); |
54 g_object_notify_by_pspec(G_OBJECT(dialog), properties[PROP_CONVERSATION]); |
| 61 } |
55 } |
| 62 |
56 |
| 63 /****************************************************************************** |
57 /****************************************************************************** |
| 117 } |
111 } |
| 118 } |
112 } |
| 119 |
113 |
| 120 static void |
114 static void |
| 121 pidgin_invite_dialog_finalize(GObject *obj) { |
115 pidgin_invite_dialog_finalize(GObject *obj) { |
| 122 PidginInviteDialogPrivate *priv = NULL; |
116 PidginInviteDialog *dialog = PIDGIN_INVITE_DIALOG(obj); |
| 123 |
117 |
| 124 priv = pidgin_invite_dialog_get_instance_private(PIDGIN_INVITE_DIALOG(obj)); |
118 g_clear_pointer(&dialog->contact, g_free); |
| 125 |
119 g_clear_pointer(&dialog->message, g_free); |
| 126 g_clear_pointer(&priv->contact, g_free); |
120 g_clear_object(&dialog->conversation); |
| 127 g_clear_pointer(&priv->message, g_free); |
|
| 128 g_clear_object(&priv->conversation); |
|
| 129 |
121 |
| 130 G_OBJECT_CLASS(pidgin_invite_dialog_parent_class)->finalize(obj); |
122 G_OBJECT_CLASS(pidgin_invite_dialog_parent_class)->finalize(obj); |
| 131 } |
123 } |
| 132 |
124 |
| 133 static void |
125 static void |
| 147 gtk_widget_class_set_template_from_resource( |
139 gtk_widget_class_set_template_from_resource( |
| 148 widget_class, |
140 widget_class, |
| 149 "/im/pidgin/Pidgin3/Conversations/invite_dialog.ui" |
141 "/im/pidgin/Pidgin3/Conversations/invite_dialog.ui" |
| 150 ); |
142 ); |
| 151 |
143 |
| 152 gtk_widget_class_bind_template_child_private( |
144 gtk_widget_class_bind_template_child(widget_class, PidginInviteDialog, |
| 153 widget_class, |
145 contact); |
| 154 PidginInviteDialog, |
146 gtk_widget_class_bind_template_child(widget_class, PidginInviteDialog, |
| 155 contact |
147 message); |
| 156 ); |
|
| 157 gtk_widget_class_bind_template_child_private( |
|
| 158 widget_class, |
|
| 159 PidginInviteDialog, |
|
| 160 message |
|
| 161 ); |
|
| 162 |
148 |
| 163 properties[PROP_CONTACT] = g_param_spec_string( |
149 properties[PROP_CONTACT] = g_param_spec_string( |
| 164 "contact", |
150 "contact", |
| 165 "contact", |
151 "contact", |
| 166 "The person that is being invited", |
152 "The person that is being invited", |
| 195 NULL)); |
181 NULL)); |
| 196 } |
182 } |
| 197 |
183 |
| 198 const gchar * |
184 const gchar * |
| 199 pidgin_invite_dialog_get_contact(PidginInviteDialog *dialog) { |
185 pidgin_invite_dialog_get_contact(PidginInviteDialog *dialog) { |
| 200 PidginInviteDialogPrivate *priv = NULL; |
|
| 201 |
|
| 202 g_return_val_if_fail(PIDGIN_IS_INVITE_DIALOG(dialog), NULL); |
186 g_return_val_if_fail(PIDGIN_IS_INVITE_DIALOG(dialog), NULL); |
| 203 |
187 |
| 204 priv = pidgin_invite_dialog_get_instance_private(dialog); |
188 return gtk_editable_get_text(GTK_EDITABLE(dialog->contact)); |
| 205 |
|
| 206 return gtk_editable_get_text(GTK_EDITABLE(priv->contact)); |
|
| 207 } |
189 } |
| 208 |
190 |
| 209 void |
191 void |
| 210 pidgin_invite_dialog_set_contact(PidginInviteDialog *dialog, |
192 pidgin_invite_dialog_set_contact(PidginInviteDialog *dialog, |
| 211 const gchar *contact) |
193 const gchar *contact) |
| 212 { |
194 { |
| 213 PidginInviteDialogPrivate *priv = NULL; |
|
| 214 |
|
| 215 g_return_if_fail(PIDGIN_IS_INVITE_DIALOG(dialog)); |
195 g_return_if_fail(PIDGIN_IS_INVITE_DIALOG(dialog)); |
| 216 |
196 |
| 217 priv = pidgin_invite_dialog_get_instance_private(dialog); |
|
| 218 |
|
| 219 if(contact != NULL) { |
197 if(contact != NULL) { |
| 220 gtk_editable_set_text(GTK_EDITABLE(priv->contact), contact); |
198 gtk_editable_set_text(GTK_EDITABLE(dialog->contact), contact); |
| 221 |
199 |
| 222 g_object_notify_by_pspec(G_OBJECT(dialog), properties[PROP_CONTACT]); |
200 g_object_notify_by_pspec(G_OBJECT(dialog), properties[PROP_CONTACT]); |
| 223 } |
201 } |
| 224 } |
202 } |
| 225 |
203 |
| 226 const gchar * |
204 const gchar * |
| 227 pidgin_invite_dialog_get_message(PidginInviteDialog *dialog) { |
205 pidgin_invite_dialog_get_message(PidginInviteDialog *dialog) { |
| 228 PidginInviteDialogPrivate *priv = NULL; |
|
| 229 |
|
| 230 g_return_val_if_fail(PIDGIN_IS_INVITE_DIALOG(dialog), NULL); |
206 g_return_val_if_fail(PIDGIN_IS_INVITE_DIALOG(dialog), NULL); |
| 231 |
207 |
| 232 priv = pidgin_invite_dialog_get_instance_private(dialog); |
208 return gtk_editable_get_text(GTK_EDITABLE(dialog->message)); |
| 233 |
|
| 234 return gtk_editable_get_text(GTK_EDITABLE(priv->message)); |
|
| 235 } |
209 } |
| 236 |
210 |
| 237 void |
211 void |
| 238 pidgin_invite_dialog_set_message(PidginInviteDialog *dialog, |
212 pidgin_invite_dialog_set_message(PidginInviteDialog *dialog, |
| 239 const gchar *message) |
213 const gchar *message) |
| 240 { |
214 { |
| 241 PidginInviteDialogPrivate *priv = NULL; |
|
| 242 |
|
| 243 g_return_if_fail(PIDGIN_IS_INVITE_DIALOG(dialog)); |
215 g_return_if_fail(PIDGIN_IS_INVITE_DIALOG(dialog)); |
| 244 |
216 |
| 245 priv = pidgin_invite_dialog_get_instance_private(dialog); |
|
| 246 |
|
| 247 if(message != NULL) { |
217 if(message != NULL) { |
| 248 gtk_editable_set_text(GTK_EDITABLE(priv->message), message); |
218 gtk_editable_set_text(GTK_EDITABLE(dialog->message), message); |
| 249 |
219 |
| 250 g_object_notify_by_pspec(G_OBJECT(dialog), properties[PROP_MESSAGE]); |
220 g_object_notify_by_pspec(G_OBJECT(dialog), properties[PROP_MESSAGE]); |
| 251 } |
221 } |
| 252 } |
222 } |
| 253 |
223 |
| 254 PurpleChatConversation * |
224 PurpleChatConversation * |
| 255 pidgin_invite_dialog_get_conversation(PidginInviteDialog *dialog) { |
225 pidgin_invite_dialog_get_conversation(PidginInviteDialog *dialog) { |
| 256 PidginInviteDialogPrivate *priv = NULL; |
|
| 257 |
|
| 258 g_return_val_if_fail(PIDGIN_IS_INVITE_DIALOG(dialog), NULL); |
226 g_return_val_if_fail(PIDGIN_IS_INVITE_DIALOG(dialog), NULL); |
| 259 |
227 |
| 260 priv = pidgin_invite_dialog_get_instance_private(dialog); |
228 return dialog->conversation; |
| 261 |
229 } |
| 262 return priv->conversation; |
|
| 263 } |
|