]> git.0d.be Git - empathy.git/commitdiff
Do not show salut accounts in the add contact dialog. Rework a bit
authorXavier Claessens <xclaesse@gmail.com>
Thu, 26 Jul 2007 14:27:45 +0000 (14:27 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Thu, 26 Jul 2007 14:27:45 +0000 (14:27 +0000)
2007-07-26 Xavier Claessens  <xclaesse@gmail.com>

* libempathy-gtk/empathy-account-chooser.c:
* libempathy-gtk/empathy-new-chatroom-dialog.c:
* libempathy-gtk/empathy-account-chooser.h:
* libempathy-gtk/empathy-contact-dialogs.c:
* libempathy-gtk/empathy-chatrooms-window.c:
* libempathy-gtk/empathy-contact-widget.c:
* libempathy-gtk/empathy-contact-widget.h:
* libempathy-gtk/empathy-log-window.c:
* doc/*: Do not show salut accounts in the add contact dialog. Rework
a bit EmpathyContactWidget. Fixes bug #459100
(Guillaume Desmottes, Xavier Claessens).

svn path=/trunk/; revision=197

ChangeLog
doc/libempathy-gtk/tmpl/empathy-account-chooser.sgml
doc/libempathy-gtk/tmpl/empathy-contact-widget.sgml
libempathy-gtk/empathy-account-chooser.c
libempathy-gtk/empathy-account-chooser.h
libempathy-gtk/empathy-chatrooms-window.c
libempathy-gtk/empathy-contact-dialogs.c
libempathy-gtk/empathy-contact-widget.c
libempathy-gtk/empathy-contact-widget.h
libempathy-gtk/empathy-log-window.c
libempathy-gtk/empathy-new-chatroom-dialog.c

index aaf1f61e4e904b85b05cd56e6ff2c11bd8642f48..5d9c8e77494f0f015cb3c6bbce36fb36bcfa5a66 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2007-07-26 Xavier Claessens  <xclaesse@gmail.com>
+
+       * libempathy-gtk/empathy-account-chooser.c:
+       * libempathy-gtk/empathy-new-chatroom-dialog.c:
+       * libempathy-gtk/empathy-account-chooser.h:
+       * libempathy-gtk/empathy-contact-dialogs.c:
+       * libempathy-gtk/empathy-chatrooms-window.c:
+       * libempathy-gtk/empathy-contact-widget.c:
+       * libempathy-gtk/empathy-contact-widget.h:
+       * libempathy-gtk/empathy-log-window.c:
+       * doc/*: Do not show salut accounts in the add contact dialog. Rework
+       a bit EmpathyContactWidget. Fixes bug #459100
+       (Guillaume Desmottes, Xavier Claessens).
+
 2007-07-26 Xavier Claessens  <xclaesse@gmail.com>
 
        * libempathy-gtk/empathy-accounts-dialog.c: add contact frame is not
index 73f07db43d6dfa64b657fd43e7ca0f2fc906e213..9db0bf2a1a4f3b55901671c27203ce8b5b8da151 100644 (file)
@@ -51,24 +51,6 @@ EmpathyAccountChooser
 @Returns: 
 
 
-<!-- ##### FUNCTION empathy_account_chooser_get_can_select_all ##### -->
-<para>
-
-</para>
-
-@chooser: 
-@Returns: 
-
-
-<!-- ##### FUNCTION empathy_account_chooser_set_can_select_all ##### -->
-<para>
-
-</para>
-
-@chooser: 
-@can_select_all: 
-
-
 <!-- ##### FUNCTION empathy_account_chooser_get_has_all_option ##### -->
 <para>
 
index bdba0d8f5b96b7b563e630d57400bd59130bd3c0..a715f098c17c9cb35ba997d1d9d283d219c1c2d8 100644 (file)
@@ -23,7 +23,7 @@ empathy-contact-widget
 </para>
 
 @contact: 
-@editable: 
+@type: 
 @Returns: 
 
 
index eb46c52f7fc7aca56293382defc0324ad328df2b..6d3aea6a61934762a4025e30c3cb7bd91d8ef24b 100644 (file)
 #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_TYPE_ACCOUNT_CHOOSER, EmpathyAccountChooserPriv))
 
 typedef struct {
-       MissionControl   *mc;
-       McAccountMonitor *monitor;
-
-       gboolean          set_active_item;
-       gboolean          can_select_all;
-       gboolean          has_all_option;
+       MissionControl                 *mc;
+       McAccountMonitor               *monitor;
+       gboolean                        set_active_item;
+       gboolean                        has_all_option;
+       EmpathyAccountChooserFilterFunc filter;
+       gpointer                        filter_data;
 } EmpathyAccountChooserPriv;
 
 typedef struct {
        EmpathyAccountChooser *chooser;
-       McAccount            *account;
-       gboolean              set;
+       McAccount             *account;
+       gboolean               set;
 } SetAccountData;
 
 enum {
@@ -98,14 +98,9 @@ static gboolean account_chooser_set_account_foreach    (GtkTreeModel
                                                        GtkTreePath                     *path,
                                                        GtkTreeIter                     *iter,
                                                        SetAccountData                  *data);
-static gboolean account_chooser_set_enabled_foreach    (GtkTreeModel                    *model,
-                                                       GtkTreePath                     *path,
-                                                       GtkTreeIter                     *iter,
-                                                       EmpathyAccountChooser            *chooser);
 
 enum {
        PROP_0,
-       PROP_CAN_SELECT_ALL,
        PROP_HAS_ALL_OPTION,
 };
 
@@ -120,14 +115,6 @@ empathy_account_chooser_class_init (EmpathyAccountChooserClass *klass)
        object_class->get_property = account_chooser_get_property;
        object_class->set_property = account_chooser_set_property;
 
-       g_object_class_install_property (object_class,
-                                        PROP_CAN_SELECT_ALL,
-                                        g_param_spec_boolean ("can-select-all",
-                                                              "Can Select All",
-                                                              "Should the user be able to select offline accounts",
-                                                              FALSE,
-                                                              G_PARAM_READWRITE));
-
        g_object_class_install_property (object_class,
                                         PROP_HAS_ALL_OPTION,
                                         g_param_spec_boolean ("has-all-option",
@@ -142,6 +129,11 @@ empathy_account_chooser_class_init (EmpathyAccountChooserClass *klass)
 static void
 empathy_account_chooser_init (EmpathyAccountChooser *chooser)
 {
+       EmpathyAccountChooserPriv *priv = GET_PRIV (chooser);
+
+       priv->set_active_item = FALSE;
+       priv->filter = NULL;
+       priv->filter_data = NULL;
 }
 
 static void
@@ -180,9 +172,6 @@ account_chooser_get_property (GObject    *object,
        priv = GET_PRIV (object);
 
        switch (param_id) {
-       case PROP_CAN_SELECT_ALL:
-               g_value_set_boolean (value, priv->can_select_all);
-               break;
        case PROP_HAS_ALL_OPTION:
                g_value_set_boolean (value, priv->has_all_option);
                break;
@@ -203,10 +192,6 @@ account_chooser_set_property (GObject      *object,
        priv = GET_PRIV (object);
 
        switch (param_id) {
-       case PROP_CAN_SELECT_ALL:
-               empathy_account_chooser_set_can_select_all (EMPATHY_ACCOUNT_CHOOSER (object),
-                                                          g_value_get_boolean (value));
-               break;
        case PROP_HAS_ALL_OPTION:
                empathy_account_chooser_set_has_all_option (EMPATHY_ACCOUNT_CHOOSER (object),
                                                           g_value_get_boolean (value));
@@ -292,46 +277,6 @@ empathy_account_chooser_set_account (EmpathyAccountChooser *chooser,
        return data.set;
 }
 
-gboolean
-empathy_account_chooser_get_can_select_all (EmpathyAccountChooser *chooser)
-{
-       EmpathyAccountChooserPriv *priv;
-
-       g_return_val_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (chooser), FALSE);
-
-       priv = GET_PRIV (chooser);
-       
-       return priv->can_select_all;
-}
-
-void
-empathy_account_chooser_set_can_select_all (EmpathyAccountChooser *chooser,
-                                          gboolean              can_select_all)
-{
-       EmpathyAccountChooserPriv *priv;
-       GtkComboBox              *combobox;
-       GtkTreeModel             *model;
-
-       g_return_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (chooser));
-
-       priv = GET_PRIV (chooser);
-
-       if (priv->can_select_all == can_select_all) {
-               return;
-       }
-
-       combobox = GTK_COMBO_BOX (chooser);
-       model = gtk_combo_box_get_model (combobox);
-
-       priv->can_select_all = can_select_all;
-
-       gtk_tree_model_foreach (model,
-                               (GtkTreeModelForeachFunc) account_chooser_set_enabled_foreach,
-                               chooser);
-
-       g_object_notify (G_OBJECT (chooser), "can-select-all");
-}
-
 gboolean
 empathy_account_chooser_get_has_all_option (EmpathyAccountChooser *chooser)
 {
@@ -509,15 +454,14 @@ account_chooser_account_remove_foreach (McAccount            *account,
 
 static void
 account_chooser_update_iter (EmpathyAccountChooser *chooser,
-                            GtkTreeIter          *iter,
-                            McAccount            *account)
+                            GtkTreeIter           *iter,
+                            McAccount             *account)
 {
        EmpathyAccountChooserPriv *priv;
-       GtkListStore             *store;
-       GtkComboBox              *combobox;
-       TpConn                   *tp_conn;
-       const gchar              *icon_name;
-       gboolean                  is_enabled;
+       GtkListStore              *store;
+       GtkComboBox               *combobox;
+       const gchar               *icon_name;
+       gboolean                   is_enabled = TRUE;
 
        priv = GET_PRIV (chooser);
 
@@ -525,11 +469,8 @@ account_chooser_update_iter (EmpathyAccountChooser *chooser,
        store = GTK_LIST_STORE (gtk_combo_box_get_model (combobox));
 
        icon_name = empathy_icon_name_from_account (account);
-       tp_conn = mission_control_get_connection (priv->mc, account, NULL);
-       is_enabled = (tp_conn != NULL || priv->can_select_all);
-
-       if (tp_conn) {
-               g_object_unref (tp_conn);
+       if (priv->filter) {
+               is_enabled = priv->filter (account, priv->filter_data);
        }
 
        gtk_list_store_set (store, iter,
@@ -614,24 +555,76 @@ account_chooser_set_account_foreach (GtkTreeModel   *model,
 }
 
 static gboolean
-account_chooser_set_enabled_foreach (GtkTreeModel         *model,
-                                    GtkTreePath          *path,
-                                    GtkTreeIter          *iter,
-                                    EmpathyAccountChooser *chooser)
+account_chooser_filter_foreach (GtkTreeModel          *model,
+                               GtkTreePath           *path,
+                               GtkTreeIter           *iter,
+                               gpointer               chooser)
 {
        EmpathyAccountChooserPriv *priv;
-       McAccount                *account;
+       McAccount                 *account;
+       gboolean                   is_enabled = TRUE;
 
        priv = GET_PRIV (chooser);
 
        gtk_tree_model_get (model, iter, COL_ACCOUNT_POINTER, &account, -1);
-       if (!account) {
-               return FALSE;
+
+       if (priv->filter) {
+               is_enabled = priv->filter (account, priv->filter_data);
+       }
+
+       gtk_list_store_set (GTK_LIST_STORE (model), iter,
+                           COL_ACCOUNT_ENABLED, is_enabled,
+                           -1);
+
+       /* set first connected account as active account */
+       if (!priv->set_active_item && is_enabled) {
+               priv->set_active_item = TRUE;
+               gtk_combo_box_set_active_iter (GTK_COMBO_BOX (chooser), iter);
        }
 
-       account_chooser_update_iter (chooser, iter, account);
        g_object_unref (account);
 
        return FALSE;
 }
 
