*/
#include "config.h"
-
#include "empathy-subscription-dialog.h"
-#include <libempathy/empathy-utils.h>
-#include <libempathy-gtk/empathy-individual-widget.h>
-#include <libempathy-gtk/empathy-contact-dialogs.h>
-
#include <glib/gi18n-lib.h>
+#include <telepathy-glib/telepathy-glib-dbus.h>
+
+#include "empathy-individual-widget.h"
+#include "empathy-utils.h"
G_DEFINE_TYPE (EmpathySubscriptionDialog, empathy_subscription_dialog, GTK_TYPE_MESSAGE_DIALOG)
}
}
+/**
+ * block_contact_dialog_show:
+ * @parent: the parent of this dialog (or %NULL)
+ * @contact: the contact for this dialog
+ * @abusive: a pointer to store the value of the abusive contact check box
+ * (or %NULL)
+ *
+ * Returns: %TRUE if the user wishes to block the contact
+ */
+static gboolean
+block_contact_dialog_show (GtkWindow *parent,
+ EmpathyContact *contact,
+ GdkPixbuf *avatar,
+ gboolean *abusive)
+{
+ GtkWidget *dialog;
+ GtkWidget *abusive_check = NULL;
+ int res;
+ TpConnection *conn;
+
+ dialog = gtk_message_dialog_new (parent, GTK_DIALOG_MODAL,
+ GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, _("Block %s?"),
+ empathy_contact_get_alias (contact));
+
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ _("Are you sure you want to block '%s' from contacting you again?"),
+ empathy_contact_get_alias (contact));
+
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ _("_Block"), GTK_RESPONSE_REJECT,
+ NULL);
+
+ if (avatar != NULL)
+ {
+ GtkWidget *image = gtk_image_new_from_pixbuf (avatar);
+ gtk_message_dialog_set_image (GTK_MESSAGE_DIALOG (dialog), image);
+ gtk_widget_show (image);
+ }
+
+ conn = empathy_contact_get_connection (contact);
+
+ /* ask the user if they want to also report the contact as abusive */
+ if (tp_connection_can_report_abusive (conn))
+ {
+ GtkWidget *vbox;
+
+ vbox = gtk_message_dialog_get_message_area (
+ GTK_MESSAGE_DIALOG (dialog));
+ abusive_check = gtk_check_button_new_with_mnemonic (
+ _("_Report this contact as abusive"));
+
+ gtk_box_pack_start (GTK_BOX (vbox), abusive_check,
+ FALSE, TRUE, 0);
+ gtk_widget_show (abusive_check);
+ }
+
+ res = gtk_dialog_run (GTK_DIALOG (dialog));
+ if (abusive != NULL)
+ {
+ if (abusive_check != NULL)
+ *abusive = gtk_toggle_button_get_active (
+ GTK_TOGGLE_BUTTON (abusive_check));
+ else
+ *abusive = FALSE;
+ }
+
+ gtk_widget_destroy (dialog);
+
+ return res == GTK_RESPONSE_REJECT;
+}
+
static void
response_cb (GtkDialog *dialog,
gint reponse,
gboolean abusive;
/* confirm the blocking */
- if (empathy_block_contact_dialog_show (GTK_WINDOW (dialog), contact,
+ if (block_contact_dialog_show (GTK_WINDOW (dialog), contact,
NULL, &abusive))
{
TpContact *tp_contact;
{
tmp = g_strdup_printf ("<i>%s</i>", self->priv->message);
gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (self),
- tmp);
+ "%s", tmp);
g_free (tmp);
}