| 329 } |
329 } |
| 330 |
330 |
| 331 return g_markup_escape_text(text, -1); |
331 return g_markup_escape_text(text, -1); |
| 332 } |
332 } |
| 333 |
333 |
| |
334 static GtkWidget * |
| |
335 pidgin_request_dialog_icon(PurpleRequestCommonParameters *cpar) |
| |
336 { |
| |
337 GtkWidget *img = NULL; |
| |
338 PurpleRequestIconType icon_type; |
| |
339 gconstpointer icon_data; |
| |
340 gsize icon_size; |
| |
341 const gchar *icon_stock = PIDGIN_STOCK_DIALOG_QUESTION; |
| |
342 |
| |
343 /* Dialog icon. */ |
| |
344 icon_data = purple_request_cpar_get_custom_icon(cpar, &icon_size); |
| |
345 if (icon_data) { |
| |
346 GdkPixbuf *pixbuf; |
| |
347 |
| |
348 pixbuf = pidgin_pixbuf_from_data(icon_data, icon_size); |
| |
349 if (pixbuf) { |
| |
350 /* scale the image if it is too large */ |
| |
351 int width = gdk_pixbuf_get_width(pixbuf); |
| |
352 int height = gdk_pixbuf_get_height(pixbuf); |
| |
353 if (width > 128 || height > 128) { |
| |
354 int scaled_width = width > height ? |
| |
355 128 : (128 * width) / height; |
| |
356 int scaled_height = height > width ? |
| |
357 128 : (128 * height) / width; |
| |
358 GdkPixbuf *scaled; |
| |
359 |
| |
360 purple_debug_info("pidgin", "dialog icon was " |
| |
361 "too large, scaling it down"); |
| |
362 |
| |
363 scaled = gdk_pixbuf_scale_simple(pixbuf, |
| |
364 scaled_width, scaled_height, |
| |
365 GDK_INTERP_BILINEAR); |
| |
366 if (scaled) { |
| |
367 g_object_unref(pixbuf); |
| |
368 pixbuf = scaled; |
| |
369 } |
| |
370 } |
| |
371 img = gtk_image_new_from_pixbuf(pixbuf); |
| |
372 g_object_unref(pixbuf); |
| |
373 } else { |
| |
374 purple_debug_info("pidgin", |
| |
375 "failed to parse dialog icon"); |
| |
376 } |
| |
377 } |
| |
378 |
| |
379 if (img) |
| |
380 return img; |
| |
381 |
| |
382 icon_type = purple_request_cpar_get_icon(cpar); |
| |
383 switch (icon_type) |
| |
384 { |
| |
385 case PURPLE_REQUEST_ICON_REQUEST: |
| |
386 icon_stock = PIDGIN_STOCK_DIALOG_QUESTION; |
| |
387 break; |
| |
388 case PURPLE_REQUEST_ICON_DIALOG: |
| |
389 case PURPLE_REQUEST_ICON_INFO: |
| |
390 icon_stock = PIDGIN_STOCK_DIALOG_INFO; |
| |
391 break; |
| |
392 case PURPLE_REQUEST_ICON_WARNING: |
| |
393 icon_stock = PIDGIN_STOCK_DIALOG_WARNING; |
| |
394 break; |
| |
395 case PURPLE_REQUEST_ICON_ERROR: |
| |
396 icon_stock = PIDGIN_STOCK_DIALOG_ERROR; |
| |
397 break; |
| |
398 /* intentionally no default value */ |
| |
399 } |
| |
400 |
| |
401 img = gtk_image_new_from_stock(icon_stock, |
| |
402 gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_HUGE)); |
| |
403 |
| |
404 if (img || icon_type == PURPLE_REQUEST_ICON_REQUEST) |
| |
405 return img; |
| |
406 |
| |
407 return gtk_image_new_from_stock(PIDGIN_STOCK_DIALOG_QUESTION, |
| |
408 gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_HUGE)); |
| |
409 } |
| |
410 |
| 334 static void * |
411 static void * |
| 335 pidgin_request_input(const char *title, const char *primary, |
412 pidgin_request_input(const char *title, const char *primary, |
| 336 const char *secondary, const char *default_value, |
413 const char *secondary, const char *default_value, |
| 337 gboolean multiline, gboolean masked, gchar *hint, |
414 gboolean multiline, gboolean masked, gchar *hint, |
| 338 const char *ok_text, GCallback ok_cb, |
415 const char *ok_text, GCallback ok_cb, |
| 385 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); |
462 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); |
| 386 gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), |
463 gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), |
| 387 hbox); |
464 hbox); |
| 388 |
465 |
| 389 /* Dialog icon. */ |
466 /* Dialog icon. */ |
| 390 img = gtk_image_new_from_stock(PIDGIN_STOCK_DIALOG_QUESTION, |
467 img = pidgin_request_dialog_icon(cpar); |
| 391 gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_HUGE)); |
|
| 392 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); |
468 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); |
| 393 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
469 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
| 394 |
470 |
| 395 /* Vertical box */ |
471 /* Vertical box */ |
| 396 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); |
472 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); |
| 546 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); |
622 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); |
| 547 gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), |
623 gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), |
| 548 hbox); |
624 hbox); |
| 549 |
625 |
| 550 /* Dialog icon. */ |
626 /* Dialog icon. */ |
| 551 img = gtk_image_new_from_stock(PIDGIN_STOCK_DIALOG_QUESTION, |
627 img = pidgin_request_dialog_icon(cpar); |
| 552 gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_HUGE)); |
|
| 553 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); |
628 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); |
| 554 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
629 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
| 555 |
630 |
| 556 pidgin_widget_decorate_account(hbox, purple_request_cpar_get_account(cpar)); |
631 pidgin_widget_decorate_account(hbox, purple_request_cpar_get_account(cpar)); |
| 557 |
632 |
| 669 /* Setup the main horizontal box */ |
742 /* Setup the main horizontal box */ |
| 670 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); |
743 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); |
| 671 gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), |
744 gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), |
| 672 hbox); |
745 hbox); |
| 673 |
746 |
| 674 /* Dialog icon. */ |
747 img = pidgin_request_dialog_icon(cpar); |
| 675 icon_data = purple_request_cpar_get_custom_icon(cpar, &icon_size); |
|
| 676 if (icon_data) { |
|
| 677 GdkPixbuf *pixbuf = pidgin_pixbuf_from_data(icon_data, icon_size); |
|
| 678 if (pixbuf) { |
|
| 679 /* scale the image if it is too large */ |
|
| 680 int width = gdk_pixbuf_get_width(pixbuf); |
|
| 681 int height = gdk_pixbuf_get_height(pixbuf); |
|
| 682 if (width > 128 || height > 128) { |
|
| 683 int scaled_width = width > height ? 128 : (128 * width) / height; |
|
| 684 int scaled_height = height > width ? 128 : (128 * height) / width; |
|
| 685 GdkPixbuf *scaled = |
|
| 686 gdk_pixbuf_scale_simple(pixbuf, scaled_width, scaled_height, |
|
| 687 GDK_INTERP_BILINEAR); |
|
| 688 |
|
| 689 purple_debug_info("pidgin", |
|
| 690 "dialog icon was too large, scaled it down\n"); |
|
| 691 if (scaled) { |
|
| 692 g_object_unref(pixbuf); |
|
| 693 pixbuf = scaled; |
|
| 694 } |
|
| 695 } |
|
| 696 img = gtk_image_new_from_pixbuf(pixbuf); |
|
| 697 g_object_unref(pixbuf); |
|
| 698 } else { |
|
| 699 purple_debug_info("pidgin", "failed to parse dialog icon\n"); |
|
| 700 } |
|
| 701 } |
|
| 702 |
|
| 703 if (!img) { |
|
| 704 img = gtk_image_new_from_stock(PIDGIN_STOCK_DIALOG_QUESTION, |
|
| 705 gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_HUGE)); |
|
| 706 } |
|
| 707 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); |
748 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); |
| 708 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
749 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
| 709 |
750 |
| 710 /* Vertical box */ |
751 /* Vertical box */ |
| 711 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); |
752 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); |
| 1283 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); |
1324 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); |
| 1284 gtk_container_add(GTK_CONTAINER(pidgin_dialog_get_vbox(GTK_DIALOG(win))), hbox); |
1325 gtk_container_add(GTK_CONTAINER(pidgin_dialog_get_vbox(GTK_DIALOG(win))), hbox); |
| 1285 gtk_widget_show(hbox); |
1326 gtk_widget_show(hbox); |
| 1286 |
1327 |
| 1287 /* Dialog icon. */ |
1328 /* Dialog icon. */ |
| 1288 img = gtk_image_new_from_stock(PIDGIN_STOCK_DIALOG_QUESTION, |
1329 img = pidgin_request_dialog_icon(cpar); |
| 1289 gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_HUGE)); |
|
| 1290 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); |
1330 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); |
| 1291 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
1331 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
| 1292 gtk_widget_show(img); |
1332 gtk_widget_show(img); |
| 1293 |
1333 |
| 1294 /* Cancel button */ |
1334 /* Cancel button */ |