[empathy] Don't call SetAlias for subscription requests until the request has been acked (#608975)



commit 4ee728df4875d0f62e1953851a1eb01627eb9e9e
Author: Danielle Madeley <danielle madeley collabora co uk>
Date:   Fri Feb 5 11:06:13 2010 +1100

    Don't call SetAlias for subscription requests until the request has been acked (#608975)

 libempathy-gtk/empathy-contact-dialogs.c |   11 +++++++++++
 libempathy-gtk/empathy-contact-widget.c  |   23 ++++++++++++++++++++---
 libempathy-gtk/empathy-contact-widget.h  |    2 ++
 3 files changed, 33 insertions(+), 3 deletions(-)
---
diff --git a/libempathy-gtk/empathy-contact-dialogs.c b/libempathy-gtk/empathy-contact-dialogs.c
index 390caa2..52e43e1 100644
--- a/libempathy-gtk/empathy-contact-dialogs.c
+++ b/libempathy-gtk/empathy-contact-dialogs.c
@@ -31,6 +31,7 @@
 
 #include <libempathy/empathy-contact-manager.h>
 #include <libempathy/empathy-contact-list.h>
+#include <libempathy/empathy-tp-contact-factory.h>
 #include <libempathy/empathy-utils.h>
 
 #include "empathy-contact-dialogs.h"
@@ -72,8 +73,17 @@ subscription_dialog_response_cb (GtkDialog *dialog,
 	contact = empathy_contact_widget_get_contact (contact_widget);
 
 	if (response == GTK_RESPONSE_YES) {
+		EmpathyTpContactFactory *factory;
+
+		factory = empathy_tp_contact_factory_dup_singleton (
+			empathy_contact_get_connection (contact));
+
 		empathy_contact_list_add (EMPATHY_CONTACT_LIST (manager),
 					  contact, "");
+		empathy_tp_contact_factory_set_alias (factory, contact,
+			empathy_contact_widget_get_alias (contact_widget));
+
+		g_object_unref (factory);
 	}
 	else if (response == GTK_RESPONSE_NO) {
 		empathy_contact_list_remove (EMPATHY_CONTACT_LIST (manager),
@@ -117,6 +127,7 @@ empathy_subscription_dialog_show (EmpathyContact *contact,
 
 	/* Contact info widget */
 	contact_widget = empathy_contact_widget_new (contact,
+						     EMPATHY_CONTACT_WIDGET_NO_SET_ALIAS |
 						     EMPATHY_CONTACT_WIDGET_EDIT_ALIAS |
 						     EMPATHY_CONTACT_WIDGET_EDIT_GROUPS);
 	gtk_box_pack_end (GTK_BOX (hbox_subscription),
diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c
index 773aa61..3e8ed84 100644
--- a/libempathy-gtk/empathy-contact-widget.c
+++ b/libempathy-gtk/empathy-contact-widget.c
@@ -1271,9 +1271,12 @@ contact_widget_contact_setup (EmpathyContactWidget *information)
   if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ALIAS)
     {
       information->widget_alias = gtk_entry_new ();
-      g_signal_connect (information->widget_alias, "focus-out-event",
-            G_CALLBACK (contact_widget_entry_alias_focus_event_cb),
-            information);
+
+      if (!(information->flags & EMPATHY_CONTACT_WIDGET_NO_SET_ALIAS))
+        g_signal_connect (information->widget_alias, "focus-out-event",
+              G_CALLBACK (contact_widget_entry_alias_focus_event_cb),
+              information);
+
       /* Make return activate the window default (the Close button) */
       gtk_entry_set_activates_default (GTK_ENTRY (information->widget_alias),
           TRUE);
@@ -1414,6 +1417,20 @@ empathy_contact_widget_get_contact (GtkWidget *widget)
   return information->contact;
 }
 
+const gchar *
+empathy_contact_widget_get_alias (GtkWidget *widget)
+{
+  EmpathyContactWidget *information;
+
+  g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+
+  information = g_object_get_data (G_OBJECT (widget), "EmpathyContactWidget");
+  if (!information)
+      return NULL;
+
+  return gtk_entry_get_text (GTK_ENTRY (information->widget_alias));
+}
+
 /**
  * empathy_contact_widget_set_contact:
  * @widget: an #EmpathyContactWidget
diff --git a/libempathy-gtk/empathy-contact-widget.h b/libempathy-gtk/empathy-contact-widget.h
index b010578..04b567f 100644
--- a/libempathy-gtk/empathy-contact-widget.h
+++ b/libempathy-gtk/empathy-contact-widget.h
@@ -60,6 +60,7 @@ typedef enum
   EMPATHY_CONTACT_WIDGET_EDIT_GROUPS  = 1 << 4,
   EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP  = 1 << 5,
   EMPATHY_CONTACT_WIDGET_SHOW_LOCATION  = 1 << 6,
+  EMPATHY_CONTACT_WIDGET_NO_SET_ALIAS = 1 << 7,
 } EmpathyContactWidgetFlags;
 
 GtkWidget * empathy_contact_widget_new (EmpathyContact *contact,
@@ -69,6 +70,7 @@ void empathy_contact_widget_set_contact (GtkWidget *widget,
     EmpathyContact *contact);
 void empathy_contact_widget_set_account_filter (GtkWidget *widget,
     EmpathyAccountChooserFilterFunc filter, gpointer user_data);
+const gchar *empathy_contact_widget_get_alias (GtkWidget *widget);
 
 G_END_DECLS
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]