aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2011-08-22 16:01:59 +0800
committerJonny Lamb <jonny.lamb@collabora.co.uk>2011-08-22 16:01:59 +0800
commit64cc7e6fe9b37afbc55fe0c5166132e32ac3f994 (patch)
tree96dea666351591d0278a2eb2142fda7e42a6c9bf
parent18f318c2dc698f416fc9a05587908fa5eb3f96d1 (diff)
parent569c3381242efcb5bc7966825023e890965c0b62 (diff)
downloadgsoc2013-empathy-64cc7e6fe9b37afbc55fe0c5166132e32ac3f994.tar
gsoc2013-empathy-64cc7e6fe9b37afbc55fe0c5166132e32ac3f994.tar.gz
gsoc2013-empathy-64cc7e6fe9b37afbc55fe0c5166132e32ac3f994.tar.bz2
gsoc2013-empathy-64cc7e6fe9b37afbc55fe0c5166132e32ac3f994.tar.lz
gsoc2013-empathy-64cc7e6fe9b37afbc55fe0c5166132e32ac3f994.tar.xz
gsoc2013-empathy-64cc7e6fe9b37afbc55fe0c5166132e32ac3f994.tar.zst
gsoc2013-empathy-64cc7e6fe9b37afbc55fe0c5166132e32ac3f994.zip
Merge remote-tracking branch 'pochu/request-message'
-rw-r--r--libempathy-gtk/empathy-contact-search-dialog.c61
-rw-r--r--libempathy/empathy-contact-list.h1
-rw-r--r--libempathy/empathy-tp-contact-list.c4
3 files changed, 63 insertions, 3 deletions
diff --git a/libempathy-gtk/empathy-contact-search-dialog.c b/libempathy-gtk/empathy-contact-search-dialog.c
index 8b2f7f3b5..bfc42bbb0 100644
--- a/libempathy-gtk/empathy-contact-search-dialog.c
+++ b/libempathy-gtk/empathy-contact-search-dialog.c
@@ -73,6 +73,9 @@ struct _EmpathyContactSearchDialogPrivate
GtkWidget *no_contact_found;
GtkWidget *search_entry;
/* GtkWidget *server_entry; */
+ GtkWidget *message;
+ GtkWidget *message_window;
+ GtkWidget *message_label;
};
static void
@@ -140,6 +143,7 @@ on_get_contact_factory_get_from_id_cb (TpConnection *connection,
GObject *object)
{
EmpathyContactManager *manager = empathy_contact_manager_dup_singleton ();
+ const gchar *message = user_data;
if (error != NULL)
{
@@ -147,7 +151,8 @@ on_get_contact_factory_get_from_id_cb (TpConnection *connection,
return;
}
- empathy_contact_list_add (EMPATHY_CONTACT_LIST (manager), contact, "");
+ empathy_contact_list_add (EMPATHY_CONTACT_LIST (manager), contact,
+ message);
}
static void
@@ -158,6 +163,9 @@ add_selected_contact (EmpathyContactSearchDialog *self)
TpConnection *conn;
GtkTreeIter iter;
GtkTreeModel *model;
+ GtkTextBuffer *buffer;
+ GtkTextIter start, end;
+ gchar *message;
gboolean sel;
gchar *id;
@@ -170,9 +178,14 @@ add_selected_contact (EmpathyContactSearchDialog *self)
DEBUG ("Requested to add contact: %s", id);
+ buffer = gtk_text_view_get_buffer GTK_TEXT_VIEW (priv->message);
+ gtk_text_buffer_get_start_iter (buffer, &start);
+ gtk_text_buffer_get_end_iter (buffer, &end);
+ message = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
+
empathy_tp_contact_factory_get_from_id (conn, id,
- on_get_contact_factory_get_from_id_cb, NULL,
- NULL, NULL);
+ on_get_contact_factory_get_from_id_cb,
+ message, g_free, NULL);
/* Close the dialog */
gtk_dialog_response (GTK_DIALOG (self), GTK_RESPONSE_CANCEL);
@@ -324,6 +337,21 @@ on_selection_changed (GtkTreeSelection *selection,
gtk_widget_set_sensitive (priv->add_button, sel);
}
+static void
+check_request_message_available (EmpathyContactSearchDialog *self,
+ TpConnection *conn)
+{
+ EmpathyContactSearchDialogPrivate *priv = GET_PRIVATE (self);
+ EmpathyContactManager *manager = empathy_contact_manager_dup_singleton ();
+ EmpathyContactListFlags flags;
+
+ flags = empathy_contact_manager_get_flags_for_connection (manager, conn);
+
+ gtk_widget_set_visible (priv->message_window,
+ flags & EMPATHY_CONTACT_LIST_MESSAGE_ADD);
+ gtk_widget_set_visible (priv->message_label,
+ flags & EMPATHY_CONTACT_LIST_MESSAGE_ADD);
+}
static void
_account_chooser_changed (EmpathyAccountChooser *chooser,
@@ -352,6 +380,9 @@ _account_chooser_changed (EmpathyAccountChooser *chooser,
NULL, /* gtk_entry_get_text (GTK_ENTRY (priv->server_entry)), */
0,
on_searcher_created, self);
+
+ /* Make the request message textview sensitive if it can be used */
+ check_request_message_available (self, conn);
}
static void
@@ -591,6 +622,30 @@ empathy_contact_search_dialog_init (EmpathyContactSearchDialog *self)
gtk_box_pack_start (GTK_BOX (vbox), priv->notebook, TRUE, TRUE, 3);
+ /* Request message textview */
+ priv->message_label = gtk_label_new (
+ _("Your message introducing yourself:"));
+ gtk_misc_set_alignment (GTK_MISC (priv->message_label), 0, 0.5);
+
+ priv->message = gtk_text_view_new ();
+ gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (priv->message),
+ GTK_WRAP_WORD_CHAR);
+ gtk_text_buffer_set_text (
+ gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->message)),
+ _("Please let me see when you're online. Thanks!"), -1);
+
+ priv->message_window = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_shadow_type (
+ GTK_SCROLLED_WINDOW (priv->message_window),
+ GTK_SHADOW_ETCHED_IN);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->message_window),
+ GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+
+ gtk_container_add (GTK_CONTAINER (priv->message_window), priv->message);
+
+ gtk_box_pack_start (GTK_BOX (vbox), priv->message_label, FALSE, TRUE, 3);
+ gtk_box_pack_start (GTK_BOX (vbox), priv->message_window, FALSE, TRUE, 3);
+
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (
GTK_DIALOG (self))), vbox, TRUE, TRUE, 0);
diff --git a/libempathy/empathy-contact-list.h b/libempathy/empathy-contact-list.h
index cf523bf2a..b36817a93 100644
--- a/libempathy/empathy-contact-list.h
+++ b/libempathy/empathy-contact-list.h
@@ -41,6 +41,7 @@ typedef enum {
EMPATHY_CONTACT_LIST_CAN_GROUP = 1 << 3,
EMPATHY_CONTACT_LIST_CAN_BLOCK = 1 << 4,
EMPATHY_CONTACT_LIST_CAN_REPORT_ABUSIVE = 1 << 5,
+ EMPATHY_CONTACT_LIST_MESSAGE_ADD = 1 << 6,
} EmpathyContactListFlags;
typedef struct _EmpathyContactListIface EmpathyContactListIface;
diff --git a/libempathy/empathy-tp-contact-list.c b/libempathy/empathy-tp-contact-list.c
index 11990a9a2..d9fb18182 100644
--- a/libempathy/empathy-tp-contact-list.c
+++ b/libempathy/empathy-tp-contact-list.c
@@ -1358,6 +1358,10 @@ tp_contact_list_get_flags (EmpathyContactList *list)
if (group_flags & TP_CHANNEL_GROUP_FLAG_CAN_REMOVE) {
flags |= EMPATHY_CONTACT_LIST_CAN_REMOVE;
}
+
+ if (group_flags & TP_CHANNEL_GROUP_FLAG_MESSAGE_ADD) {
+ flags |= EMPATHY_CONTACT_LIST_MESSAGE_ADD;
+ }
}
if (priv->deny != NULL)