]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-contact-dialogs.c
More flexible API for EmpathyContactWidget, we now have flags to set
[empathy.git] / libempathy-gtk / empathy-contact-dialogs.c
index 051876940f5fa8ca930717ba4a132e3435222a46..d032eab5a146a0eb21ed22dec9302afe29306e21 100644 (file)
@@ -34,7 +34,7 @@
 
 #include "empathy-contact-dialogs.h"
 #include "empathy-contact-widget.h"
-#include "gossip-ui-utils.h"
+#include "empathy-ui-utils.h"
 
 static GList *subscription_dialogs = NULL;
 static GList *information_dialogs = NULL;
@@ -42,16 +42,16 @@ static GtkWidget *new_contact_dialog = NULL;
 
 
 static gint
-contact_dialogs_find (GtkDialog     *dialog,
-                     GossipContact *contact)
+contact_dialogs_find (GtkDialog      *dialog,
+                     EmpathyContact *contact)
 {
        GtkWidget     *contact_widget;
-       GossipContact *this_contact;
+       EmpathyContact *this_contact;
 
        contact_widget = g_object_get_data (G_OBJECT (dialog), "contact_widget");
        this_contact = empathy_contact_widget_get_contact (contact_widget);
 
-       return !gossip_contact_equal (contact, this_contact);
+       return !empathy_contact_equal (contact, this_contact);
 }
 
 /*
@@ -64,20 +64,18 @@ subscription_dialog_response_cb (GtkDialog *dialog,
                                 GtkWidget *contact_widget)
 {
        EmpathyContactManager *manager;
-       GossipContact         *contact;
+       EmpathyContact        *contact;
 
        manager = empathy_contact_manager_new ();
        contact = empathy_contact_widget_get_contact (contact_widget);
 
        if (response == GTK_RESPONSE_YES) {
                empathy_contact_list_add (EMPATHY_CONTACT_LIST (manager),
-                                         contact,
-                                         _("I would like to add you to my contact list."));
+                                         contact, "");
        }
        else if (response == GTK_RESPONSE_NO) {
                empathy_contact_list_remove (EMPATHY_CONTACT_LIST (manager),
-                                            contact,
-                                            _("Sorry, I don't want you in my contact list."));
+                                            contact, "");
        }
 
        subscription_dialogs = g_list_remove (subscription_dialogs, dialog);
@@ -86,7 +84,7 @@ subscription_dialog_response_cb (GtkDialog *dialog,
 }
 
 void
-empathy_subscription_dialog_show (GossipContact *contact,
+empathy_subscription_dialog_show (EmpathyContact *contact,
                                  GtkWindow     *parent)
 {
        GtkWidget *dialog;
@@ -94,7 +92,7 @@ empathy_subscription_dialog_show (GossipContact *contact,
        GtkWidget *contact_widget;
        GList     *l;
 
-       g_return_if_fail (GOSSIP_IS_CONTACT (contact));
+       g_return_if_fail (EMPATHY_IS_CONTACT (contact));
 
        l = g_list_find_custom (subscription_dialogs,
                                contact,
@@ -104,14 +102,16 @@ empathy_subscription_dialog_show (GossipContact *contact,
                return;
        }
 
-       gossip_glade_get_file_simple ("empathy-contact-dialogs.glade",
+       empathy_glade_get_file_simple ("empathy-contact-dialogs.glade",
                                      "subscription_request_dialog",
                                      NULL,
                                      "subscription_request_dialog", &dialog,
                                      "hbox_subscription", &hbox_subscription,
                                      NULL);
 
-       contact_widget = empathy_contact_widget_new (contact, TRUE);
+       contact_widget = empathy_contact_widget_new (contact,
+                                                    EMPATHY_CONTACT_WIDGET_EDIT_ALIAS |
+                                                    EMPATHY_CONTACT_WIDGET_EDIT_GROUPS);
        gtk_box_pack_end (GTK_BOX (hbox_subscription),
                          contact_widget,
                          TRUE, TRUE,
@@ -145,16 +145,18 @@ contact_information_response_cb (GtkDialog *dialog,
 }
 
 void
-empathy_contact_information_dialog_show (GossipContact *contact,
-                                        GtkWindow     *parent,
-                                        gboolean       edit)
+empathy_contact_information_dialog_show (EmpathyContact *contact,
+                                        GtkWindow      *parent,
+                                        gboolean        edit,
+                                        gboolean        edit_groups)
 {
-       GtkWidget *dialog;
-       GtkWidget *button;
-       GtkWidget *contact_widget;
-       GList     *l;
+       GtkWidget                *dialog;
+       GtkWidget                *button;
+       GtkWidget                *contact_widget;
+       GList                    *l;
+       EmpathyContactWidgetFlags flags = 0;
 
-       g_return_if_fail (GOSSIP_IS_CONTACT (contact));
+       g_return_if_fail (EMPATHY_IS_CONTACT (contact));
 
        l = g_list_find_custom (information_dialogs,
                                contact,
@@ -168,6 +170,7 @@ empathy_contact_information_dialog_show (GossipContact *contact,
        dialog = gtk_dialog_new ();
        gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
        gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+       gtk_window_set_title (GTK_WINDOW (dialog), _("Contact information"));
 
        /* Close button */
        button = gtk_button_new_with_label (GTK_STOCK_CLOSE);