+void
+empathy_account_chooser_set_filter (EmpathyAccountChooser           *chooser,
+                                    EmpathyAccountChooserFilterFunc  filter,
+                                    gpointer                         user_data)
+{
+       EmpathyAccountChooserPriv *priv;
+       GtkTreeModel *model;
+
+       g_return_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (chooser));
+
+       priv = GET_PRIV (chooser);
+
+       priv->filter = filter;
+       priv->filter_data = user_data;
+
+       /* Refilter existing data */
+       priv->set_active_item = FALSE;
+       model = gtk_combo_box_get_model (GTK_COMBO_BOX (chooser));
+       gtk_tree_model_foreach (model, account_chooser_filter_foreach, chooser);
+}
+
+gboolean
+empathy_account_chooser_filter_is_connected (McAccount *account,
+                                            gpointer   user_data)
+{
+       MissionControl *mc;
+       TpConn         *tp_conn;
+
+       g_return_val_if_fail (MC_IS_ACCOUNT (account), FALSE);
+
+       mc = empathy_mission_control_new ();
+       tp_conn = mission_control_get_connection (mc, account, NULL);
+       g_object_unref (mc);
+
+       if (tp_conn == NULL) {
+               return FALSE;
+       }
+
+       g_object_unref (tp_conn);
+       return TRUE;
+}
index 8d9cb657c0b5410bf35d2283930c4d2c645f48a8..1461603808d6bb092cc7605097a75c49046374d9 100644 (file)
@@ -36,6 +36,10 @@ G_BEGIN_DECLS
 #define EMPATHY_IS_ACCOUNT_CHOOSER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_ACCOUNT_CHOOSER))
 #define EMPATHY_ACCOUNT_CHOOSER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_ACCOUNT_CHOOSER, EmpathyAccountChooserClass))
 
