pidgin/gtkrequest.c

changeset 34331
c8486462bb63
parent 34330
35d5e8fcc07b
child 34332
876483829700
equal deleted inserted replaced
34330:35d5e8fcc07b 34331:c8486462bb63
577 577
578 return data; 578 return data;
579 } 579 }
580 580
581 static void * 581 static void *
582 pidgin_request_action_with_icon(const char *title, const char *primary, 582 pidgin_request_action(const char *title, const char *primary,
583 const char *secondary, int default_action, 583 const char *secondary, int default_action,
584 PurpleAccount *account, const char *who, 584 PurpleRequestCommonParameters *cpar, void *user_data,
585 PurpleConversation *conv, gconstpointer icon_data, 585 size_t action_count, va_list actions)
586 gsize icon_size,
587 void *user_data, size_t action_count, va_list actions)
588 { 586 {
589 PidginRequestData *data; 587 PidginRequestData *data;
590 GtkWidget *dialog; 588 GtkWidget *dialog;
591 GtkWidget *vbox; 589 GtkWidget *vbox;
592 GtkWidget *hbox; 590 GtkWidget *hbox;
594 GtkWidget *img = NULL; 592 GtkWidget *img = NULL;
595 void **buttons; 593 void **buttons;
596 char *label_text; 594 char *label_text;
597 char *primary_esc, *secondary_esc; 595 char *primary_esc, *secondary_esc;
598 gsize i; 596 gsize i;
597 gconstpointer icon_data;
598 gsize icon_size;
599 599
600 data = g_new0(PidginRequestData, 1); 600 data = g_new0(PidginRequestData, 1);
601 data->type = PURPLE_REQUEST_ACTION; 601 data->type = PURPLE_REQUEST_ACTION;
602 data->user_data = user_data; 602 data->user_data = user_data;
603 603
648 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); 648 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER);
649 gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), 649 gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),
650 hbox); 650 hbox);
651 651
652 /* Dialog icon. */ 652 /* Dialog icon. */
653 icon_data = purple_request_cpar_get_custom_icon(cpar, &icon_size);
653 if (icon_data) { 654 if (icon_data) {
654 GdkPixbuf *pixbuf = pidgin_pixbuf_from_data(icon_data, icon_size); 655 GdkPixbuf *pixbuf = pidgin_pixbuf_from_data(icon_data, icon_size);
655 if (pixbuf) { 656 if (pixbuf) {
656 /* scale the image if it is too large */ 657 /* scale the image if it is too large */
657 int width = gdk_pixbuf_get_width(pixbuf); 658 int width = gdk_pixbuf_get_width(pixbuf);
686 687
687 /* Vertical box */ 688 /* Vertical box */
688 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); 689 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER);
689 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); 690 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
690 691
691 pidgin_widget_decorate_account(hbox, account); 692 pidgin_widget_decorate_account(hbox,
693 purple_request_cpar_get_account(cpar));
692 694
693 /* Descriptive label */ 695 /* Descriptive label */
694 primary_esc = (primary != NULL) ? g_markup_escape_text(primary, -1) : NULL; 696 primary_esc = (primary != NULL) ? g_markup_escape_text(primary, -1) : NULL;
695 secondary_esc = (secondary != NULL) ? g_markup_escape_text(secondary, -1) : NULL; 697 secondary_esc = (secondary != NULL) ? g_markup_escape_text(secondary, -1) : NULL;
696 label_text = g_strdup_printf((primary ? "<span weight=\"bold\" size=\"larger\">" 698 label_text = g_strdup_printf((primary ? "<span weight=\"bold\" size=\"larger\">"
728 pidgin_auto_parent_window(dialog); 730 pidgin_auto_parent_window(dialog);
729 731
730 gtk_widget_show_all(dialog); 732 gtk_widget_show_all(dialog);
731 733
732 return data; 734 return data;
733 }
734
735 static void *
736 pidgin_request_action(const char *title, const char *primary,
737 const char *secondary, int default_action,
738 PurpleAccount *account, const char *who, PurpleConversation *conv,
739 void *user_data, size_t action_count, va_list actions)
740 {
741 return pidgin_request_action_with_icon(title, primary, secondary,
742 default_action, account, who, conv, NULL, 0, user_data, action_count,
743 actions);
744 } 735 }
745 736
746 static void 737 static void
747 req_entry_field_changed_cb(GtkWidget *entry, PurpleRequestField *field) 738 req_entry_field_changed_cb(GtkWidget *entry, PurpleRequestField *field)
748 { 739 {
1616 } 1607 }
1617 if ((data->u.file.savedialog == TRUE) && 1608 if ((data->u.file.savedialog == TRUE) &&
1618 (g_file_test(data->u.file.name, G_FILE_TEST_EXISTS))) { 1609 (g_file_test(data->u.file.name, G_FILE_TEST_EXISTS))) {
1619 purple_request_action(data, NULL, _("That file already exists"), 1610 purple_request_action(data, NULL, _("That file already exists"),
1620 _("Would you like to overwrite it?"), 0, 1611 _("Would you like to overwrite it?"), 0,
1621 NULL, NULL, NULL, 1612 NULL,
1622 data, 2, 1613 data, 2,
1623 _("Overwrite"), G_CALLBACK(file_yes_no_cb), 1614 _("Overwrite"), G_CALLBACK(file_yes_no_cb),
1624 _("Choose New Name"), G_CALLBACK(file_yes_no_cb)); 1615 _("Choose New Name"), G_CALLBACK(file_yes_no_cb));
1625 } else 1616 } else
1626 file_yes_no_cb(data, 1); 1617 file_yes_no_cb(data, 1);
1795 pidgin_request_action, 1786 pidgin_request_action,
1796 pidgin_request_fields, 1787 pidgin_request_fields,
1797 pidgin_request_file, 1788 pidgin_request_file,
1798 pidgin_close_request, 1789 pidgin_close_request,
1799 pidgin_request_folder, 1790 pidgin_request_folder,
1800 pidgin_request_action_with_icon, 1791 NULL,
1801 NULL, 1792 NULL,
1802 NULL, 1793 NULL,
1803 NULL 1794 NULL
1804 }; 1795 };
1805 1796

mercurial