summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@gmail.com>2007-07-26 14:27:45 +0000
committerXavier Claessens <xclaesse@src.gnome.org>2007-07-26 14:27:45 +0000
commitbc51bf4283ead42b56ddcd174d3273b446ac4aa4 (patch)
tree0c13a5b7b0cc6e8a678db595e6b79eb2d46ffa25
parent7907c710253ba70cf1b3f475a1f7be79d0e3f546 (diff)
Do not show salut accounts in the add contact dialog. Rework a bit
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
-rw-r--r--ChangeLog14
-rw-r--r--doc/libempathy-gtk/tmpl/empathy-account-chooser.sgml18
-rw-r--r--doc/libempathy-gtk/tmpl/empathy-contact-widget.sgml2
-rw-r--r--libempathy-gtk/empathy-account-chooser.c169
-rw-r--r--libempathy-gtk/empathy-account-chooser.h17
-rw-r--r--libempathy-gtk/empathy-chatrooms-window.c4
-rw-r--r--libempathy-gtk/empathy-contact-dialogs.c26
-rw-r--r--libempathy-gtk/empathy-contact-widget.c122
-rw-r--r--libempathy-gtk/empathy-contact-widget.h13
-rw-r--r--libempathy-gtk/empathy-log-window.c1
-rw-r--r--libempathy-gtk/empathy-new-chatroom-dialog.c3
11 files changed, 232 insertions, 157 deletions
diff --git a/ChangeLog b/ChangeLog
index aaf1f61e..5d9c8e77 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
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
hidden after cancelling. Fixes bug #458997 (Frederic Peters).
diff --git a/doc/libempathy-gtk/tmpl/empathy-account-chooser.sgml b/doc/libempathy-gtk/tmpl/empathy-account-chooser.sgml
index 73f07db4..9db0bf2a 100644
--- a/doc/libempathy-gtk/tmpl/empathy-account-chooser.sgml
+++ b/doc/libempathy-gtk/tmpl/empathy-account-chooser.sgml
@@ -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>
diff --git a/doc/libempathy-gtk/tmpl/empathy-contact-widget.sgml b/doc/libempathy-gtk/tmpl/empathy-contact-widget.sgml
index bdba0d8f..a715f098 100644
--- a/doc/libempathy-gtk/tmpl/empathy-contact-widget.sgml
+++ b/doc/libempathy-gtk/tmpl/empathy-contact-widget.sgml
@@ -23,7 +23,7 @@ empathy-contact-widget
</para>
@contact:
-@editable:
+@type:
@Returns:
diff --git a/libempathy-gtk/empathy-account-chooser.c b/libempathy-gtk/empathy-account-chooser.c
index eb46c52f..6d3aea6a 100644
--- a/libempathy-gtk/empathy-account-chooser.c
+++ b/libempathy-gtk/empathy-account-chooser.c
@@ -40,18 +40,18 @@
#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,
};
@@ -121,14 +116,6 @@ empathy_account_chooser_class_init (EmpathyAccountChooserClass *klass)
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",
"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));
@@ -293,46 +278,6 @@ empathy_account_chooser_set_account (EmpathyAccountChooser *chooser,
}
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)
{
EmpathyAccountChooserPriv *priv;
@@ -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;
+}
diff --git a/libempathy-gtk/empathy-account-chooser.h b/libempathy-gtk/empathy-account-chooser.h
index 8d9cb657..14616038 100644
--- a/libempathy-gtk/empathy-account-chooser.h
+++ b/libempathy-gtk/empathy-account-chooser.h
@@ -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
diff --git a/libempathy-gtk/empathy-chatrooms-window.c b/libempathy-gtk/empathy-chatrooms-window.c
index 390fff42..9a0d125e 100644
--- a/libempathy-gtk/empathy-chatrooms-window.c
+++ b/libempathy-gtk/empathy-chatrooms-window.c
@@ -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);
diff --git a/libempathy-gtk/empathy-contact-dialogs.c b/libempathy-gtk/empathy-contact-dialogs.c
index b0d24dec..437e255f 100644
--- a/libempathy-gtk/empathy-contact-dialogs.c
+++ b/libempathy-gtk/empathy-contact-dialogs.c
@@ -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);
diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c
index 617a7d62..df780b84 100644
--- a/libempathy-gtk/empathy-contact-widget.c
+++ b/libempathy-gtk/empathy-contact-widget.c
@@ -32,17 +32,21 @@
#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);
diff --git a/libempathy-gtk/empathy-contact-widget.h b/libempathy-gtk/empathy-contact-widget.h
index f48d15e7..119d8a59 100644
--- a/libempathy-gtk/empathy-contact-widget.h
+++ b/libempathy-gtk/empathy-contact-widget.h
@@ -29,9 +29,16 @@
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__ */
diff --git a/libempathy-gtk/empathy-log-window.c b/libempathy-gtk/empathy-log-window.c
index 53eb39c8..b50ab9fa 100644
--- a/libempathy-gtk/empathy-log-window.c
+++ b/libempathy-gtk/empathy-log-window.c
@@ -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,
diff --git a/libempathy-gtk/empathy-new-chatroom-dialog.c b/libempathy-gtk/empathy-new-chatroom-dialog.c
index 6194fb29..1c84c70b 100644
--- a/libempathy-gtk/empathy-new-chatroom-dialog.c
+++ b/libempathy-gtk/empathy-new-chatroom-dialog.c
@@ -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);