aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorDanielle Madeley <danielle.madeley@collabora.co.uk>2011-02-10 13:23:58 +0800
committerChandni Verma <chandniverma2112@gmail.com>2011-03-08 12:04:56 +0800
commit0c363023bd77f286bc6257db3f7d90aeb4e7b0f0 (patch)
tree0984c07df7fe99316ceadffe8de31257ae27cca2 /libempathy-gtk
parent1a2bbd7b2824e683c772b4784b98dcd531e91089 (diff)
downloadgsoc2013-empathy-0c363023bd77f286bc6257db3f7d90aeb4e7b0f0.tar
gsoc2013-empathy-0c363023bd77f286bc6257db3f7d90aeb4e7b0f0.tar.gz
gsoc2013-empathy-0c363023bd77f286bc6257db3f7d90aeb4e7b0f0.tar.bz2
gsoc2013-empathy-0c363023bd77f286bc6257db3f7d90aeb4e7b0f0.tar.lz
gsoc2013-empathy-0c363023bd77f286bc6257db3f7d90aeb4e7b0f0.tar.xz
gsoc2013-empathy-0c363023bd77f286bc6257db3f7d90aeb4e7b0f0.tar.zst
gsoc2013-empathy-0c363023bd77f286bc6257db3f7d90aeb4e7b0f0.zip
contact-blocking-dialog: report errors to the user
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-contact-blocking-dialog.c55
1 files changed, 52 insertions, 3 deletions
diff --git a/libempathy-gtk/empathy-contact-blocking-dialog.c b/libempathy-gtk/empathy-contact-blocking-dialog.c
index 81fd4d99b..3d0b9afe9 100644
--- a/libempathy-gtk/empathy-contact-blocking-dialog.c
+++ b/libempathy-gtk/empathy-contact-blocking-dialog.c
@@ -58,6 +58,8 @@ struct _EmpathyContactBlockingDialogPrivate
GtkWidget *account_chooser;
GtkWidget *add_button;
GtkWidget *add_contact_entry;
+ GtkWidget *info_bar;
+ GtkWidget *info_bar_label;
GtkWidget *remove_button;
};
@@ -406,6 +408,31 @@ contact_blocking_dialog_deny_channel_prepared (GObject *channel,
G_CALLBACK (contact_blocking_dialog_deny_channel_members_changed), self);
}
+static void
+contact_blocking_dialog_set_error (EmpathyContactBlockingDialog *self,
+ const GError *error)
+{
+ const char *msg = NULL;
+
+ if (error->domain == TP_ERRORS)
+ {
+ if (error->code == TP_ERROR_INVALID_HANDLE)
+ msg = _("Unknown or invalid identifier");
+ else if (error->code == TP_ERROR_NOT_AVAILABLE)
+ msg = _("Contact blocking temporarily unavailable");
+ else if (error->code == TP_ERROR_NOT_CAPABLE)
+ msg = _("Contact blocking unavailable");
+ else if (error->code == TP_ERROR_PERMISSION_DENIED)
+ msg = _("Permission Denied");
+ }
+
+ if (msg == NULL)
+ msg = _("Could not block contact");
+
+ gtk_label_set_text (GTK_LABEL (self->priv->info_bar_label), msg);
+ gtk_widget_show (self->priv->info_bar);
+}
+
static void contact_blocking_dialog_add_contact_got_handle (TpConnection *,
const GArray *, const GError *, gpointer, GObject *);
@@ -428,6 +455,7 @@ contact_blocking_dialog_add_contact (GtkWidget *widget,
NULL, NULL, G_OBJECT (self));
gtk_entry_set_text (GTK_ENTRY (self->priv->add_contact_entry), "");
+ gtk_widget_hide (self->priv->info_bar);
}
static void
@@ -447,7 +475,10 @@ contact_blocking_dialog_add_contact_got_handle (TpConnection *conn,
if (in_error != NULL)
{
DEBUG ("Error getting handle: %s", in_error->message);
- /* FIXME: expose error to user */
+
+ contact_blocking_dialog_set_error (
+ EMPATHY_CONTACT_BLOCKING_DIALOG (self), in_error);
+
return;
}
@@ -470,7 +501,10 @@ contact_blocking_dialog_added_contact (TpChannel *channel,
if (in_error != NULL)
{
DEBUG ("Error adding contact to deny list: %s", in_error->message);
- /* FIXME: expose error to user */
+
+ contact_blocking_dialog_set_error (
+ EMPATHY_CONTACT_BLOCKING_DIALOG (self), in_error);
+
return;
}
@@ -535,7 +569,10 @@ contact_blocking_dialog_removed_contacts (TpChannel *channel,
if (in_error != NULL)
{
DEBUG ("Error removing contacts from deny list: %s", in_error->message);
- /* FIXME: expose error to user */
+
+ contact_blocking_dialog_set_error (
+ EMPATHY_CONTACT_BLOCKING_DIALOG (self), in_error);
+
return;
}
@@ -716,6 +753,18 @@ empathy_contact_blocking_dialog_init (EmpathyContactBlockingDialog *self)
TRUE, TRUE, 0);
gtk_widget_show (self->priv->account_chooser);
+ /* add an error warning info bar */
+ self->priv->info_bar = gtk_info_bar_new ();
+ gtk_box_pack_start (GTK_BOX (contents), self->priv->info_bar, FALSE, TRUE, 0);
+ gtk_info_bar_set_message_type (GTK_INFO_BAR (self->priv->info_bar),
+ GTK_MESSAGE_ERROR);
+
+ self->priv->info_bar_label = gtk_label_new ("");
+ gtk_container_add (GTK_CONTAINER (
+ gtk_info_bar_get_content_area (GTK_INFO_BAR (self->priv->info_bar))),
+ self->priv->info_bar_label);
+ gtk_widget_show (self->priv->info_bar_label);
+
/* prepare the account manager */
am = tp_account_manager_dup ();
tp_proxy_prepare_async (am, NULL, contact_blocking_dialog_am_prepared, self);