| 110 |
65 |
| 111 dialogwindows = g_list_remove(dialogwindows, dest); |
66 dialogwindows = g_list_remove(dialogwindows, dest); |
| 112 gtk_widget_destroy(dest); |
67 gtk_widget_destroy(dest); |
| 113 } |
68 } |
| 114 |
69 |
| 115 void destroy_all_dialogs() |
70 void |
| |
71 gaim_gtkdialogs_destroy_all() |
| 116 { |
72 { |
| 117 while (dialogwindows) |
73 while (dialogwindows) |
| 118 destroy_dialog(NULL, dialogwindows->data); |
74 destroy_dialog(NULL, dialogwindows->data); |
| 119 |
75 |
| |
76 /* STATUS */ |
| 120 if (awaymessage) |
77 if (awaymessage) |
| 121 do_im_back(NULL, NULL); |
78 do_im_back(NULL, NULL); |
| 122 } |
79 } |
| 123 |
80 |
| 124 static void do_warn(GtkWidget *widget, gint resp, struct warning *w) |
81 static void |
| |
82 gaim_gtkdialogs_im_cb(gpointer data, GaimRequestFields *fields) |
| |
83 { |
| |
84 GaimAccount *account; |
| |
85 const char *username; |
| |
86 |
| |
87 account = gaim_request_fields_get_account(fields, "account"); |
| |
88 username = gaim_request_fields_get_string(fields, "screenname"); |
| |
89 |
| |
90 gaim_gtkdialogs_im_with_user(account, username); |
| |
91 } |
| |
92 |
| |
93 void |
| |
94 gaim_gtkdialogs_im(void) |
| |
95 { |
| |
96 GaimRequestFields *fields; |
| |
97 GaimRequestFieldGroup *group; |
| |
98 GaimRequestField *field; |
| |
99 |
| |
100 fields = gaim_request_fields_new(); |
| |
101 |
| |
102 group = gaim_request_field_group_new(NULL); |
| |
103 gaim_request_fields_add_group(fields, group); |
| |
104 |
| |
105 field = gaim_request_field_string_new("screenname", _("_Screen name"), |
| |
106 NULL, FALSE); |
| |
107 gaim_request_field_set_required(field, TRUE); |
| |
108 gaim_request_field_set_type_hint(field, "screenname"); |
| |
109 gaim_request_field_group_add_field(group, field); |
| |
110 |
| |
111 field = gaim_request_field_account_new("account", _("_Account"), NULL); |
| |
112 gaim_request_field_set_visible(field, |
| |
113 (gaim_connections_get_all() != NULL && |
| |
114 gaim_connections_get_all()->next != NULL)); |
| |
115 gaim_request_field_set_required(field, TRUE); |
| |
116 gaim_request_field_group_add_field(group, field); |
| |
117 |
| |
118 gaim_request_fields(gaim_get_blist(), _("New Instant Message"), |
| |
119 NULL, |
| |
120 _("Please enter the screen name of the person you " |
| |
121 "would like to IM."), |
| |
122 fields, |
| |
123 _("OK"), G_CALLBACK(gaim_gtkdialogs_im_cb), |
| |
124 _("Cancel"), NULL, |
| |
125 NULL); |
| |
126 } |
| |
127 |
| |
128 void |
| |
129 gaim_gtkdialogs_im_with_user(GaimAccount *account, const char *username) |
| |
130 { |
| |
131 GaimConversation *conv; |
| |
132 GaimConvWindow *win; |
| |
133 GaimGtkWindow *gtkwin; |
| |
134 |
| |
135 conv = gaim_find_conversation_with_account(username, account); |
| |
136 |
| |
137 if (conv == NULL) |
| |
138 conv = gaim_conversation_new(GAIM_CONV_IM, account, username); |
| |
139 |
| |
140 win = gaim_conversation_get_window(conv); |
| |
141 gtkwin = GAIM_GTK_WINDOW(win); |
| |
142 |
| |
143 gtk_window_present(GTK_WINDOW(gtkwin->window)); |
| |
144 gaim_conv_window_switch_conversation(win, gaim_conversation_get_index(conv)); |
| |
145 } |
| |
146 |
| |
147 static gboolean |
| |
148 gaim_gtkdialogs_ee(const char *ee) |
| |
149 { |
| |
150 GtkWidget *window; |
| |
151 GtkWidget *hbox; |
| |
152 GtkWidget *label; |
| |
153 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_COOL, GTK_ICON_SIZE_DIALOG); |
| |
154 gchar *norm = gaim_strreplace(ee, "rocksmyworld", ""); |
| |
155 |
| |
156 label = gtk_label_new(NULL); |
| |
157 if (!strcmp(norm, "zilding")) |
| |
158 gtk_label_set_markup(GTK_LABEL(label), |
| |
159 "<span weight=\"bold\" size=\"large\" foreground=\"purple\">Amazing! Simply Amazing!</span>"); |
| |
160 else if (!strcmp(norm, "robflynn")) |
| |
161 gtk_label_set_markup(GTK_LABEL(label), |
| |
162 "<span weight=\"bold\" size=\"large\" foreground=\"#1f6bad\">Pimpin\' Penguin Style! *Waddle Waddle*</span>"); |
| |
163 else if (!strcmp(norm, "flynorange")) |
| |
164 gtk_label_set_markup(GTK_LABEL(label), |
| |
165 "<span weight=\"bold\" size=\"large\" foreground=\"blue\">You should be me. I'm so cute!</span>"); |
| |
166 else if (!strcmp(norm, "ewarmenhoven")) |
| |
167 gtk_label_set_markup(GTK_LABEL(label), |
| |
168 "<span weight=\"bold\" size=\"large\" foreground=\"orange\">Now that's what I like!</span>"); |
| |
169 else if (!strcmp(norm, "markster97")) |
| |
170 gtk_label_set_markup(GTK_LABEL(label), |
| |
171 "<span weight=\"bold\" size=\"large\" foreground=\"brown\">Ahh, and excellent choice!</span>"); |
| |
172 else if (!strcmp(norm, "seanegn")) |
| |
173 gtk_label_set_markup(GTK_LABEL(label), |
| |
174 "<span weight=\"bold\" size=\"large\" foreground=\"#009900\">Everytime you click my name, an angel gets its wings.</span>"); |
| |
175 else if (!strcmp(norm, "chipx86")) |
| |
176 gtk_label_set_markup(GTK_LABEL(label), |
| |
177 "<span weight=\"bold\" size=\"large\" foreground=\"red\">This sunflower seed taste like pizza.</span>"); |
| |
178 else if (!strcmp(norm, "markdoliner")) |
| |
179 gtk_label_set_markup(GTK_LABEL(label), |
| |
180 "<span weight=\"bold\" size=\"large\" foreground=\"#6364B1\">Hey! I was in that tumbleweed!</span>"); |
| |
181 else if (!strcmp(norm, "lschiere")) |
| |
182 gtk_label_set_markup(GTK_LABEL(label), |
| |
183 "<span weight=\"bold\" size=\"large\" foreground=\"gray\">I'm not anything.</span>"); |
| |
184 g_free(norm); |
| |
185 |
| |
186 if (strlen(gtk_label_get_label(GTK_LABEL(label))) <= 0) |
| |
187 return FALSE; |
| |
188 |
| |
189 window = gtk_dialog_new_with_buttons(GAIM_ALERT_TITLE, NULL, 0, GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); |
| |
190 gtk_dialog_set_default_response (GTK_DIALOG(window), GTK_RESPONSE_OK); |
| |
191 g_signal_connect(G_OBJECT(window), "response", G_CALLBACK(gtk_widget_destroy), NULL); |
| |
192 |
| |
193 gtk_container_set_border_width (GTK_CONTAINER(window), 6); |
| |
194 gtk_window_set_resizable(GTK_WINDOW(window), FALSE); |
| |
195 gtk_dialog_set_has_separator(GTK_DIALOG(window), FALSE); |
| |
196 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(window)->vbox), 12); |
| |
197 gtk_container_set_border_width (GTK_CONTAINER(GTK_DIALOG(window)->vbox), 6); |
| |
198 |
| |
199 hbox = gtk_hbox_new(FALSE, 12); |
| |
200 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(window)->vbox), hbox); |
| |
201 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
| |
202 |
| |
203 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
| |
204 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
| |
205 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
| |
206 |
| |
207 gtk_widget_show_all(window); |
| |
208 return TRUE; |
| |
209 } |
| |
210 |
| |
211 static void |
| |
212 gaim_gtkdialogs_info_cb(gpointer data, GaimRequestFields *fields) |
| |
213 { |
| |
214 char *username; |
| |
215 gboolean found = FALSE; |
| |
216 GaimAccount *account; |
| |
217 |
| |
218 account = gaim_request_fields_get_account(fields, "account"); |
| |
219 |
| |
220 username = g_strdup(gaim_normalize(account, |
| |
221 gaim_request_fields_get_string(fields, "screenname"))); |
| |
222 |
| |
223 if (username != NULL && gaim_str_has_suffix(username, "rocksmyworld")) |
| |
224 found = gaim_gtkdialogs_ee(username); |
| |
225 |
| |
226 if (!found && username != NULL && *username != '\0' && account != NULL) |
| |
227 serv_get_info(gaim_account_get_connection(account), username); |
| |
228 |
| |
229 g_free(username); |
| |
230 } |
| |
231 |
| |
232 void |
| |
233 gaim_gtkdialogs_info(void) |
| |
234 { |
| |
235 GaimRequestFields *fields; |
| |
236 GaimRequestFieldGroup *group; |
| |
237 GaimRequestField *field; |
| |
238 |
| |
239 fields = gaim_request_fields_new(); |
| |
240 |
| |
241 group = gaim_request_field_group_new(NULL); |
| |
242 gaim_request_fields_add_group(fields, group); |
| |
243 |
| |
244 field = gaim_request_field_string_new("screenname", _("_Screen name"), |
| |
245 NULL, FALSE); |
| |
246 gaim_request_field_set_type_hint(field, "screenname"); |
| |
247 gaim_request_field_set_required(field, TRUE); |
| |
248 gaim_request_field_group_add_field(group, field); |
| |
249 |
| |
250 field = gaim_request_field_account_new("account", _("_Account"), NULL); |
| |
251 gaim_request_field_set_visible(field, |
| |
252 (gaim_connections_get_all() != NULL && |
| |
253 gaim_connections_get_all()->next != NULL)); |
| |
254 gaim_request_field_set_required(field, TRUE); |
| |
255 gaim_request_field_group_add_field(group, field); |
| |
256 |
| |
257 gaim_request_fields(gaim_get_blist(), _("Get User Info"), |
| |
258 NULL, |
| |
259 _("Please enter the screen name of the person whose " |
| |
260 "info you would like to view."), |
| |
261 fields, |
| |
262 _("OK"), G_CALLBACK(gaim_gtkdialogs_info_cb), |
| |
263 _("Cancel"), NULL, |
| |
264 NULL); |
| |
265 } |
| |
266 |
| |
267 static void |
| |
268 gaim_gtkdialogs_log_cb(gpointer data, GaimRequestFields *fields) |
| |
269 { |
| |
270 char *username; |
| |
271 GaimAccount *account; |
| |
272 |
| |
273 account = gaim_request_fields_get_account(fields, "account"); |
| |
274 |
| |
275 username = g_strdup(gaim_normalize(account, |
| |
276 gaim_request_fields_get_string(fields, "screenname"))); |
| |
277 |
| |
278 if( username != NULL && *username != '\0' && account != NULL ) |
| |
279 gaim_gtk_log_show( username, account ); |
| |
280 |
| |
281 g_free(username); |
| |
282 } |
| |
283 |
| |
284 void |
| |
285 gaim_gtkdialogs_log(void) |
| |
286 { |
| |
287 GaimRequestFields *fields; |
| |
288 GaimRequestFieldGroup *group; |
| |
289 GaimRequestField *field; |
| |
290 |
| |
291 fields = gaim_request_fields_new(); |
| |
292 |
| |
293 group = gaim_request_field_group_new(NULL); |
| |
294 gaim_request_fields_add_group(fields, group); |
| |
295 |
| |
296 field = gaim_request_field_string_new("screenname", _("_Screen name"), |
| |
297 NULL, FALSE); |
| |
298 gaim_request_field_set_type_hint(field, "screenname"); |
| |
299 gaim_request_field_set_required(field, TRUE); |
| |
300 gaim_request_field_group_add_field(group, field); |
| |
301 |
| |
302 field = gaim_request_field_account_new("account", _("_Account"), NULL); |
| |
303 gaim_request_field_account_set_show_all(field, TRUE); |
| |
304 gaim_request_field_set_visible(field, |
| |
305 (gaim_accounts_get_all() != NULL && |
| |
306 gaim_accounts_get_all()->next != NULL)); |
| |
307 gaim_request_field_set_required(field, TRUE); |
| |
308 gaim_request_field_group_add_field(group, field); |
| |
309 |
| |
310 gaim_request_fields(gaim_get_blist(), _("Get User Log"), |
| |
311 NULL, |
| |
312 _("Please enter the screen name of the person whose " |
| |
313 "log you would like to view."), |
| |
314 fields, |
| |
315 _("OK"), G_CALLBACK(gaim_gtkdialogs_log_cb), |
| |
316 _("Cancel"), NULL, |
| |
317 NULL); |
| |
318 } |
| |
319 |
| |
320 static void |
| |
321 gaim_gtkdialogs_warn_cb(GtkWidget *widget, gint resp, struct warning *w) |
| 125 { |
322 { |
| 126 if (resp == GTK_RESPONSE_OK) |
323 if (resp == GTK_RESPONSE_OK) |
| 127 serv_warn(w->gc, w->who, (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w->anon))) ? 1 : 0); |
324 serv_warn(w->gc, w->who, (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w->anon))) ? 1 : 0); |
| 128 |
325 |
| 129 destroy_dialog(NULL, w->window); |
326 destroy_dialog(NULL, w->window); |
| 130 g_free(w->who); |
327 g_free(w->who); |
| 131 g_free(w); |
328 g_free(w); |
| 132 } |
329 } |
| 133 |
330 |
| 134 void gaim_gtkdialogs_warn(GaimConnection *gc, const char *who) |
331 void |
| |
332 gaim_gtkdialogs_warn(GaimConnection *gc, const char *who) |
| 135 { |
333 { |
| 136 char *labeltext; |
334 char *labeltext; |
| 137 GtkWidget *hbox, *vbox; |
335 GtkWidget *hbox, *vbox; |
| 138 GtkWidget *label; |
336 GtkWidget *label; |
| 139 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG); |
337 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG); |
| 310 _("Cancel"), NULL); |
600 _("Cancel"), NULL); |
| 311 |
601 |
| 312 g_free(name); |
602 g_free(name); |
| 313 g_free(text); |
603 g_free(text); |
| 314 } |
604 } |
| 315 |
|
| 316 void show_confirm_del_group(GaimGroup *group) |
|
| 317 { |
|
| 318 char *text = g_strdup_printf(_("You are about to remove the group %s and all its members from your buddy list. Do you want to continue?"), |
|
| 319 group->name); |
|
| 320 |
|
| 321 gaim_request_action(NULL, NULL, _("Remove Group"), text, -1, group, 2, |
|
| 322 _("Remove Group"), G_CALLBACK(do_remove_group), |
|
| 323 _("Cancel"), NULL); |
|
| 324 |
|
| 325 g_free(text); |
|
| 326 } |
|
| 327 |
|
| 328 void show_confirm_del_contact(GaimContact *contact) |
|
| 329 { |
|
| 330 GaimBuddy *buddy = gaim_contact_get_priority_buddy(contact); |
|
| 331 |
|
| 332 if (!buddy) |
|
| 333 return; |
|
| 334 |
|
| 335 if (((GaimBlistNode*)contact)->child == (GaimBlistNode*)buddy && |
|
| 336 !((GaimBlistNode*)buddy)->next) { |
|
| 337 show_confirm_del(buddy); |
|
| 338 } else { |
|
| 339 char *text = g_strdup_printf(_("You are about to remove the contact containing %s and %d other buddies from your buddy list. Do you want to continue?"), |
|
| 340 buddy->name, contact->totalsize - 1); |
|
| 341 |
|
| 342 gaim_request_action(NULL, NULL, _("Remove Contact"), text, -1, contact, 2, |
|
| 343 _("Remove Contact"), G_CALLBACK(do_remove_contact), |
|
| 344 _("Cancel"), NULL); |
|
| 345 |
|
| 346 g_free(text); |
|
| 347 } |
|
| 348 } |
|
| 349 |
|
| 350 static gboolean show_ee_dialog(const char *ee) |
|
| 351 { |
|
| 352 GtkWidget *window; |
|
| 353 GtkWidget *hbox; |
|
| 354 GtkWidget *label; |
|
| 355 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_COOL, GTK_ICON_SIZE_DIALOG); |
|
| 356 gchar *norm = gaim_strreplace(ee, "rocksmyworld", ""); |
|
| 357 |
|
| 358 label = gtk_label_new(NULL); |
|
| 359 if (!strcmp(norm, "zilding")) |
|
| 360 gtk_label_set_markup(GTK_LABEL(label), |
|
| 361 "<span weight=\"bold\" size=\"large\" foreground=\"purple\">Amazing! Simply Amazing!</span>"); |
|
| 362 else if (!strcmp(norm, "robflynn")) |
|
| 363 gtk_label_set_markup(GTK_LABEL(label), |
|
| 364 "<span weight=\"bold\" size=\"large\" foreground=\"#1f6bad\">Pimpin\' Penguin Style! *Waddle Waddle*</span>"); |
|
| 365 else if (!strcmp(norm, "flynorange")) |
|
| 366 gtk_label_set_markup(GTK_LABEL(label), |
|
| 367 "<span weight=\"bold\" size=\"large\" foreground=\"blue\">You should be me. I'm so cute!</span>"); |
|
| 368 else if (!strcmp(norm, "ewarmenhoven")) |
|
| 369 gtk_label_set_markup(GTK_LABEL(label), |
|
| 370 "<span weight=\"bold\" size=\"large\" foreground=\"orange\">Now that's what I like!</span>"); |
|
| 371 else if (!strcmp(norm, "markster97")) |
|
| 372 gtk_label_set_markup(GTK_LABEL(label), |
|
| 373 "<span weight=\"bold\" size=\"large\" foreground=\"brown\">Ahh, and excellent choice!</span>"); |
|
| 374 else if (!strcmp(norm, "seanegn")) |
|
| 375 gtk_label_set_markup(GTK_LABEL(label), |
|
| 376 "<span weight=\"bold\" size=\"large\" foreground=\"#009900\">Everytime you click my name, an angel gets its wings.</span>"); |
|
| 377 else if (!strcmp(norm, "chipx86")) |
|
| 378 gtk_label_set_markup(GTK_LABEL(label), |
|
| 379 "<span weight=\"bold\" size=\"large\" foreground=\"red\">This sunflower seed taste like pizza.</span>"); |
|
| 380 else if (!strcmp(norm, "markdoliner")) |
|
| 381 gtk_label_set_markup(GTK_LABEL(label), |
|
| 382 "<span weight=\"bold\" size=\"large\" foreground=\"#6364B1\">Hey! I was in that tumbleweed!</span>"); |
|
| 383 else if (!strcmp(norm, "lschiere")) |
|
| 384 gtk_label_set_markup(GTK_LABEL(label), |
|
| 385 "<span weight=\"bold\" size=\"large\" foreground=\"gray\">I'm not anything.</span>"); |
|
| 386 g_free(norm); |
|
| 387 |
|
| 388 if (strlen(gtk_label_get_label(GTK_LABEL(label))) <= 0) |
|
| 389 return FALSE; |
|
| 390 |
|
| 391 window = gtk_dialog_new_with_buttons(GAIM_ALERT_TITLE, NULL, 0, GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); |
|
| 392 gtk_dialog_set_default_response (GTK_DIALOG(window), GTK_RESPONSE_OK); |
|
| 393 g_signal_connect(G_OBJECT(window), "response", G_CALLBACK(gtk_widget_destroy), NULL); |
|
| 394 |
|
| 395 gtk_container_set_border_width (GTK_CONTAINER(window), 6); |
|
| 396 gtk_window_set_resizable(GTK_WINDOW(window), FALSE); |
|
| 397 gtk_dialog_set_has_separator(GTK_DIALOG(window), FALSE); |
|
| 398 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(window)->vbox), 12); |
|
| 399 gtk_container_set_border_width (GTK_CONTAINER(GTK_DIALOG(window)->vbox), 6); |
|
| 400 |
|
| 401 hbox = gtk_hbox_new(FALSE, 12); |
|
| 402 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(window)->vbox), hbox); |
|
| 403 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
|
| 404 |
|
| 405 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
|
| 406 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
|
| 407 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
|
| 408 |
|
| 409 gtk_widget_show_all(window); |
|
| 410 return TRUE; |
|
| 411 } |
|
| 412 |
|
| 413 void |
|
| 414 gaim_gtkdialogs_im_with_user(GaimAccount *account, const char *username) |
|
| 415 { |
|
| 416 GaimConversation *conv; |
|
| 417 GaimConvWindow *win; |
|
| 418 GaimGtkWindow *gtkwin; |
|
| 419 |
|
| 420 conv = gaim_find_conversation_with_account(username, account); |
|
| 421 |
|
| 422 if (conv == NULL) |
|
| 423 conv = gaim_conversation_new(GAIM_CONV_IM, account, username); |
|
| 424 |
|
| 425 win = gaim_conversation_get_window(conv); |
|
| 426 gtkwin = GAIM_GTK_WINDOW(win); |
|
| 427 |
|
| 428 gtk_window_present(GTK_WINDOW(gtkwin->window)); |
|
| 429 gaim_conv_window_switch_conversation(win, gaim_conversation_get_index(conv)); |
|
| 430 } |
|
| 431 |
|
| 432 static void |
|
| 433 new_im_cb(gpointer data, GaimRequestFields *fields) |
|
| 434 { |
|
| 435 GaimAccount *account; |
|
| 436 const char *username; |
|
| 437 |
|
| 438 account = gaim_request_fields_get_account(fields, "account"); |
|
| 439 username = gaim_request_fields_get_string(fields, "screenname"); |
|
| 440 |
|
| 441 gaim_gtkdialogs_im_with_user(account, username); |
|
| 442 } |
|
| 443 |
|
| 444 void |
|
| 445 gaim_gtkdialogs_im(void) |
|
| 446 { |
|
| 447 GaimRequestFields *fields; |
|
| 448 GaimRequestFieldGroup *group; |
|
| 449 GaimRequestField *field; |
|
| 450 |
|
| 451 fields = gaim_request_fields_new(); |
|
| 452 |
|
| 453 group = gaim_request_field_group_new(NULL); |
|
| 454 gaim_request_fields_add_group(fields, group); |
|
| 455 |
|
| 456 field = gaim_request_field_string_new("screenname", _("_Screen name"), |
|
| 457 NULL, FALSE); |
|
| 458 gaim_request_field_set_required(field, TRUE); |
|
| 459 gaim_request_field_set_type_hint(field, "screenname"); |
|
| 460 gaim_request_field_group_add_field(group, field); |
|
| 461 |
|
| 462 field = gaim_request_field_account_new("account", _("_Account"), NULL); |
|
| 463 gaim_request_field_set_visible(field, |
|
| 464 (gaim_connections_get_all() != NULL && |
|
| 465 gaim_connections_get_all()->next != NULL)); |
|
| 466 gaim_request_field_set_required(field, TRUE); |
|
| 467 gaim_request_field_group_add_field(group, field); |
|
| 468 |
|
| 469 gaim_request_fields(gaim_get_blist(), _("New Instant Message"), |
|
| 470 NULL, |
|
| 471 _("Please enter the screen name of the person you " |
|
| 472 "would like to IM."), |
|
| 473 fields, |
|
| 474 _("OK"), G_CALLBACK(new_im_cb), |
|
| 475 _("Cancel"), NULL, |
|
| 476 NULL); |
|
| 477 } |
|
| 478 |
|
| 479 static void |
|
| 480 get_info_cb(gpointer data, GaimRequestFields *fields) |
|
| 481 { |
|
| 482 char *username; |
|
| 483 gboolean found = FALSE; |
|
| 484 GaimAccount *account; |
|
| 485 |
|
| 486 account = gaim_request_fields_get_account(fields, "account"); |
|
| 487 |
|
| 488 username = g_strdup(gaim_normalize(account, |
|
| 489 gaim_request_fields_get_string(fields, "screenname"))); |
|
| 490 |
|
| 491 if (username != NULL && gaim_str_has_suffix(username, "rocksmyworld")) |
|
| 492 found = show_ee_dialog(username); |
|
| 493 |
|
| 494 if (!found && username != NULL && *username != '\0' && account != NULL) |
|
| 495 serv_get_info(gaim_account_get_connection(account), username); |
|
| 496 |
|
| 497 g_free(username); |
|
| 498 } |
|
| 499 |
|
| 500 void |
|
| 501 gaim_gtkdialogs_info(void) |
|
| 502 { |
|
| 503 GaimRequestFields *fields; |
|
| 504 GaimRequestFieldGroup *group; |
|
| 505 GaimRequestField *field; |
|
| 506 |
|
| 507 fields = gaim_request_fields_new(); |
|
| 508 |
|
| 509 group = gaim_request_field_group_new(NULL); |
|
| 510 gaim_request_fields_add_group(fields, group); |
|
| 511 |
|
| 512 field = gaim_request_field_string_new("screenname", _("_Screen name"), |
|
| 513 NULL, FALSE); |
|
| 514 gaim_request_field_set_type_hint(field, "screenname"); |
|
| 515 gaim_request_field_set_required(field, TRUE); |
|
| 516 gaim_request_field_group_add_field(group, field); |
|
| 517 |
|
| 518 field = gaim_request_field_account_new("account", _("_Account"), NULL); |
|
| 519 gaim_request_field_set_visible(field, |
|
| 520 (gaim_connections_get_all() != NULL && |
|
| 521 gaim_connections_get_all()->next != NULL)); |
|
| 522 gaim_request_field_set_required(field, TRUE); |
|
| 523 gaim_request_field_group_add_field(group, field); |
|
| 524 |
|
| 525 gaim_request_fields(gaim_get_blist(), _("Get User Info"), |
|
| 526 NULL, |
|
| 527 _("Please enter the screen name of the person whose " |
|
| 528 "info you would like to view."), |
|
| 529 fields, |
|
| 530 _("OK"), G_CALLBACK(get_info_cb), |
|
| 531 _("Cancel"), NULL, |
|
| 532 NULL); |
|
| 533 } |
|
| 534 |
|
| 535 static void |
|
| 536 get_log_cb(gpointer data, GaimRequestFields *fields) |
|
| 537 { |
|
| 538 char *username; |
|
| 539 GaimAccount *account; |
|
| 540 |
|
| 541 account = gaim_request_fields_get_account(fields, "account"); |
|
| 542 |
|
| 543 username = g_strdup(gaim_normalize(account, |
|
| 544 gaim_request_fields_get_string(fields, "screenname"))); |
|
| 545 |
|
| 546 if( username != NULL && *username != '\0' && account != NULL ) |
|
| 547 gaim_gtk_log_show( username, account ); |
|
| 548 |
|
| 549 g_free(username); |
|
| 550 } |
|
| 551 |
|
| 552 void |
|
| 553 gaim_gtkdialogs_log(void) |
|
| 554 { |
|
| 555 GaimRequestFields *fields; |
|
| 556 GaimRequestFieldGroup *group; |
|
| 557 GaimRequestField *field; |
|
| 558 |
|
| 559 fields = gaim_request_fields_new(); |
|
| 560 |
|
| 561 group = gaim_request_field_group_new(NULL); |
|
| 562 gaim_request_fields_add_group(fields, group); |
|
| 563 |
|
| 564 field = gaim_request_field_string_new("screenname", _("_Screen name"), |
|
| 565 NULL, FALSE); |
|
| 566 gaim_request_field_set_type_hint(field, "screenname"); |
|
| 567 gaim_request_field_set_required(field, TRUE); |
|
| 568 gaim_request_field_group_add_field(group, field); |
|
| 569 |
|
| 570 field = gaim_request_field_account_new("account", _("_Account"), NULL); |
|
| 571 gaim_request_field_account_set_show_all(field, TRUE); |
|
| 572 gaim_request_field_set_visible(field, |
|
| 573 (gaim_accounts_get_all() != NULL && |
|
| 574 gaim_accounts_get_all()->next != NULL)); |
|
| 575 gaim_request_field_set_required(field, TRUE); |
|
| 576 gaim_request_field_group_add_field(group, field); |
|
| 577 |
|
| 578 gaim_request_fields(gaim_get_blist(), _("Get User Log"), |
|
| 579 NULL, |
|
| 580 _("Please enter the screen name of the person whose " |
|
| 581 "log you would like to view."), |
|
| 582 fields, |
|
| 583 _("OK"), G_CALLBACK(get_log_cb), |
|
| 584 _("Cancel"), NULL, |
|
| 585 NULL); |
|
| 586 } |
|
| 587 |
|
| 588 /*------------------------------------------------------------------------*/ |
|
| 589 /* The dialog for new away messages */ |
|
| 590 /*------------------------------------------------------------------------*/ |
|
| 591 |
|
| 592 static void away_mess_destroy(GtkWidget *widget, struct create_away *ca) |
|
| 593 { |
|
| 594 destroy_dialog(NULL, ca->window); |
|
| 595 g_free(ca); |
|
| 596 } |
|
| 597 |
|
| 598 static void away_mess_destroy_ca(GtkWidget *widget, GdkEvent *event, struct create_away *ca) |
|
| 599 { |
|
| 600 away_mess_destroy(NULL, ca); |
|
| 601 } |
|
| 602 |
|
| 603 static gint sort_awaymsg_list(gconstpointer a, gconstpointer b) |
|
| 604 { |
|
| 605 struct away_message *msg_a; |
|
| 606 struct away_message *msg_b; |
|
| 607 |
|
| 608 msg_a = (struct away_message *)a; |
|
| 609 msg_b = (struct away_message *)b; |
|
| 610 |
|
| 611 return (strcmp(msg_a->name, msg_b->name)); |
|
| 612 } |
|
| 613 |
|
| 614 static struct away_message *save_away_message(struct create_away *ca) |
|
| 615 { |
|
| 616 struct away_message *am; |
|
| 617 gchar *away_message; |
|
| 618 |
|
| 619 if (!ca->mess) |
|
| 620 am = g_new0(struct away_message, 1); |
|
| 621 else { |
|
| 622 am = ca->mess; |
|
| 623 } |
|
| 624 |
|
| 625 g_snprintf(am->name, sizeof(am->name), "%s", gtk_entry_get_text(GTK_ENTRY(ca->entry))); |
|
| 626 away_message = gtk_imhtml_get_markup(GTK_IMHTML(ca->text)); |
|
| 627 |
|
| 628 g_snprintf(am->message, sizeof(am->message), "%s", away_message); |
|
| 629 g_free(away_message); |
|
| 630 |
|
| 631 if (!ca->mess) |
|
| 632 away_messages = g_slist_insert_sorted(away_messages, am, sort_awaymsg_list); |
|
| 633 |
|
| 634 do_away_menu(NULL); |
|
| 635 gaim_status_sync(); |
|
| 636 |
|
| 637 return am; |
|
| 638 } |
|
| 639 |
|
| 640 int check_away_mess(struct create_away *ca, int type) |
|
| 641 { |
|
| 642 gchar *msg; |
|
| 643 if ((strlen(gtk_entry_get_text(GTK_ENTRY(ca->entry))) == 0) && (type == 1)) { |
|
| 644 /* We shouldn't allow a blank title */ |
|
| 645 gaim_notify_error(NULL, NULL, |
|
| 646 _("You cannot save an away message with a " |
|
| 647 "blank title"), |
|
| 648 _("Please give the message a title, or choose " |
|
| 649 "\"Use\" to use without saving.")); |
|
| 650 return 0; |
|
| 651 } |
|
| 652 |
|
| 653 msg = gtk_imhtml_get_text(GTK_IMHTML(ca->text), NULL, NULL); |
|
| 654 |
|
| 655 if ((type <= 1) && ((msg == NULL) || (*msg == '\0'))) { |
|
| 656 /* We shouldn't allow a blank message */ |
|
| 657 gaim_notify_error(NULL, NULL, |
|
| 658 _("You cannot create an empty away message"), NULL); |
|
| 659 return 0; |
|
| 660 } |
|
| 661 |
|
| 662 g_free(msg); |
|
| 663 |
|
| 664 return 1; |
|
| 665 } |
|
| 666 |
|
| 667 void save_away_mess(GtkWidget *widget, struct create_away *ca) |
|
| 668 { |
|
| 669 if (!check_away_mess(ca, 1)) |
|
| 670 return; |
|
| 671 |
|
| 672 save_away_message(ca); |
|
| 673 |
|
| 674 away_mess_destroy(NULL, ca); |
|
| 675 } |
|
| 676 |
|
| 677 void use_away_mess(GtkWidget *widget, struct create_away *ca) |
|
| 678 { |
|
| 679 static struct away_message am; |
|
| 680 gchar *away_message; |
|
| 681 |
|
| 682 if (!check_away_mess(ca, 0)) |
|
| 683 return; |
|
| 684 |
|
| 685 g_snprintf(am.name, sizeof(am.name), "%s", gtk_entry_get_text(GTK_ENTRY(ca->entry))); |
|
| 686 away_message = gtk_imhtml_get_markup(GTK_IMHTML(ca->text)); |
|
| 687 |
|
| 688 g_snprintf(am.message, sizeof(am.message), "%s", away_message); |
|
| 689 g_free(away_message); |
|
| 690 |
|
| 691 do_away_message(NULL, &am); |
|
| 692 |
|
| 693 away_mess_destroy(NULL, ca); |
|
| 694 } |
|
| 695 |
|
| 696 void su_away_mess(GtkWidget *widget, struct create_away *ca) |
|
| 697 { |
|
| 698 if (!check_away_mess(ca, 1)) |
|
| 699 return; |
|
| 700 |
|
| 701 do_away_message(NULL, save_away_message(ca)); |
|
| 702 |
|
| 703 away_mess_destroy(NULL, ca); |
|
| 704 } |
|
| 705 |
|
| 706 void create_away_mess(GtkWidget *widget, void *dummy) |
|
| 707 { |
|
| 708 GtkWidget *vbox, *hbox; |
|
| 709 GtkWidget *label; |
|
| 710 GtkWidget *sw; |
|
| 711 GtkWidget *button; |
|
| 712 GList *focus_chain = NULL; |
|
| 713 struct create_away *ca = g_new0(struct create_away, 1); |
|
| 714 |
|
| 715 /* Set up window */ |
|
| 716 GAIM_DIALOG(ca->window); |
|
| 717 gtk_widget_set_size_request(ca->window, -1, 250); |
|
| 718 gtk_window_set_role(GTK_WINDOW(ca->window), "away_mess"); |
|
| 719 gtk_window_set_title(GTK_WINDOW(ca->window), _("New away message")); |
|
| 720 g_signal_connect(G_OBJECT(ca->window), "delete_event", |
|
| 721 G_CALLBACK(away_mess_destroy_ca), ca); |
|
| 722 |
|
| 723 hbox = gtk_hbox_new(FALSE, 12); |
|
| 724 gtk_container_set_border_width(GTK_CONTAINER(hbox), 12); |
|
| 725 gtk_container_add(GTK_CONTAINER(ca->window), hbox); |
|
| 726 |
|
| 727 vbox = gtk_vbox_new(FALSE, 12); |
|
| 728 gtk_container_add(GTK_CONTAINER(hbox), vbox); |
|
| 729 |
|
| 730 /* Away message title */ |
|
| 731 hbox = gtk_hbox_new(FALSE, 0); |
|
| 732 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
|
| 733 |
|
| 734 label = gtk_label_new(_("Away title: ")); |
|
| 735 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
|
| 736 |
|
| 737 ca->entry = gtk_entry_new(); |
|
| 738 gtk_box_pack_start(GTK_BOX(hbox), ca->entry, TRUE, TRUE, 0); |
|
| 739 gaim_set_accessible_label (ca->entry, label); |
|
| 740 focus_chain = g_list_append(focus_chain, hbox); |
|
| 741 |
|
| 742 /* Toolbar */ |
|
| 743 ca->toolbar = gtk_imhtmltoolbar_new(); |
|
| 744 gtk_box_pack_start(GTK_BOX(vbox), ca->toolbar, FALSE, FALSE, 0); |
|
| 745 |
|
| 746 /* Away message text */ |
|
| 747 sw = gtk_scrolled_window_new(NULL, NULL); |
|
| 748 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), |
|
| 749 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
|
| 750 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
|
| 751 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); |
|
| 752 |
|
| 753 ca->text = gtk_imhtml_new(NULL, NULL); |
|
| 754 gtk_imhtml_set_editable(GTK_IMHTML(ca->text), TRUE); |
|
| 755 gtk_imhtml_set_format_functions(GTK_IMHTML(ca->text), GTK_IMHTML_ALL ^ GTK_IMHTML_IMAGE); |
|
| 756 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(ca->text), GTK_WRAP_WORD_CHAR); |
|
| 757 |
|
| 758 gtk_imhtml_smiley_shortcuts(GTK_IMHTML(ca->text), |
|
| 759 gaim_prefs_get_bool("/gaim/gtk/conversations/smiley_shortcuts")); |
|
| 760 gtk_imhtml_html_shortcuts(GTK_IMHTML(ca->text), |
|
| 761 gaim_prefs_get_bool("/gaim/gtk/conversations/html_shortcuts")); |
|
| 762 if (gaim_prefs_get_bool("/gaim/gtk/conversations/spellcheck")) |
|
| 763 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(ca->text)); |
|
| 764 gtk_imhtmltoolbar_attach(GTK_IMHTMLTOOLBAR(ca->toolbar), ca->text); |
|
| 765 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(ca->toolbar), "default"); |
|
| 766 gaim_setup_imhtml(ca->text); |
|
| 767 |
|
| 768 gtk_container_add(GTK_CONTAINER(sw), ca->text); |
|
| 769 focus_chain = g_list_append(focus_chain, sw); |
|
| 770 |
|
| 771 if (dummy) { |
|
| 772 struct away_message *amt; |
|
| 773 GtkTreeIter iter; |
|
| 774 GtkListStore *ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(dummy))); |
|
| 775 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(dummy)); |
|
| 776 GValue val = { 0, }; |
|
| 777 |
|
| 778 if (! gtk_tree_selection_get_selected (sel, (GtkTreeModel**)&ls, &iter)) |
|
| 779 return; |
|
| 780 gtk_tree_model_get_value (GTK_TREE_MODEL(ls), &iter, 1, &val); |
|
| 781 amt = g_value_get_pointer (&val); |
|
| 782 gtk_entry_set_text(GTK_ENTRY(ca->entry), amt->name); |
|
| 783 gtk_imhtml_append_text_with_images(GTK_IMHTML(ca->text), amt->message, 0, NULL); |
|
| 784 ca->mess = amt; |
|
| 785 } |
|
| 786 |
|
| 787 hbox = gtk_hbox_new(FALSE, 5); |
|
| 788 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
|
| 789 |
|
| 790 button = gaim_pixbuf_button_from_stock(_("_Save"), GTK_STOCK_SAVE, GAIM_BUTTON_HORIZONTAL); |
|
| 791 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(save_away_mess), ca); |
|
| 792 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
|
| 793 |
|
| 794 button = gaim_pixbuf_button_from_stock(_("Sa_ve & Use"), GTK_STOCK_OK, GAIM_BUTTON_HORIZONTAL); |
|
| 795 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(su_away_mess), ca); |
|
| 796 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
|
| 797 |
|
| 798 button = gaim_pixbuf_button_from_stock(_("_Use"), GTK_STOCK_EXECUTE, GAIM_BUTTON_HORIZONTAL); |
|
| 799 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(use_away_mess), ca); |
|
| 800 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
|
| 801 |
|
| 802 button = gaim_pixbuf_button_from_stock(_("_Cancel"), GTK_STOCK_CANCEL, GAIM_BUTTON_HORIZONTAL); |
|
| 803 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(away_mess_destroy), ca); |
|
| 804 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
|
| 805 focus_chain = g_list_prepend(focus_chain, hbox); |
|
| 806 |
|
| 807 gtk_widget_show_all(ca->window); |
|
| 808 gtk_container_set_focus_chain(GTK_CONTAINER(vbox), focus_chain); |
|
| 809 } |
|
| 810 |
|
| 811 static void |
|
| 812 alias_chat_cb(GaimChat *chat, const char *new_alias) |
|
| 813 { |
|
| 814 gaim_blist_alias_chat(chat, new_alias); |
|
| 815 } |
|
| 816 |
|
| 817 void |
|
| 818 alias_dialog_blist_chat(GaimChat *chat) |
|
| 819 { |
|
| 820 gaim_request_input(NULL, _("Alias Chat"), NULL, |
|
| 821 _("Enter an alias for this chat."), |
|
| 822 chat->alias, FALSE, FALSE, NULL, |
|
| 823 _("Alias"), G_CALLBACK(alias_chat_cb), |
|
| 824 _("Cancel"), NULL, chat); |
|
| 825 } |
|
| 826 |
|
| 827 static void |
|
| 828 alias_contact_cb(GaimContact *contact, const char *new_alias) |
|
| 829 { |
|
| 830 gaim_contact_set_alias(contact, new_alias); |
|
| 831 } |
|
| 832 |
|
| 833 void |
|
| 834 alias_dialog_contact(GaimContact *contact) |
|
| 835 { |
|
| 836 gaim_request_input(NULL, _("Alias Contact"), NULL, |
|
| 837 _("Enter an alias for this contact."), |
|
| 838 contact->alias, FALSE, FALSE, NULL, |
|
| 839 _("Alias"), G_CALLBACK(alias_contact_cb), |
|
| 840 _("Cancel"), NULL, contact); |
|
| 841 } |
|
| 842 |
|
| 843 static void |
|
| 844 alias_buddy_cb(GaimBuddy *buddy, const char *alias) |
|
| 845 { |
|
| 846 gaim_blist_alias_buddy(buddy, (alias != NULL && *alias != '\0') ? alias : NULL); |
|
| 847 serv_alias_buddy(buddy); |
|
| 848 } |
|
| 849 |
|
| 850 void |
|
| 851 alias_dialog_bud(GaimBuddy *b) |
|
| 852 { |
|
| 853 char *secondary = g_strdup_printf(_("Enter an alias for %s."), b->name); |
|
| 854 |
|
| 855 gaim_request_input(NULL, _("Alias Buddy"), NULL, |
|
| 856 secondary, b->alias, FALSE, FALSE, NULL, |
|
| 857 _("Alias"), G_CALLBACK(alias_buddy_cb), |
|
| 858 _("Cancel"), NULL, b); |
|
| 859 |
|
| 860 g_free(secondary); |
|
| 861 } |
|