+typedef gboolean (* EmpathyAccountChooserFilterFunc) (McAccount *account,
+                                                     gpointer   user_data);
+
+
 typedef struct _EmpathyAccountChooser      EmpathyAccountChooser;
 typedef struct _EmpathyAccountChooserClass EmpathyAccountChooserClass;
 
@@ -51,14 +55,15 @@ GType          empathy_account_chooser_get_type           (void) G_GNUC_CONST;
 GtkWidget *    empathy_account_chooser_new                (void);
 McAccount *    empathy_account_chooser_get_account        (EmpathyAccountChooser *chooser);
 gboolean       empathy_account_chooser_set_account        (EmpathyAccountChooser *chooser,
-                                                         McAccount            *account);
-gboolean       empathy_account_chooser_get_can_select_all (EmpathyAccountChooser *chooser);
-
-void           empathy_account_chooser_set_can_select_all (EmpathyAccountChooser *chooser,
-                                                         gboolean              can_select_all);
+                                                          McAccount            *account);
 gboolean       empathy_account_chooser_get_has_all_option (EmpathyAccountChooser *chooser);
 void           empathy_account_chooser_set_has_all_option (EmpathyAccountChooser *chooser,
-                                                         gboolean              has_all_option);
+                                                          gboolean               has_all_option);
+void           empathy_account_chooser_set_filter         (EmpathyAccountChooser *chooser,
+                                                          EmpathyAccountChooserFilterFunc filter,
+                                                          gpointer               user_data);
+gboolean       empathy_account_chooser_filter_is_connected(McAccount             *account,
+                                                          gpointer               user_data);
 
 G_END_DECLS
 
