477 | 477 |
roster_window_remove_error (self, account);
|
478 | 478 |
}
|
479 | 479 |
|
480 | |
static void
|
481 | |
roster_window_error_retry_clicked_cb (GtkButton *button,
|
|
480 |
typedef enum
|
|
481 |
{
|
|
482 |
ERROR_RESPONSE_RETRY,
|
|
483 |
ERROR_RESPONSE_EDIT,
|
|
484 |
ERROR_RESPONSE_CLOSE,
|
|
485 |
ERROR_RESPONSE_UPGRADE,
|
|
486 |
} ErrorResponse;
|
|
487 |
|
|
488 |
static void
|
|
489 |
roster_window_error_response_cb (GtkInfoBar *infobar,
|
|
490 |
gint response_id,
|
482 | 491 |
EmpathyRosterWindow *self)
|
483 | 492 |
{
|
484 | 493 |
TpAccount *account;
|
485 | 494 |
|
486 | |
account = g_object_get_data (G_OBJECT (button), "account");
|
487 | |
tp_account_reconnect_async (account, NULL, NULL);
|
|
495 |
account = g_object_get_data (G_OBJECT (infobar), "account");
|
|
496 |
|
|
497 |
switch (response_id)
|
|
498 |
{
|
|
499 |
case ERROR_RESPONSE_RETRY:
|
|
500 |
tp_account_reconnect_async (account, NULL, NULL);
|
|
501 |
break;
|
|
502 |
|
|
503 |
case ERROR_RESPONSE_EDIT:
|
|
504 |
empathy_accounts_dialog_show_application (
|
|
505 |
gtk_widget_get_screen (GTK_WIDGET (infobar)),
|
|
506 |
account, FALSE, FALSE);
|
|
507 |
break;
|
|
508 |
|
|
509 |
case ERROR_RESPONSE_CLOSE:
|
|
510 |
break;
|
|
511 |
|
|
512 |
case ERROR_RESPONSE_UPGRADE:
|
|
513 |
{
|
|
514 |
GtkWidget *dialog;
|
|
515 |
|
|
516 |
dialog = gtk_message_dialog_new (GTK_WINDOW (self),
|
|
517 |
GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
|
|
518 |
_("Sorry, %s accounts can’t be used until your %s software is updated."),
|
|
519 |
tp_account_get_protocol_name (account),
|
|
520 |
tp_account_get_protocol_name (account));
|
|
521 |
|
|
522 |
g_signal_connect_swapped (dialog, "response",
|
|
523 |
G_CALLBACK (gtk_widget_destroy),
|
|
524 |
dialog);
|
|
525 |
|
|
526 |
gtk_widget_show (dialog);
|
|
527 |
}
|
|
528 |
}
|
488 | 529 |
|
489 | 530 |
roster_window_remove_error (self, account);
|
490 | 531 |
}
|
491 | 532 |
|
492 | |
static void
|
493 | |
roster_window_error_edit_clicked_cb (GtkButton *button,
|
494 | |
EmpathyRosterWindow *self)
|
495 | |
{
|
496 | |
TpAccount *account;
|
497 | |
|
498 | |
account = g_object_get_data (G_OBJECT (button), "account");
|
499 | |
|
500 | |
empathy_accounts_dialog_show_application (
|
501 | |
gtk_widget_get_screen (GTK_WIDGET (button)),
|
502 | |
account, FALSE, FALSE);
|
503 | |
|
504 | |
roster_window_remove_error (self, account);
|
505 | |
}
|
506 | |
|
507 | |
static void
|
508 | |
roster_window_error_close_clicked_cb (GtkButton *button,
|
509 | |
EmpathyRosterWindow *self)
|
510 | |
{
|
511 | |
TpAccount *account;
|
512 | |
|
513 | |
account = g_object_get_data (G_OBJECT (button), "account");
|
514 | |
roster_window_remove_error (self, account);
|
515 | |
}
|
516 | |
|
517 | |
static void
|
518 | |
roster_window_error_upgrade_sw_clicked_cb (GtkButton *button,
|
519 | |
EmpathyRosterWindow *self)
|
520 | |
{
|
521 | |
TpAccount *account;
|
522 | |
GtkWidget *dialog;
|
523 | |
|
524 | |
account = g_object_get_data (G_OBJECT (button), "account");
|
525 | |
roster_window_remove_error (self, account);
|
526 | |
|
527 | |
dialog = gtk_message_dialog_new (GTK_WINDOW (self),
|
528 | |
GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR,
|
529 | |
GTK_BUTTONS_OK,
|
530 | |
_("Sorry, %s accounts can’t be used until your %s software is updated."),
|
531 | |
tp_account_get_protocol_name (account),
|
532 | |
tp_account_get_protocol_name (account));
|
533 | |
|
534 | |
g_signal_connect_swapped (dialog, "response",
|
535 | |
G_CALLBACK (gtk_widget_destroy),
|
536 | |
dialog);
|
537 | |
|
538 | |
gtk_widget_show (dialog);
|
539 | |
}
|
540 | |
|
541 | |
static void
|
542 | |
roster_window_upgrade_software_error (EmpathyRosterWindow *self,
|
543 | |
TpAccount *account)
|
|
533 |
static GtkWidget *
|
|
534 |
roster_window_error_create_info_bar (EmpathyRosterWindow *self,
|
|
535 |
TpAccount *account,
|
|
536 |
GtkMessageType message_type,
|
|
537 |
const gchar *message_markup)
|
544 | 538 |
{
|
545 | 539 |
GtkWidget *info_bar;
|
546 | 540 |
GtkWidget *content_area;
|
|
541 |
GtkWidget *action_area;
|
547 | 542 |
GtkWidget *label;
|
548 | 543 |
GtkWidget *image;
|
549 | |
GtkWidget *upgrade_button;
|
550 | |
GtkWidget *close_button;
|
551 | |
GtkWidget *action_area;
|
552 | |
GtkWidget *action_grid;
|
553 | |
gchar *str;
|
554 | 544 |
const gchar *icon_name;
|
555 | |
const gchar *error_message;
|
556 | |
gboolean user_requested;
|
557 | |
|
558 | |
error_message =
|
559 | |
empathy_account_get_error_message (account, &user_requested);
|
560 | |
|
561 | |
if (user_requested)
|
562 | |
return;
|
563 | |
|
564 | |
str = g_markup_printf_escaped ("<b>%s</b>\n%s",
|
565 | |
tp_account_get_display_name (account),
|
566 | |
error_message);
|
567 | 545 |
|
568 | 546 |
/* If there are other errors, remove them */
|
569 | 547 |
roster_window_remove_error (self, account);
|
570 | 548 |
|
571 | 549 |
info_bar = gtk_info_bar_new ();
|
572 | |
gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), GTK_MESSAGE_ERROR);
|
|
550 |
gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), message_type);
|
573 | 551 |
|
574 | 552 |
gtk_widget_set_no_show_all (info_bar, TRUE);
|
575 | 553 |
gtk_box_pack_start (GTK_BOX (self->priv->errors_vbox), info_bar, FALSE, TRUE, 0);
|
|
579 | 557 |
image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_SMALL_TOOLBAR);
|
580 | 558 |
gtk_widget_show (image);
|
581 | 559 |
|
582 | |
label = gtk_label_new (str);
|
|
560 |
label = gtk_label_new (message_markup);
|
583 | 561 |
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
|
584 | |
gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
|
|
562 |
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
|
585 | 563 |
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
|
586 | 564 |
gtk_widget_show (label);
|
587 | |
g_free (str);
|
588 | 565 |
|
589 | 566 |
content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar));
|
590 | 567 |
gtk_box_pack_start (GTK_BOX (content_area), image, FALSE, FALSE, 0);
|
591 | 568 |
gtk_box_pack_start (GTK_BOX (content_area), label, TRUE, TRUE, 0);
|
592 | 569 |
|
593 | |
image = gtk_image_new_from_stock (GTK_STOCK_REFRESH, GTK_ICON_SIZE_BUTTON);
|
594 | |
upgrade_button = gtk_button_new ();
|
595 | |
gtk_button_set_image (GTK_BUTTON (upgrade_button), image);
|
596 | |
gtk_widget_set_tooltip_text (upgrade_button, _("Update software..."));
|
597 | |
gtk_widget_show (upgrade_button);
|
598 | |
|
599 | |
image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_BUTTON);
|
600 | |
close_button = gtk_button_new ();
|
601 | |
gtk_button_set_image (GTK_BUTTON (close_button), image);
|
602 | |
gtk_widget_set_tooltip_text (close_button, _("Close"));
|
603 | |
gtk_widget_show (close_button);
|
604 | |
|
605 | |
action_grid = gtk_grid_new ();
|
606 | |
gtk_grid_set_column_spacing (GTK_GRID (action_grid), 2);
|
607 | |
gtk_widget_show (action_grid);
|
608 | |
|
609 | 570 |
action_area = gtk_info_bar_get_action_area (GTK_INFO_BAR (info_bar));
|
610 | |
gtk_box_pack_start (GTK_BOX (action_area), action_grid, FALSE, FALSE, 0);
|
611 | |
|
612 | |
gtk_grid_attach (GTK_GRID (action_grid), upgrade_button, 0, 0, 1, 1);
|
613 | |
gtk_grid_attach (GTK_GRID (action_grid), close_button, 1, 0, 1, 1);
|
614 | |
|
615 | |
g_object_set_data (G_OBJECT (info_bar), "label", label);
|
|
571 |
gtk_orientable_set_orientation (GTK_ORIENTABLE (action_area),
|
|
572 |
GTK_ORIENTATION_HORIZONTAL);
|
|
573 |
gtk_style_context_add_class (gtk_widget_get_style_context (action_area),
|
|
574 |
"empathy-roster-window-error-button");
|
|
575 |
|
616 | 576 |
g_object_set_data_full (G_OBJECT (info_bar),
|
617 | 577 |
"account", g_object_ref (account),
|
618 | 578 |
g_object_unref);
|
619 | |
g_object_set_data_full (G_OBJECT (upgrade_button),
|
620 | |
"account", g_object_ref (account),
|
621 | |
g_object_unref);
|
622 | |
g_object_set_data_full (G_OBJECT (close_button),
|
623 | |
"account", g_object_ref (account),
|
624 | |
g_object_unref);
|
625 | |
|
626 | |
g_signal_connect (upgrade_button, "clicked",
|
627 | |
G_CALLBACK (roster_window_error_upgrade_sw_clicked_cb), self);
|
628 | |
g_signal_connect (close_button, "clicked",
|
629 | |
G_CALLBACK (roster_window_error_close_clicked_cb), self);
|
630 | |
|
631 | |
gtk_widget_set_tooltip_text (self->priv->errors_vbox, error_message);
|
|
579 |
|
|
580 |
g_signal_connect (info_bar, "response",
|
|
581 |
G_CALLBACK (roster_window_error_response_cb), self);
|
|
582 |
|
632 | 583 |
gtk_widget_show (self->priv->errors_vbox);
|
633 | 584 |
|
634 | 585 |
g_hash_table_insert (self->priv->errors, g_object_ref (account), info_bar);
|
|
586 |
|
|
587 |
return info_bar;
|
|
588 |
}
|
|
589 |
|
|
590 |
static void
|
|
591 |
roster_window_error_add_stock_button (GtkInfoBar *info_bar,
|
|
592 |
const gchar *stock_id,
|
|
593 |
const gchar *tooltip,
|
|
594 |
ErrorResponse response_id)
|
|
595 |
{
|
|
596 |
GtkWidget *image;
|
|
597 |
GtkWidget *button;
|
|
598 |
|
|
599 |
image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_BUTTON);
|
|
600 |
button = gtk_button_new ();
|
|
601 |
gtk_button_set_image (GTK_BUTTON (button), image);
|
|
602 |
gtk_widget_set_tooltip_text (button, tooltip);
|
|
603 |
gtk_widget_show (button);
|
|
604 |
|
|
605 |
gtk_info_bar_add_action_widget (info_bar, button, response_id);
|
635 | 606 |
}
|
636 | 607 |
|
637 | 608 |
static void
|
638 | 609 |
roster_window_error_display (EmpathyRosterWindow *self,
|
639 | 610 |
TpAccount *account)
|
640 | 611 |
{
|
641 | |
GtkWidget *info_bar;
|
642 | |
GtkWidget *content_area;
|
643 | |
GtkWidget *label;
|
644 | |
GtkWidget *image;
|
645 | |
GtkWidget *retry_button;
|
646 | |
GtkWidget *edit_button;
|
647 | |
GtkWidget *close_button;
|
648 | |
GtkWidget *action_area;
|
649 | |
GtkWidget *action_grid;
|
650 | |
gchar *str;
|
651 | |
const gchar *icon_name;
|
652 | 612 |
const gchar *error_message;
|
653 | 613 |
gboolean user_requested;
|
|
614 |
GtkWidget *info_bar;
|
|
615 |
gchar *str;
|
|
616 |
|
|
617 |
error_message =
|
|
618 |
empathy_account_get_error_message (account, &user_requested);
|
|
619 |
|
|
620 |
if (user_requested)
|
|
621 |
return;
|
|
622 |
|
|
623 |
str = g_markup_printf_escaped ("<b>%s</b>\n%s",
|
|
624 |
tp_account_get_display_name (account), error_message);
|
|
625 |
|
|
626 |
info_bar = roster_window_error_create_info_bar (self, account,
|
|
627 |
GTK_MESSAGE_ERROR, str);
|
|
628 |
g_free (str);
|
|
629 |
|
|
630 |
gtk_widget_set_tooltip_text (self->priv->errors_vbox, error_message);
|
654 | 631 |
|
655 | 632 |
if (!tp_strdiff (TP_ERROR_STR_SOFTWARE_UPGRADE_REQUIRED,
|
656 | 633 |
tp_account_get_detailed_error (account, NULL)))
|
657 | 634 |
{
|
658 | |
roster_window_upgrade_software_error (self, account);
|
659 | |
return;
|
660 | |
}
|
661 | |
|
662 | |
error_message = empathy_account_get_error_message (account, &user_requested);
|
663 | |
|
664 | |
if (user_requested)
|
665 | |
return;
|
666 | |
|
667 | |
str = g_markup_printf_escaped ("<b>%s</b>\n%s",
|
668 | |
tp_account_get_display_name (account), error_message);
|
669 | |
|
670 | |
info_bar = g_hash_table_lookup (self->priv->errors, account);
|
671 | |
if (info_bar)
|
672 | |
{
|
673 | |
label = g_object_get_data (G_OBJECT (info_bar), "label");
|
674 | |
|
675 | |
/* Just set the latest error and return */
|
676 | |
gtk_label_set_markup (GTK_LABEL (label), str);
|
677 | |
g_free (str);
|
678 | |
|
679 | |
return;
|
680 | |
}
|
681 | |
|
682 | |
info_bar = gtk_info_bar_new ();
|
683 | |
gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), GTK_MESSAGE_ERROR);
|
684 | |
|
685 | |
gtk_widget_set_no_show_all (info_bar, TRUE);
|
686 | |
gtk_box_pack_start (GTK_BOX (self->priv->errors_vbox), info_bar, FALSE, TRUE, 0);
|
687 | |
gtk_widget_show (info_bar);
|
688 | |
|
689 | |
icon_name = tp_account_get_icon_name (account);
|
690 | |
image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_SMALL_TOOLBAR);
|
691 | |
gtk_widget_show (image);
|
692 | |
|
693 | |
label = gtk_label_new (str);
|
694 | |
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
|
695 | |
gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
|
696 | |
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
|
697 | |
gtk_widget_show (label);
|
698 | |
g_free (str);
|
699 | |
|
700 | |
content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar));
|
701 | |
gtk_box_pack_start (GTK_BOX (content_area), image, FALSE, FALSE, 0);
|
702 | |
gtk_box_pack_start (GTK_BOX (content_area), label, TRUE, TRUE, 0);
|
703 | |
|
704 | |
image = gtk_image_new_from_stock (GTK_STOCK_REFRESH, GTK_ICON_SIZE_BUTTON);
|
705 | |
retry_button = gtk_button_new ();
|
706 | |
gtk_button_set_image (GTK_BUTTON (retry_button), image);
|
707 | |
gtk_widget_set_tooltip_text (retry_button, _("Reconnect"));
|
708 | |
gtk_widget_show (retry_button);
|
709 | |
|
710 | |
image = gtk_image_new_from_stock (GTK_STOCK_EDIT, GTK_ICON_SIZE_BUTTON);
|
711 | |
edit_button = gtk_button_new ();
|
712 | |
gtk_button_set_image (GTK_BUTTON (edit_button), image);
|
713 | |
gtk_widget_set_tooltip_text (edit_button, _("Edit Account"));
|
714 | |
gtk_widget_show (edit_button);
|
715 | |
|
716 | |
image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_BUTTON);
|
717 | |
close_button = gtk_button_new ();
|
718 | |
gtk_button_set_image (GTK_BUTTON (close_button), image);
|
719 | |
gtk_widget_set_tooltip_text (close_button, _("Close"));
|
720 | |
gtk_widget_show (close_button);
|
721 | |
|
722 | |
action_grid = gtk_grid_new ();
|
723 | |
gtk_grid_set_column_spacing (GTK_GRID (action_grid), 2);
|
724 | |
gtk_widget_show (action_grid);
|
725 | |
|
726 | |
action_area = gtk_info_bar_get_action_area (GTK_INFO_BAR (info_bar));
|
727 | |
gtk_box_pack_start (GTK_BOX (action_area), action_grid, FALSE, FALSE, 0);
|
728 | |
|
729 | |
gtk_grid_attach (GTK_GRID (action_grid), retry_button, 0, 0, 1, 1);
|
730 | |
gtk_grid_attach (GTK_GRID (action_grid), edit_button, 1, 0, 1, 1);
|
731 | |
gtk_grid_attach (GTK_GRID (action_grid), close_button, 2, 0, 1, 1);
|
732 | |
|
733 | |
g_object_set_data (G_OBJECT (info_bar), "label", label);
|
734 | |
g_object_set_data_full (G_OBJECT (info_bar),
|
735 | |
"account", g_object_ref (account),
|
736 | |
g_object_unref);
|
737 | |
g_object_set_data_full (G_OBJECT (edit_button),
|
738 | |
"account", g_object_ref (account),
|
739 | |
g_object_unref);
|
740 | |
g_object_set_data_full (G_OBJECT (close_button),
|
741 | |
"account", g_object_ref (account),
|
742 | |
g_object_unref);
|
743 | |
g_object_set_data_full (G_OBJECT (retry_button),
|
744 | |
"account", g_object_ref (account),
|
745 | |
g_object_unref);
|
746 | |
|
747 | |
g_signal_connect (edit_button, "clicked",
|
748 | |
G_CALLBACK (roster_window_error_edit_clicked_cb), self);
|
749 | |
g_signal_connect (close_button, "clicked",
|
750 | |
G_CALLBACK (roster_window_error_close_clicked_cb), self);
|
751 | |
g_signal_connect (retry_button, "clicked",
|
752 | |
G_CALLBACK (roster_window_error_retry_clicked_cb), self);
|
753 | |
|
754 | |
gtk_widget_set_tooltip_text (self->priv->errors_vbox, error_message);
|
755 | |
gtk_widget_show (self->priv->errors_vbox);
|
756 | |
|
757 | |
g_hash_table_insert (self->priv->errors, g_object_ref (account), info_bar);
|
|
635 |
roster_window_error_add_stock_button (GTK_INFO_BAR (info_bar),
|
|
636 |
GTK_STOCK_REFRESH, _("Update software..."),
|
|
637 |
ERROR_RESPONSE_RETRY);
|
|
638 |
}
|
|
639 |
else
|
|
640 |
{
|
|
641 |
roster_window_error_add_stock_button (GTK_INFO_BAR (info_bar),
|
|
642 |
GTK_STOCK_REFRESH, _("Reconnect"),
|
|
643 |
ERROR_RESPONSE_RETRY);
|
|
644 |
|
|
645 |
roster_window_error_add_stock_button (GTK_INFO_BAR (info_bar),
|
|
646 |
GTK_STOCK_EDIT, _("Edit Account"),
|
|
647 |
ERROR_RESPONSE_EDIT);
|
|
648 |
}
|
|
649 |
|
|
650 |
roster_window_error_add_stock_button (GTK_INFO_BAR (info_bar),
|
|
651 |
GTK_STOCK_CLOSE, _("Close"),
|
|
652 |
ERROR_RESPONSE_CLOSE);
|
758 | 653 |
}
|
759 | 654 |
|
760 | 655 |
static void
|