]> 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 659d91769ead926e15e32bd610ca834dab1411a3..d032eab5a146a0eb21ed22dec9302afe29306e21 100644 (file)
@@ -42,7 +42,7 @@ static GtkWidget *new_contact_dialog = NULL;
 
 
 static gint
-contact_dialogs_find (GtkDialog     *dialog,
+contact_dialogs_find (GtkDialog      *dialog,
                      EmpathyContact *contact)
 {
        GtkWidget     *contact_widget;
@@ -64,18 +64,18 @@ subscription_dialog_response_cb (GtkDialog *dialog,
                                 GtkWidget *contact_widget)
 {
        EmpathyContactManager *manager;
-       EmpathyContact         *contact;
+       EmpathyContact        *contact;
 
        manager = empathy_contact_manager_new ();
        contact = empathy_contact_widget_get_contact (contact_widget);
 
        if (response == GTK_RESPONSE_YES) {
-               empathy_contact_list_process_pending (EMPATHY_CONTACT_LIST (manager),
-                                                     contact, TRUE);
+               empathy_contact_list_add (EMPATHY_CONTACT_LIST (manager),
+                                         contact, "");
        }
        else if (response == GTK_RESPONSE_NO) {
-               empathy_contact_list_process_pending (EMPATHY_CONTACT_LIST (manager),
-                                                     contact, FALSE);
+               empathy_contact_list_remove (EMPATHY_CONTACT_LIST (manager),
+                                            contact, "");
        }
 
        subscription_dialogs = g_list_remove (subscription_dialogs, dialog);
@@ -109,7 +109,9 @@ empathy_subscription_dialog_show (EmpathyContact *contact,
                                      "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,
@@ -144,13 +146,15 @@ contact_information_response_cb (GtkDialog *dialog,
 
 void
 empathy_contact_information_dialog_show (EmpathyContact *contact,
-                                        GtkWindow     *parent,
-                                        gboolean       edit)
+                                        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 (EMPATHY_IS_CONTACT (contact));
 
@@ -166,6 +170,7 @@ empathy_contact_information_dialog_show (EmpathyContact *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);
@@ -174,9 +179,19 @@ empathy_contact_information_dialog_show (EmpathyContact *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);
@@ -237,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);
@@ -254,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);