index 390fff42e675522dbc698c3c370fe872e2fef247..9a0d125ed622f5d51d78ad12f45988415de34721 100644 (file)
@@ -151,9 +151,11 @@ empathy_chatrooms_window_show (GtkWindow *parent)
 
        /* Account chooser for chat rooms */
        window->account_chooser = empathy_account_chooser_new ();
+       empathy_account_chooser_set_filter (EMPATHY_ACCOUNT_CHOOSER (window->account_chooser),
+                                           empathy_account_chooser_filter_is_connected,
+                                           NULL);
        empathy_account_chooser_set_account (EMPATHY_ACCOUNT_CHOOSER (window->account_chooser), NULL);
        g_object_set (window->account_chooser, 
-                     "can-select-all", TRUE,
                      "has-all-option", TRUE,
                      NULL);
 
index b0d24decc8ec23fb2ce1d3491c4cc16df4aba3db..437e255fa80d0d01c236579216692082f6b0faae 100644 (file)
@@ -109,7 +109,8 @@ 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,
+                                                    CONTACT_WIDGET_TYPE_SUBSCRIPTION);
        gtk_box_pack_end (GTK_BOX (hbox_subscription),
                          contact_widget,
                          TRUE, TRUE,
@@ -144,13 +145,14 @@ contact_information_response_cb (GtkDialog *dialog,
 
 void
 empathy_contact_information_dialog_show (EmpathyContact *contact,
-                                        GtkWindow     *parent,
-                                        gboolean       edit)
+                                        GtkWindow      *parent,
+                                        gboolean        edit)
 {
-       GtkWidget *dialog;
-       GtkWidget *button;
-       GtkWidget *contact_widget;
-       GList     *l;
+       GtkWidget                *dialog;
+       GtkWidget                *button;
+       GtkWidget                *contact_widget;
+       GList                    *l;
+       EmpathyContactWidgetType  type;
 
        g_return_if_fail (EMPATHY_IS_CONTACT (contact));
 
@@ -162,6 +164,8 @@ empathy_contact_information_dialog_show (EmpathyContact *contact,
                return;
        }
 
+       type = edit ? CONTACT_WIDGET_TYPE_EDIT : CONTACT_WIDGET_TYPE_SHOW;
+
        /* Create dialog */
        dialog = gtk_dialog_new ();
        gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
@@ -176,8 +180,8 @@ empathy_contact_information_dialog_show (EmpathyContact *contact,
                                      GTK_RESPONSE_CLOSE);
        gtk_widget_show (button);
        
-       /* Contact infor widget */
-       contact_widget = empathy_contact_widget_new (contact, edit);
+       /* Contact info widget */
+       contact_widget = empathy_contact_widget_new (contact, type);
        gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
                            contact_widget,
                            TRUE, TRUE, 0);
@@ -256,8 +260,8 @@ 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, CONTACT_WIDGET_TYPE_ADD);
        gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
                            contact_widget,
                            TRUE, TRUE, 0);