@@ -176,9 +179,19 @@ empathy_contact_information_dialog_show (GossipContact *contact,
                                      button,
                                      GTK_RESPONSE_CLOSE);
        gtk_widget_show (button);
-       
-       /* Contact infor widget */
-       contact_widget = empathy_contact_widget_new (contact, edit);
+
+       /* Contact info widget */
+       if (edit) {
+               flags |= EMPATHY_CONTACT_WIDGET_EDIT_ALIAS;
+               if (empathy_contact_is_user (contact)) {
+                       flags |= EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT |
+                                EMPATHY_CONTACT_WIDGET_EDIT_AVATAR;
+               }
+       }
+       if (edit_groups) {
+               flags |= EMPATHY_CONTACT_WIDGET_EDIT_GROUPS;
+       }
+       contact_widget = empathy_contact_widget_new (contact, flags);
        gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
                            contact_widget,
                            TRUE, TRUE, 0);
@@ -207,7 +220,7 @@ new_contact_response_cb (GtkDialog *dialog,
                         GtkWidget *contact_widget)
 {
        EmpathyContactManager *manager;
-       GossipContact         *contact;
+       EmpathyContact         *contact;
 
        manager = empathy_contact_manager_new ();
        contact = empathy_contact_widget_get_contact (contact_widget);
@@ -239,6 +252,7 @@ empathy_new_contact_dialog_show (GtkWindow *parent)
        dialog = gtk_dialog_new ();
        gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
        gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+       gtk_window_set_title (GTK_WINDOW (dialog), _("New contact"));
 
        /* Cancel button */
        button = gtk_button_new_with_label (GTK_STOCK_CANCEL);
@@ -256,8 +270,12 @@ empathy_new_contact_dialog_show (GtkWindow *parent)
                                      GTK_RESPONSE_OK);
        gtk_widget_show (button);
 
-       /* Contact infor widget */
-       contact_widget = empathy_contact_widget_new (NULL, TRUE);
+       /* Contact info widget */
+       contact_widget = empathy_contact_widget_new (NULL,
+                                                    EMPATHY_CONTACT_WIDGET_EDIT_ALIAS |
+                                                    EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT |
+                                                    EMPATHY_CONTACT_WIDGET_EDIT_ID |
+                                                    EMPATHY_CONTACT_WIDGET_EDIT_GROUPS);
        gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
                            contact_widget,
                            TRUE, TRUE, 0);