index 617a7d62d5b928095d829641c9d310462137afd2..df780b84cb819e536f6b1c65feceb926ac36d956 100644 (file)
 #include <libmissioncontrol/mc-account.h>
 
 #include <libempathy/empathy-contact-manager.h>
+#include <libempathy/empathy-utils.h>
 
 #include "empathy-contact-widget.h"
 #include "empathy-account-chooser.h"
 #include "empathy-ui-utils.h"
 
+/* Delay before updating the widget when the id entry changed (ms) */
+#define ID_CHANGED_TIMEOUT 500
+
 typedef struct {
-       EmpathyContact   *contact;
+       EmpathyContact  *contact;
        gboolean         is_user;
-       gboolean         editable;
-       gboolean         can_change_contact;
+       EmpathyContactWidgetType type;
        GtkCellRenderer *renderer;
+       guint            widget_id_timeout;
 
        GtkWidget       *vbox_contact_widget;
 
@@ -139,20 +143,18 @@ enum {
 };
 
 GtkWidget *
-empathy_contact_widget_new (EmpathyContact *contact,
-                           gboolean       editable)
+empathy_contact_widget_new (EmpathyContact           *contact,
+                           EmpathyContactWidgetType  type)
 {
        EmpathyContactWidget *information;
        GladeXML             *glade;
 
        information = g_slice_new0 (EmpathyContactWidget);
-       information->editable = editable;
+       information->type = type;
        if (contact) {
                information->is_user = empathy_contact_is_user (contact);
-               information->can_change_contact = FALSE;
        } else {
                information->is_user = FALSE;
-               information->can_change_contact = TRUE;
        }
 
        glade = empathy_glade_get_file ("empathy-contact-widget.glade",
@@ -225,6 +227,11 @@ contact_widget_destroy_cb (GtkWidget            *widget,
                           EmpathyContactWidget *information)
 {
        contact_widget_remove_contact (information);
+
+       if (information->widget_id_timeout != 0) {
+               g_source_remove (information->widget_id_timeout);
+       }
+
        g_slice_free (EmpathyContactWidget, information);
 }
 
@@ -266,6 +273,60 @@ contact_widget_set_contact (EmpathyContactWidget *information,
        contact_widget_client_update (information);
 }
 
+static gboolean
+contact_widget_can_add_contact_to_account (McAccount *account,
+                                          gpointer   user_data)
+{
+       MissionControl *mc;
+       TpConn         *tp_conn;
+       McProfile      *profile;
+       const gchar    *protocol_name;
+
+       mc = empathy_mission_control_new ();
+       tp_conn = mission_control_get_connection (mc, account, NULL);
+       g_object_unref (mc);
+       if (tp_conn == NULL) {
+               /* Account is disconnected */
+               return FALSE;
+       }
+       g_object_unref (tp_conn);
+
+       profile = mc_account_get_profile (account);
+       protocol_name = mc_profile_get_protocol_name (profile);
+       if (strcmp (protocol_name, "salut") == 0) {
+               /* We can't add accounts to a XMPP LL connection
+                * FIXME: We should take that information from the profile
+                * to not hardcode the protocol name
+                */
+               g_object_unref (profile);
+               return FALSE;
+       }
+
+       g_object_unref (profile);
+       return TRUE;
+}
+
+static gboolean
+contact_widget_id_activate_timeout (EmpathyContactWidget *self)
+{
+       contact_widget_update_contact (self);
+       return FALSE;
+}
+
+static void
+contact_widget_id_changed_cb (GtkEntry             *entry,
+                              EmpathyContactWidget *self)
+{
+       if (self->widget_id_timeout != 0) {             
+               g_source_remove (self->widget_id_timeout);
+       }
+
+       self->widget_id_timeout =
+               g_timeout_add (ID_CHANGED_TIMEOUT,
+                              (GSourceFunc) contact_widget_id_activate_timeout,
+                              self);
+}
+
 static void
 contact_widget_contact_setup (EmpathyContactWidget *information)
 {
@@ -277,39 +338,47 @@ contact_widget_contact_setup (EmpathyContactWidget *information)
                          6);
 
        /* Setup account label/chooser */
-       if (information->can_change_contact) {
+       if (information->type == CONTACT_WIDGET_TYPE_ADD) {
                information->widget_account = empathy_account_chooser_new ();
+               empathy_account_chooser_set_filter (
+                       EMPATHY_ACCOUNT_CHOOSER (information->widget_account),
+                       contact_widget_can_add_contact_to_account,
+                       NULL);
+
                g_signal_connect (information->widget_account, "changed",
                                  G_CALLBACK (contact_widget_account_changed_cb),
                                  information);
        } else {
                information->widget_account = gtk_label_new (NULL);
                gtk_label_set_selectable (GTK_LABEL (information->widget_account), TRUE);
+               gtk_misc_set_alignment (GTK_MISC (information->widget_account), 0, 0.5);
        }
        gtk_table_attach_defaults (GTK_TABLE (information->table_contact),
                                   information->widget_account,
                                   1, 2, 0, 1);
        gtk_widget_show (information->widget_account);
-       gtk_misc_set_alignment (GTK_MISC (information->widget_account), 0, 0.5);
 
        /* Setup id label/entry */
-       if (information->can_change_contact) {
+       if (information->type == CONTACT_WIDGET_TYPE_ADD) {
                information->widget_id = gtk_entry_new ();
                g_signal_connect (information->widget_id, "focus-out-event",
                                  G_CALLBACK (contact_widget_id_focus_out_cb),
                                  information);
+               g_signal_connect (information->widget_id, "changed",
+                                 G_CALLBACK (contact_widget_id_changed_cb),
+                                 information);
        } else {
                information->widget_id = gtk_label_new (NULL);
                gtk_label_set_selectable (GTK_LABEL (information->widget_id), TRUE);
+               gtk_misc_set_alignment (GTK_MISC (information->widget_id), 0, 0.5);
        }
        gtk_table_attach_defaults (GTK_TABLE (information->table_contact),
                                   information->widget_id,
                                   1, 2, 1, 2);
        gtk_widget_show (information->widget_id);
-       gtk_misc_set_alignment (GTK_MISC (information->widget_id), 0, 0.5);
 
        /* Setup alias label/entry */
-       if (information->editable) {
+       if (information->type > CONTACT_WIDGET_TYPE_SHOW) {
                information->widget_alias = gtk_entry_new ();
                g_signal_connect (information->widget_alias, "focus-out-event",
                                  G_CALLBACK (contact_widget_entry_alias_focus_event_cb),
@@ -317,12 +386,12 @@ contact_widget_contact_setup (EmpathyContactWidget *information)
        } else {
                information->widget_alias = gtk_label_new (NULL);
                gtk_label_set_selectable (GTK_LABEL (information->widget_alias), TRUE);
+               gtk_misc_set_alignment (GTK_MISC (information->widget_alias), 0, 0.5);
        }
        gtk_table_attach_defaults (GTK_TABLE (information->table_contact),
                                   information->widget_alias,
                                   1, 2, 2, 3);
        gtk_widget_show (information->widget_alias);
-       gtk_misc_set_alignment (GTK_MISC (information->widget_alias), 0, 0.5);
 }
 
 static void
@@ -348,7 +417,7 @@ contact_widget_contact_update (EmpathyContactWidget *information)
        }
 
        /* Update account widget */
-       if (information->can_change_contact) {
+       if (information->type == CONTACT_WIDGET_TYPE_ADD) {
                if (account) {
                        g_signal_handlers_block_by_func (information->widget_account,
                                                         contact_widget_account_changed_cb,
@@ -359,20 +428,16 @@ contact_widget_contact_update (EmpathyContactWidget *information)
                                                           contact_widget_account_changed_cb,
                                                           information);
                }
-       }
-       else if (account) {
-               const gchar *name;
-
-               name = mc_account_get_display_name (account);
-               gtk_label_set_label (GTK_LABEL (information->widget_account), name);
-       }
-
-       /* Update id widget */
-       if (information->can_change_contact) {
                if (!G_STR_EMPTY (id)) {
                        gtk_entry_set_text (GTK_ENTRY (information->widget_id), id);
                }
        } else {
+               if (account) {
+                       const gchar *name;
+
+                       name = mc_account_get_display_name (account);
+                       gtk_label_set_label (GTK_LABEL (information->widget_account), name);
+               }
                gtk_label_set_label (GTK_LABEL (information->widget_id), id);
        }
 
@@ -453,7 +518,7 @@ contact_widget_entry_alias_focus_event_cb (GtkEditable          *editable,
 static void
 contact_widget_name_notify_cb (EmpathyContactWidget *information)
 {
-       if (information->editable) {
+       if (GTK_IS_ENTRY (information->widget_alias)) {
                gtk_entry_set_text (GTK_ENTRY (information->widget_alias),
                                    empathy_contact_get_name (information->contact));
        } else {
@@ -494,7 +559,7 @@ contact_widget_avatar_notify_cb (EmpathyContactWidget *information)
 static void
 contact_widget_groups_setup (EmpathyContactWidget *information)
 {
-       if (information->editable) {
+       if (information->type > CONTACT_WIDGET_TYPE_SHOW) {
                contact_widget_model_setup (information);
        }
 }
@@ -502,7 +567,8 @@ contact_widget_groups_setup (EmpathyContactWidget *information)
 static void
 contact_widget_groups_update (EmpathyContactWidget *information)
 {
-       if (information->editable && information->contact) {
+       if (information->type > CONTACT_WIDGET_TYPE_SHOW &&
+           information->contact) {
                g_signal_connect_swapped (information->contact, "notify::groups",
                                          G_CALLBACK (contact_widget_groups_notify_cb),
                                          information);
index f48d15e70008265983efe2b6b6f5490781b5ea16..119d8a5963445c7b9f45d36a750cf67d0c288bf7 100644 (file)
 
 G_BEGIN_DECLS
 
-GtkWidget *    empathy_contact_widget_new         (EmpathyContact *contact,
-                                                  gboolean       editable);
-EmpathyContact *empathy_contact_widget_get_contact (GtkWidget     *widget);
+typedef enum {
+       CONTACT_WIDGET_TYPE_SHOW, /* used to show contact information */
+       CONTACT_WIDGET_TYPE_EDIT, /* used to edit contact information */
+       CONTACT_WIDGET_TYPE_ADD,  /* used to add a new contact */
+       CONTACT_WIDGET_TYPE_SUBSCRIPTION /* used to accepte/reject a new contact */
+} EmpathyContactWidgetType;
+
+GtkWidget *     empathy_contact_widget_new         (EmpathyContact           *contact,
+                                                   EmpathyContactWidgetType  type);
+EmpathyContact *empathy_contact_widget_get_contact (GtkWidget                *widget);
 
 G_END_DECLS
 #endif /*  __EMPATHY_CONTACT_WIDGET_H__ */
index 53eb39c8f9d5b2db5b672e85c24279cdc46da332..b50ab9faf9207db74ec2729e6a23d46d6264b914 100644 (file)
@@ -239,7 +239,6 @@ empathy_log_window_show (McAccount   *account,
        /* Account chooser for chats */
        window->account_chooser_chats = empathy_account_chooser_new ();
        account_chooser = EMPATHY_ACCOUNT_CHOOSER (window->account_chooser_chats);
-       empathy_account_chooser_set_can_select_all (account_chooser, TRUE);
 
        gtk_box_pack_start (GTK_BOX (window->vbox_chats),
                            window->account_chooser_chats,
index 6194fb2946649b74d54489e330d0a3f66bfd5885..1c84c70bd3206cc5d48e522ed8c9e76bf938a206 100644 (file)
@@ -185,6 +185,9 @@ empathy_new_chatroom_dialog_show (GtkWindow *parent)
 
        /* Account chooser for custom */
        dialog->account_chooser = empathy_account_chooser_new ();
+       empathy_account_chooser_set_filter (EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser),
+                                           empathy_account_chooser_filter_is_connected,
+                                           NULL);
        gtk_table_attach_defaults (GTK_TABLE (dialog->table_info),
                                   dialog->account_chooser,
                                   1, 3, 0, 1);